mirror of https://github.com/axmolengine/axmol.git
Matrix::identity() -> IDENTITY
consistency with the rest of the cocos2d API
This commit is contained in:
parent
41e57a6de3
commit
31dd70dba2
|
@ -98,7 +98,7 @@ void ActionCamera::updateTransform()
|
||||||
|
|
||||||
bool needsTranslation = !anchorPoint.equals(Vector2::ZERO);
|
bool needsTranslation = !anchorPoint.equals(Vector2::ZERO);
|
||||||
|
|
||||||
Matrix mv = Matrix::identity();
|
Matrix mv = Matrix::IDENTITY;
|
||||||
|
|
||||||
if(needsTranslation) {
|
if(needsTranslation) {
|
||||||
Matrix t;
|
Matrix t;
|
||||||
|
|
|
@ -135,7 +135,7 @@ Node::Node(void)
|
||||||
ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine();
|
ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine();
|
||||||
_scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone;
|
_scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone;
|
||||||
#endif
|
#endif
|
||||||
_transform = _inverse = _additionalTransform = Matrix::identity();
|
_transform = _inverse = _additionalTransform = Matrix::IDENTITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::~Node()
|
Node::~Node()
|
||||||
|
|
|
@ -1004,7 +1004,7 @@ void Sprite::setBatchNode(SpriteBatchNode *spriteBatchNode)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// using batch
|
// using batch
|
||||||
_transformToBatch = Matrix::identity();
|
_transformToBatch = Matrix::IDENTITY;
|
||||||
setTextureAtlas(_batchNode->getTextureAtlas()); // weak ref
|
setTextureAtlas(_batchNode->getTextureAtlas()); // weak ref
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,19 +285,17 @@ void Director::drawScene()
|
||||||
|
|
||||||
pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||||
|
|
||||||
Matrix identity = Matrix::identity();
|
|
||||||
|
|
||||||
// draw the scene
|
// draw the scene
|
||||||
if (_runningScene)
|
if (_runningScene)
|
||||||
{
|
{
|
||||||
_runningScene->visit(_renderer, identity, false);
|
_runningScene->visit(_renderer, Matrix::IDENTITY, false);
|
||||||
_eventDispatcher->dispatchEvent(_eventAfterVisit);
|
_eventDispatcher->dispatchEvent(_eventAfterVisit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the notifications node
|
// draw the notifications node
|
||||||
if (_notificationNode)
|
if (_notificationNode)
|
||||||
{
|
{
|
||||||
_notificationNode->visit(_renderer, identity, false);
|
_notificationNode->visit(_renderer, Matrix::IDENTITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_displayStats)
|
if (_displayStats)
|
||||||
|
@ -451,9 +449,9 @@ void Director::initMatrixStack()
|
||||||
_textureMatrixStack.pop();
|
_textureMatrixStack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
_modelViewMatrixStack.push(Matrix::identity());
|
_modelViewMatrixStack.push(Matrix::IDENTITY);
|
||||||
_projectionMatrixStack.push(Matrix::identity());
|
_projectionMatrixStack.push(Matrix::IDENTITY);
|
||||||
_textureMatrixStack.push(Matrix::identity());
|
_textureMatrixStack.push(Matrix::IDENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::resetMatrixStack()
|
void Director::resetMatrixStack()
|
||||||
|
@ -485,15 +483,15 @@ void Director::loadIdentityMatrix(MATRIX_STACK_TYPE type)
|
||||||
{
|
{
|
||||||
if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type)
|
if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type)
|
||||||
{
|
{
|
||||||
_modelViewMatrixStack.top() = Matrix::identity();
|
_modelViewMatrixStack.top() = Matrix::IDENTITY;
|
||||||
}
|
}
|
||||||
else if(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION == type)
|
else if(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION == type)
|
||||||
{
|
{
|
||||||
_projectionMatrixStack.top() = Matrix::identity();
|
_projectionMatrixStack.top() = Matrix::IDENTITY;
|
||||||
}
|
}
|
||||||
else if(MATRIX_STACK_TYPE::MATRIX_STACK_TEXTURE == type)
|
else if(MATRIX_STACK_TYPE::MATRIX_STACK_TEXTURE == type)
|
||||||
{
|
{
|
||||||
_textureMatrixStack.top() = Matrix::identity();
|
_textureMatrixStack.top() = Matrix::IDENTITY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1082,7 +1080,7 @@ void Director::showStats()
|
||||||
prevVerts = currentVerts;
|
prevVerts = currentVerts;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix identity = Matrix::identity();
|
Matrix identity = Matrix::IDENTITY;
|
||||||
|
|
||||||
_drawnVerticesLabel->visit(_renderer, identity, false);
|
_drawnVerticesLabel->visit(_renderer, identity, false);
|
||||||
_drawnBatchesLabel->visit(_renderer, identity, false);
|
_drawnBatchesLabel->visit(_renderer, identity, false);
|
||||||
|
|
|
@ -275,7 +275,7 @@ Matrix* kmMat4Assign(Matrix* pOut, const Matrix* pIn)
|
||||||
|
|
||||||
Matrix* kmMat4Identity(Matrix* pOut)
|
Matrix* kmMat4Identity(Matrix* pOut)
|
||||||
{
|
{
|
||||||
*pOut = Matrix::identity();
|
*pOut = Matrix::IDENTITY;
|
||||||
return pOut;
|
return pOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ Bone::Bone()
|
||||||
_displayManager = nullptr;
|
_displayManager = nullptr;
|
||||||
_ignoreMovementBoneData = false;
|
_ignoreMovementBoneData = false;
|
||||||
// _worldTransform = AffineTransformMake(1, 0, 0, 1, 0, 0);
|
// _worldTransform = AffineTransformMake(1, 0, 0, 1, 0, 0);
|
||||||
_worldTransform = Matrix::identity();
|
_worldTransform = Matrix::IDENTITY;
|
||||||
_boneTransformDirty = true;
|
_boneTransformDirty = true;
|
||||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||||
_blendDirty = false;
|
_blendDirty = false;
|
||||||
|
|
|
@ -86,7 +86,7 @@ Skin::Skin()
|
||||||
, _armature(nullptr)
|
, _armature(nullptr)
|
||||||
, _displayName("")
|
, _displayName("")
|
||||||
{
|
{
|
||||||
_skinTransform = Matrix::identity();
|
_skinTransform = Matrix::IDENTITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Skin::initWithSpriteFrameName(const std::string& spriteFrameName)
|
bool Skin::initWithSpriteFrameName(const std::string& spriteFrameName)
|
||||||
|
|
|
@ -120,7 +120,7 @@ void TransformHelp::nodeToMatrix(const BaseData &node, AffineTransform &matrix)
|
||||||
|
|
||||||
void TransformHelp::nodeToMatrix(const BaseData &node, Matrix &matrix)
|
void TransformHelp::nodeToMatrix(const BaseData &node, Matrix &matrix)
|
||||||
{
|
{
|
||||||
matrix = Matrix::identity();
|
matrix = Matrix::IDENTITY;
|
||||||
|
|
||||||
if (node.skewX == -node.skewY)
|
if (node.skewX == -node.skewY)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,17 +25,9 @@
|
||||||
|
|
||||||
NS_CC_MATH_BEGIN
|
NS_CC_MATH_BEGIN
|
||||||
|
|
||||||
static const float MATRIX_IDENTITY[16] =
|
|
||||||
{
|
|
||||||
1.0f, 0.0f, 0.0f, 0.0f,
|
|
||||||
0.0f, 1.0f, 0.0f, 0.0f,
|
|
||||||
0.0f, 0.0f, 1.0f, 0.0f,
|
|
||||||
0.0f, 0.0f, 0.0f, 1.0f
|
|
||||||
};
|
|
||||||
|
|
||||||
Matrix::Matrix()
|
Matrix::Matrix()
|
||||||
{
|
{
|
||||||
*this = Matrix::identity();
|
*this = IDENTITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix::Matrix(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24,
|
Matrix::Matrix(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24,
|
||||||
|
@ -58,26 +50,6 @@ Matrix::~Matrix()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const Matrix& Matrix::identity()
|
|
||||||
{
|
|
||||||
static Matrix m(
|
|
||||||
1, 0, 0, 0,
|
|
||||||
0, 1, 0, 0,
|
|
||||||
0, 0, 1, 0,
|
|
||||||
0, 0, 0, 1 );
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Matrix& Matrix::zero()
|
|
||||||
{
|
|
||||||
static Matrix m(
|
|
||||||
0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0 );
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Matrix::createLookAt(const Vector3& eyePosition, const Vector3& targetPosition, const Vector3& up, Matrix* dst)
|
void Matrix::createLookAt(const Vector3& eyePosition, const Vector3& targetPosition, const Vector3& up, Matrix* dst)
|
||||||
{
|
{
|
||||||
createLookAt(eyePosition.x, eyePosition.y, eyePosition.z, targetPosition.x, targetPosition.y, targetPosition.z,
|
createLookAt(eyePosition.x, eyePosition.y, eyePosition.z, targetPosition.x, targetPosition.y, targetPosition.z,
|
||||||
|
@ -250,7 +222,7 @@ void Matrix::createScale(const Vector3& scale, Matrix* dst)
|
||||||
{
|
{
|
||||||
GP_ASSERT(dst);
|
GP_ASSERT(dst);
|
||||||
|
|
||||||
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
|
memcpy(dst, &IDENTITY, MATRIX_SIZE);
|
||||||
|
|
||||||
dst->m[0] = scale.x;
|
dst->m[0] = scale.x;
|
||||||
dst->m[5] = scale.y;
|
dst->m[5] = scale.y;
|
||||||
|
@ -261,7 +233,7 @@ void Matrix::createScale(float xScale, float yScale, float zScale, Matrix* dst)
|
||||||
{
|
{
|
||||||
GP_ASSERT(dst);
|
GP_ASSERT(dst);
|
||||||
|
|
||||||
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
|
memcpy(dst, &IDENTITY, MATRIX_SIZE);
|
||||||
|
|
||||||
dst->m[0] = xScale;
|
dst->m[0] = xScale;
|
||||||
dst->m[5] = yScale;
|
dst->m[5] = yScale;
|
||||||
|
@ -371,7 +343,7 @@ void Matrix::createRotationX(float angle, Matrix* dst)
|
||||||
{
|
{
|
||||||
GP_ASSERT(dst);
|
GP_ASSERT(dst);
|
||||||
|
|
||||||
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
|
memcpy(dst, &IDENTITY, MATRIX_SIZE);
|
||||||
|
|
||||||
float c = cos(angle);
|
float c = cos(angle);
|
||||||
float s = sin(angle);
|
float s = sin(angle);
|
||||||
|
@ -386,7 +358,7 @@ void Matrix::createRotationY(float angle, Matrix* dst)
|
||||||
{
|
{
|
||||||
GP_ASSERT(dst);
|
GP_ASSERT(dst);
|
||||||
|
|
||||||
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
|
memcpy(dst, &IDENTITY, MATRIX_SIZE);
|
||||||
|
|
||||||
float c = cos(angle);
|
float c = cos(angle);
|
||||||
float s = sin(angle);
|
float s = sin(angle);
|
||||||
|
@ -401,7 +373,7 @@ void Matrix::createRotationZ(float angle, Matrix* dst)
|
||||||
{
|
{
|
||||||
GP_ASSERT(dst);
|
GP_ASSERT(dst);
|
||||||
|
|
||||||
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
|
memcpy(dst, &IDENTITY, MATRIX_SIZE);
|
||||||
|
|
||||||
float c = cos(angle);
|
float c = cos(angle);
|
||||||
float s = sin(angle);
|
float s = sin(angle);
|
||||||
|
@ -416,7 +388,7 @@ void Matrix::createTranslation(const Vector3& translation, Matrix* dst)
|
||||||
{
|
{
|
||||||
GP_ASSERT(dst);
|
GP_ASSERT(dst);
|
||||||
|
|
||||||
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
|
memcpy(dst, &IDENTITY, MATRIX_SIZE);
|
||||||
|
|
||||||
dst->m[12] = translation.x;
|
dst->m[12] = translation.x;
|
||||||
dst->m[13] = translation.y;
|
dst->m[13] = translation.y;
|
||||||
|
@ -427,7 +399,7 @@ void Matrix::createTranslation(float xTranslation, float yTranslation, float zTr
|
||||||
{
|
{
|
||||||
GP_ASSERT(dst);
|
GP_ASSERT(dst);
|
||||||
|
|
||||||
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
|
memcpy(dst, &IDENTITY, MATRIX_SIZE);
|
||||||
|
|
||||||
dst->m[12] = xTranslation;
|
dst->m[12] = xTranslation;
|
||||||
dst->m[13] = yTranslation;
|
dst->m[13] = yTranslation;
|
||||||
|
@ -712,7 +684,7 @@ bool Matrix::inverse()
|
||||||
|
|
||||||
bool Matrix::isIdentity() const
|
bool Matrix::isIdentity() const
|
||||||
{
|
{
|
||||||
return (memcmp(m, MATRIX_IDENTITY, MATRIX_SIZE) == 0);
|
return (memcmp(m, &IDENTITY, MATRIX_SIZE) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix::multiply(float scalar)
|
void Matrix::multiply(float scalar)
|
||||||
|
@ -882,7 +854,7 @@ void Matrix::set(const Matrix& mat)
|
||||||
|
|
||||||
void Matrix::setIdentity()
|
void Matrix::setIdentity()
|
||||||
{
|
{
|
||||||
memcpy(m, MATRIX_IDENTITY, MATRIX_SIZE);
|
memcpy(m, &IDENTITY, MATRIX_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix::setZero()
|
void Matrix::setZero()
|
||||||
|
@ -978,4 +950,16 @@ Matrix Matrix::getTransposed() const
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Matrix Matrix::IDENTITY = Matrix(
|
||||||
|
1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
const Matrix Matrix::ZERO = Matrix(
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0 );
|
||||||
|
|
||||||
NS_CC_MATH_END
|
NS_CC_MATH_END
|
||||||
|
|
|
@ -138,25 +138,6 @@ public:
|
||||||
*/
|
*/
|
||||||
~Matrix();
|
~Matrix();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the identity matrix:
|
|
||||||
*
|
|
||||||
* 1 0 0 0
|
|
||||||
* 0 1 0 0
|
|
||||||
* 0 0 1 0
|
|
||||||
* 0 0 0 1
|
|
||||||
*
|
|
||||||
* @return The identity matrix.
|
|
||||||
*/
|
|
||||||
static const Matrix& identity();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the matrix with all zeros.
|
|
||||||
*
|
|
||||||
* @return The matrix with all zeros.
|
|
||||||
*/
|
|
||||||
static const Matrix& zero();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a view matrix based on the specified input parameters.
|
* Creates a view matrix based on the specified input parameters.
|
||||||
*
|
*
|
||||||
|
@ -941,6 +922,11 @@ public:
|
||||||
*/
|
*/
|
||||||
inline Matrix& operator*=(const Matrix& mat);
|
inline Matrix& operator*=(const Matrix& mat);
|
||||||
|
|
||||||
|
/** equals to a matrix full of zeros */
|
||||||
|
static const Matrix ZERO;
|
||||||
|
/** equals to the identity matrix */
|
||||||
|
static const Matrix IDENTITY;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static void createBillboardHelper(const Vector3& objectPosition, const Vector3& cameraPosition,
|
static void createBillboardHelper(const Vector3& objectPosition, const Vector3& cameraPosition,
|
||||||
|
|
Loading…
Reference in New Issue