mirror of https://github.com/axmolengine/axmol.git
DrawNode add isolate flag (#19056)
* add isolate flag * add comment for DrawNode::visit * add modifier: const/virtual * update comment & change initializer
This commit is contained in:
parent
f8ed20e4b3
commit
53bed4fda3
|
@ -101,25 +101,7 @@ static inline Tex2F __t(const Vec2 &v)
|
|||
// implementation of DrawNode
|
||||
|
||||
DrawNode::DrawNode(GLfloat lineWidth)
|
||||
: _vao(0)
|
||||
, _vbo(0)
|
||||
, _vaoGLPoint(0)
|
||||
, _vboGLPoint(0)
|
||||
, _vaoGLLine(0)
|
||||
, _vboGLLine(0)
|
||||
, _bufferCapacity(0)
|
||||
, _bufferCount(0)
|
||||
, _buffer(nullptr)
|
||||
, _bufferCapacityGLPoint(0)
|
||||
, _bufferCountGLPoint(0)
|
||||
, _bufferGLPoint(nullptr)
|
||||
, _bufferCapacityGLLine(0)
|
||||
, _bufferCountGLLine(0)
|
||||
, _bufferGLLine(nullptr)
|
||||
, _dirty(false)
|
||||
, _dirtyGLPoint(false)
|
||||
, _dirtyGLLine(false)
|
||||
, _lineWidth(lineWidth)
|
||||
: _lineWidth(lineWidth)
|
||||
, _defaultLineWidth(lineWidth)
|
||||
{
|
||||
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
||||
|
@ -957,5 +939,17 @@ GLfloat DrawNode::getLineWidth()
|
|||
return this->_lineWidth;
|
||||
}
|
||||
|
||||
void DrawNode::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
if (_isolated)
|
||||
{
|
||||
//ignore `parentTransform` from parent
|
||||
Node::visit(renderer, Mat4::IDENTITY, parentFlags);
|
||||
}
|
||||
else
|
||||
{
|
||||
Node::visit(renderer, parentTransform, parentFlags);
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -313,12 +313,22 @@ public:
|
|||
|
||||
// Overrides
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
|
||||
virtual void visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
|
||||
void setLineWidth(GLfloat lineWidth);
|
||||
|
||||
// Get CocosStudio guide lines width.
|
||||
GLfloat getLineWidth();
|
||||
|
||||
/**
|
||||
* When isolated is set, the position of the node is no longer affected by parent nodes.
|
||||
* Which means it will be drawn just like a root node.
|
||||
*/
|
||||
void setIsolated(bool isolated) { _isolated = isolated; }
|
||||
|
||||
bool isIsolated() const { return _isolated; }
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
DrawNode(GLfloat lineWidth = DEFAULT_LINE_WIDTH);
|
||||
virtual ~DrawNode();
|
||||
|
@ -331,39 +341,40 @@ protected:
|
|||
|
||||
void setupBuffer();
|
||||
|
||||
GLuint _vao;
|
||||
GLuint _vbo;
|
||||
GLuint _vaoGLPoint;
|
||||
GLuint _vboGLPoint;
|
||||
GLuint _vaoGLLine;
|
||||
GLuint _vboGLLine;
|
||||
GLuint _vao = 0;
|
||||
GLuint _vbo = 0;
|
||||
GLuint _vaoGLPoint = 0;
|
||||
GLuint _vboGLPoint = 0;
|
||||
GLuint _vaoGLLine = 0;
|
||||
GLuint _vboGLLine = 0;
|
||||
|
||||
int _bufferCapacity;
|
||||
GLsizei _bufferCount;
|
||||
V2F_C4B_T2F *_buffer;
|
||||
int _bufferCapacity = 0;
|
||||
GLsizei _bufferCount = 0;
|
||||
V2F_C4B_T2F *_buffer = nullptr;
|
||||
|
||||
int _bufferCapacityGLPoint;
|
||||
GLsizei _bufferCountGLPoint;
|
||||
V2F_C4B_T2F *_bufferGLPoint;
|
||||
int _bufferCapacityGLPoint = 0;
|
||||
GLsizei _bufferCountGLPoint = 0;
|
||||
V2F_C4B_T2F *_bufferGLPoint = nullptr;
|
||||
Color4F _pointColor;
|
||||
int _pointSize;
|
||||
int _pointSize = 0;
|
||||
|
||||
int _bufferCapacityGLLine;
|
||||
GLsizei _bufferCountGLLine;
|
||||
V2F_C4B_T2F *_bufferGLLine;
|
||||
int _bufferCapacityGLLine = 0;
|
||||
GLsizei _bufferCountGLLine = 0;
|
||||
V2F_C4B_T2F *_bufferGLLine = nullptr;
|
||||
|
||||
BlendFunc _blendFunc;
|
||||
CustomCommand _customCommand;
|
||||
CustomCommand _customCommandGLPoint;
|
||||
CustomCommand _customCommandGLLine;
|
||||
|
||||
bool _dirty;
|
||||
bool _dirtyGLPoint;
|
||||
bool _dirtyGLLine;
|
||||
bool _dirty = false;
|
||||
bool _dirtyGLPoint = false;
|
||||
bool _dirtyGLLine = false;
|
||||
bool _isolated = false;
|
||||
|
||||
GLfloat _lineWidth;
|
||||
GLfloat _lineWidth = 0.0f;
|
||||
|
||||
GLfloat _defaultLineWidth;
|
||||
GLfloat _defaultLineWidth = 0.0f;
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(DrawNode);
|
||||
};
|
||||
|
|
|
@ -270,6 +270,7 @@ void PhysicsWorld::debugDraw()
|
|||
if (_debugDraw == nullptr)
|
||||
{
|
||||
_debugDraw = DrawNode::create();
|
||||
_debugDraw->setIsolated(true);
|
||||
_debugDraw->retain();
|
||||
Director::getInstance()->getRunningScene()->addChild(_debugDraw);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue