mirror of https://github.com/axmolengine/axmol.git
remove kmMat4 interface in cocostudio and UI
This commit is contained in:
parent
504fa2aa60
commit
a269ac2864
|
@ -72,7 +72,7 @@ Bone::Bone()
|
|||
_displayManager = nullptr;
|
||||
_ignoreMovementBoneData = false;
|
||||
// _worldTransform = AffineTransformMake(1, 0, 0, 1, 0, 0);
|
||||
kmMat4Identity(&_worldTransform);
|
||||
_worldTransform = Matrix::identity();
|
||||
_boneTransformDirty = true;
|
||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
_blendDirty = false;
|
||||
|
@ -238,8 +238,8 @@ void Bone::applyParentTransform(Bone *parent)
|
|||
{
|
||||
float x = _worldInfo->x;
|
||||
float y = _worldInfo->y;
|
||||
_worldInfo->x = x * parent->_worldTransform.mat[0] + y * parent->_worldTransform.mat[4] + parent->_worldInfo->x;
|
||||
_worldInfo->y = x * parent->_worldTransform.mat[1] + y * parent->_worldTransform.mat[5] + parent->_worldInfo->y;
|
||||
_worldInfo->x = x * parent->_worldTransform.m[0] + y * parent->_worldTransform.m[4] + parent->_worldInfo->x;
|
||||
_worldInfo->y = x * parent->_worldTransform.m[1] + y * parent->_worldTransform.m[5] + parent->_worldInfo->y;
|
||||
_worldInfo->scaleX = _worldInfo->scaleX * parent->_worldInfo->scaleX;
|
||||
_worldInfo->scaleY = _worldInfo->scaleY * parent->_worldInfo->scaleY;
|
||||
_worldInfo->skewX = _worldInfo->skewX + parent->_worldInfo->skewX;
|
||||
|
@ -380,7 +380,7 @@ void Bone::setLocalZOrder(int zOrder)
|
|||
Node::setLocalZOrder(zOrder);
|
||||
}
|
||||
|
||||
kmMat4 Bone::getNodeToArmatureTransform() const
|
||||
Matrix Bone::getNodeToArmatureTransform() const
|
||||
{
|
||||
return _worldTransform;
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ public:
|
|||
virtual void setTransformDirty(bool dirty) { _boneTransformDirty = dirty; }
|
||||
virtual bool isTransformDirty() { return _boneTransformDirty; }
|
||||
|
||||
virtual kmMat4 getNodeToArmatureTransform() const;
|
||||
virtual Matrix getNodeToArmatureTransform() const;
|
||||
virtual Matrix getNodeToWorldTransform() const override;
|
||||
|
||||
Node *getDisplayRenderNode();
|
||||
|
@ -250,7 +250,7 @@ protected:
|
|||
bool _boneTransformDirty; //! Whether or not transform dirty
|
||||
|
||||
//! self Transform, use this to change display's state
|
||||
kmMat4 _worldTransform;
|
||||
Matrix _worldTransform;
|
||||
|
||||
BaseData *_worldInfo;
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ ColliderFilter *ColliderDetector::getColliderFilter()
|
|||
|
||||
Point helpPoint;
|
||||
|
||||
void ColliderDetector::updateTransform(kmMat4 &t)
|
||||
void ColliderDetector::updateTransform(Matrix &t)
|
||||
{
|
||||
if (!_active)
|
||||
{
|
||||
|
|
|
@ -42,6 +42,8 @@ THE SOFTWARE.
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
USING_NS_CC_MATH;
|
||||
|
||||
class Bone;
|
||||
|
||||
/**
|
||||
|
@ -155,7 +157,7 @@ public:
|
|||
void removeContourData(ContourData *contourData);
|
||||
void removeAll();
|
||||
|
||||
void updateTransform(kmMat4 &t);
|
||||
void updateTransform(Matrix &t);
|
||||
|
||||
void setActive(bool active);
|
||||
bool getActive();
|
||||
|
|
|
@ -118,7 +118,7 @@ void DisplayFactory::updateDisplay(Bone *bone, float dt, bool dirty)
|
|||
anchorPoint = PointApplyTransform(anchorPoint, displayTransform);
|
||||
displayTransform.mat[12] = anchorPoint.x;
|
||||
displayTransform.mat[13] = anchorPoint.y;
|
||||
kmMat4 t = TransformConcat( bone->getArmature()->getNodeToParentTransform(),displayTransform);
|
||||
Matrix t = TransformConcat( bone->getArmature()->getNodeToParentTransform(),displayTransform);
|
||||
detector->updateTransform(t);
|
||||
}
|
||||
while (0);
|
||||
|
|
|
@ -86,7 +86,7 @@ Skin::Skin()
|
|||
, _armature(nullptr)
|
||||
, _displayName("")
|
||||
{
|
||||
kmMat4Identity(&_skinTransform);
|
||||
_skinTransform = Matrix::identity();
|
||||
}
|
||||
|
||||
bool Skin::initWithSpriteFrameName(const std::string& spriteFrameName)
|
||||
|
@ -206,7 +206,7 @@ Matrix Skin::getNodeToWorldTransform() const
|
|||
return TransformConcat( _bone->getArmature()->getNodeToWorldTransform(), _transform);
|
||||
}
|
||||
|
||||
kmMat4 Skin::getNodeToWorldTransformAR() const
|
||||
Matrix Skin::getNodeToWorldTransformAR() const
|
||||
{
|
||||
kmMat4 displayTransform = _transform;
|
||||
Point anchorPoint = _anchorPointInPoints;
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
void updateTransform() override;
|
||||
|
||||
Matrix getNodeToWorldTransform() const override;
|
||||
kmMat4 getNodeToWorldTransformAR() const;
|
||||
Matrix getNodeToWorldTransformAR() const;
|
||||
|
||||
virtual void draw(cocos2d::Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
||||
|
||||
|
@ -75,7 +75,7 @@ protected:
|
|||
BaseData _skinData;
|
||||
Bone *_bone;
|
||||
Armature *_armature;
|
||||
kmMat4 _skinTransform;
|
||||
Matrix _skinTransform;
|
||||
std::string _displayName;
|
||||
cocos2d::QuadCommand _quadCommand; // quad command
|
||||
};
|
||||
|
|
|
@ -118,30 +118,30 @@ void TransformHelp::nodeToMatrix(const BaseData &node, AffineTransform &matrix)
|
|||
matrix.ty = node.y;
|
||||
}
|
||||
|
||||
void TransformHelp::nodeToMatrix(const BaseData &node, kmMat4 &matrix)
|
||||
void TransformHelp::nodeToMatrix(const BaseData &node, Matrix &matrix)
|
||||
{
|
||||
kmMat4Identity(&matrix);
|
||||
matrix = Matrix::identity();
|
||||
|
||||
if (node.skewX == -node.skewY)
|
||||
{
|
||||
double sine = sin(node.skewX);
|
||||
double cosine = cos(node.skewX);
|
||||
|
||||
matrix.mat[0] = node.scaleX * cosine;
|
||||
matrix.mat[1] = node.scaleX * -sine;
|
||||
matrix.mat[4] = node.scaleY * sine;
|
||||
matrix.mat[5] = node.scaleY * cosine;
|
||||
matrix.m[0] = node.scaleX * cosine;
|
||||
matrix.m[1] = node.scaleX * -sine;
|
||||
matrix.m[4] = node.scaleY * sine;
|
||||
matrix.m[5] = node.scaleY * cosine;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix.mat[0] = node.scaleX * cos(node.skewY);
|
||||
matrix.mat[1] = node.scaleX * sin(node.skewY);
|
||||
matrix.mat[4] = node.scaleY * sin(node.skewX);
|
||||
matrix.mat[5] = node.scaleY * cos(node.skewX);
|
||||
matrix.m[0] = node.scaleX * cos(node.skewY);
|
||||
matrix.m[1] = node.scaleX * sin(node.skewY);
|
||||
matrix.m[4] = node.scaleY * sin(node.skewX);
|
||||
matrix.m[5] = node.scaleY * cos(node.skewX);
|
||||
}
|
||||
|
||||
matrix.mat[12] = node.x;
|
||||
matrix.mat[13] = node.y;
|
||||
matrix.m[12] = node.x;
|
||||
matrix.m[13] = node.y;
|
||||
}
|
||||
|
||||
|
||||
|
@ -171,7 +171,7 @@ void TransformHelp::matrixToNode(const AffineTransform &matrix, BaseData &node)
|
|||
node.y = matrix.ty;
|
||||
}
|
||||
|
||||
void TransformHelp::matrixToNode(const kmMat4 &matrix, BaseData &node)
|
||||
void TransformHelp::matrixToNode(const Matrix &matrix, BaseData &node)
|
||||
{
|
||||
/*
|
||||
* In as3 language, there is a function called "deltaTransformPoint", it calculate a point used give Transform
|
||||
|
@ -180,21 +180,21 @@ void TransformHelp::matrixToNode(const kmMat4 &matrix, BaseData &node)
|
|||
helpPoint1.x = 0;
|
||||
helpPoint1.y = 1;
|
||||
helpPoint1 = PointApplyTransform(helpPoint1, matrix);
|
||||
helpPoint1.x -= matrix.mat[12];
|
||||
helpPoint1.y -= matrix.mat[13];
|
||||
helpPoint1.x -= matrix.m[12];
|
||||
helpPoint1.y -= matrix.m[13];
|
||||
|
||||
helpPoint2.x = 1;
|
||||
helpPoint2.y = 0;
|
||||
helpPoint2 = PointApplyTransform(helpPoint2, matrix);
|
||||
helpPoint2.x -= matrix.mat[12];
|
||||
helpPoint2.y -= matrix.mat[13];
|
||||
helpPoint2.x -= matrix.m[12];
|
||||
helpPoint2.y -= matrix.m[13];
|
||||
|
||||
node.skewX = -(atan2f(helpPoint1.y, helpPoint1.x) - 1.5707964f);
|
||||
node.skewY = atan2f(helpPoint2.y, helpPoint2.x);
|
||||
node.scaleX = sqrt(matrix.mat[0] * matrix.mat[0] + matrix.mat[1] * matrix.mat[1]);
|
||||
node.scaleY = sqrt(matrix.mat[4] * matrix.mat[4] + matrix.mat[5] * matrix.mat[5]);
|
||||
node.x = matrix.mat[12];
|
||||
node.y = matrix.mat[13];
|
||||
node.scaleX = sqrt(matrix.m[0] * matrix.m[0] + matrix.m[1] * matrix.m[1]);
|
||||
node.scaleY = sqrt(matrix.m[4] * matrix.m[4] + matrix.m[5] * matrix.m[5]);
|
||||
node.x = matrix.m[12];
|
||||
node.y = matrix.m[13];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ THE SOFTWARE.
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
USING_NS_CC_MATH;
|
||||
|
||||
/*
|
||||
* use to calculate the matrix of node from parent node
|
||||
* @js NA
|
||||
|
@ -47,9 +49,9 @@ public:
|
|||
static void transformToParentWithoutScale(BaseData &node, const BaseData &parentNode);
|
||||
|
||||
static void nodeToMatrix(const BaseData &_node, cocos2d::AffineTransform &_matrix);
|
||||
static void nodeToMatrix(const BaseData &node, kmMat4 &matrix);
|
||||
static void nodeToMatrix(const BaseData &node, Matrix &matrix);
|
||||
static void matrixToNode(const cocos2d::AffineTransform &_matrix, BaseData &_node);
|
||||
static void matrixToNode(const kmMat4 &_matrix, BaseData &_node);
|
||||
static void matrixToNode(const Matrix &_matrix, BaseData &_node);
|
||||
|
||||
static void nodeConcat(BaseData &target, BaseData &source);
|
||||
static void nodeSub(BaseData &target, BaseData &source);
|
||||
|
|
|
@ -133,7 +133,7 @@ void Skeleton::draw(cocos2d::Renderer *renderer, const Matrix &transform, bool t
|
|||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void Skeleton::onDraw(const kmMat4 &transform, bool transformUpdated)
|
||||
void Skeleton::onDraw(const Matrix &transform, bool transformUpdated)
|
||||
{
|
||||
getShaderProgram()->use();
|
||||
getShaderProgram()->setUniformsForBuiltins(transform);
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
|
||||
virtual void update (float deltaTime) override;
|
||||
virtual void draw(cocos2d::Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
||||
void onDraw(const kmMat4 &transform, bool transformUpdated);
|
||||
void onDraw(const Matrix &transform, bool transformUpdated);
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
virtual cocos2d::Rect getBoundingBox () const override;
|
||||
|
|
|
@ -744,7 +744,7 @@ void Layout::sortAllChildren()
|
|||
doLayout();
|
||||
}
|
||||
|
||||
void Layout::stencilClippingVisit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
|
||||
void Layout::stencilClippingVisit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
if(!_visible)
|
||||
return;
|
||||
|
@ -902,7 +902,7 @@ void Layout::onAfterVisitScissor()
|
|||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
void Layout::scissorClippingVisit(Renderer *renderer, const kmMat4& parentTransform, bool parentTransformUpdated)
|
||||
void Layout::scissorClippingVisit(Renderer *renderer, const Matrix& parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
_beforeVisitCmdScissor.init(_globalZOrder);
|
||||
_beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this);
|
||||
|
|
|
@ -284,8 +284,8 @@ protected:
|
|||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void copyClonedWidgetChildren(Widget* model) override;
|
||||
|
||||
void stencilClippingVisit(Renderer *renderer, const kmMat4& parentTransform, bool parentTransformUpdated);
|
||||
void scissorClippingVisit(Renderer *renderer, const kmMat4& parentTransform, bool parentTransformUpdated);
|
||||
void stencilClippingVisit(Renderer *renderer, const Matrix& parentTransform, bool parentTransformUpdated);
|
||||
void scissorClippingVisit(Renderer *renderer, const Matrix& parentTransform, bool parentTransformUpdated);
|
||||
|
||||
void setStencilClippingSize(const Size& size);
|
||||
const Rect& getClippingRect();
|
||||
|
|
Loading…
Reference in New Issue