Matrix::identity() -> IDENTITY

consistency with the rest of the  cocos2d API
This commit is contained in:
Ricardo Quesada 2014-05-13 10:26:25 -07:00
parent 41e57a6de3
commit 31dd70dba2
10 changed files with 44 additions and 76 deletions

View File

@ -98,7 +98,7 @@ void ActionCamera::updateTransform()
bool needsTranslation = !anchorPoint.equals(Vector2::ZERO);
Matrix mv = Matrix::identity();
Matrix mv = Matrix::IDENTITY;
if(needsTranslation) {
Matrix t;

View File

@ -135,7 +135,7 @@ Node::Node(void)
ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine();
_scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone;
#endif
_transform = _inverse = _additionalTransform = Matrix::identity();
_transform = _inverse = _additionalTransform = Matrix::IDENTITY;
}
Node::~Node()

View File

@ -1004,7 +1004,7 @@ void Sprite::setBatchNode(SpriteBatchNode *spriteBatchNode)
} else {
// using batch
_transformToBatch = Matrix::identity();
_transformToBatch = Matrix::IDENTITY;
setTextureAtlas(_batchNode->getTextureAtlas()); // weak ref
}
}

View File

@ -285,19 +285,17 @@ void Director::drawScene()
pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
Matrix identity = Matrix::identity();
// draw the scene
if (_runningScene)
{
_runningScene->visit(_renderer, identity, false);
_runningScene->visit(_renderer, Matrix::IDENTITY, false);
_eventDispatcher->dispatchEvent(_eventAfterVisit);
}
// draw the notifications node
if (_notificationNode)
{
_notificationNode->visit(_renderer, identity, false);
_notificationNode->visit(_renderer, Matrix::IDENTITY, false);
}
if (_displayStats)
@ -451,9 +449,9 @@ void Director::initMatrixStack()
_textureMatrixStack.pop();
}
_modelViewMatrixStack.push(Matrix::identity());
_projectionMatrixStack.push(Matrix::identity());
_textureMatrixStack.push(Matrix::identity());
_modelViewMatrixStack.push(Matrix::IDENTITY);
_projectionMatrixStack.push(Matrix::IDENTITY);
_textureMatrixStack.push(Matrix::IDENTITY);
}
void Director::resetMatrixStack()
@ -485,15 +483,15 @@ void Director::loadIdentityMatrix(MATRIX_STACK_TYPE 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)
{
_projectionMatrixStack.top() = Matrix::identity();
_projectionMatrixStack.top() = Matrix::IDENTITY;
}
else if(MATRIX_STACK_TYPE::MATRIX_STACK_TEXTURE == type)
{
_textureMatrixStack.top() = Matrix::identity();
_textureMatrixStack.top() = Matrix::IDENTITY;
}
else
{
@ -1082,7 +1080,7 @@ void Director::showStats()
prevVerts = currentVerts;
}
Matrix identity = Matrix::identity();
Matrix identity = Matrix::IDENTITY;
_drawnVerticesLabel->visit(_renderer, identity, false);
_drawnBatchesLabel->visit(_renderer, identity, false);

View File

@ -275,7 +275,7 @@ Matrix* kmMat4Assign(Matrix* pOut, const Matrix* pIn)
Matrix* kmMat4Identity(Matrix* pOut)
{
*pOut = Matrix::identity();
*pOut = Matrix::IDENTITY;
return pOut;
}

View File

@ -72,7 +72,7 @@ Bone::Bone()
_displayManager = nullptr;
_ignoreMovementBoneData = false;
// _worldTransform = AffineTransformMake(1, 0, 0, 1, 0, 0);
_worldTransform = Matrix::identity();
_worldTransform = Matrix::IDENTITY;
_boneTransformDirty = true;
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
_blendDirty = false;

View File

@ -86,7 +86,7 @@ Skin::Skin()
, _armature(nullptr)
, _displayName("")
{
_skinTransform = Matrix::identity();
_skinTransform = Matrix::IDENTITY;
}
bool Skin::initWithSpriteFrameName(const std::string& spriteFrameName)

View File

@ -120,7 +120,7 @@ void TransformHelp::nodeToMatrix(const BaseData &node, AffineTransform &matrix)
void TransformHelp::nodeToMatrix(const BaseData &node, Matrix &matrix)
{
matrix = Matrix::identity();
matrix = Matrix::IDENTITY;
if (node.skewX == -node.skewY)
{

View File

@ -25,17 +25,9 @@
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()
{
*this = Matrix::identity();
*this = IDENTITY;
}
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)
{
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);
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
memcpy(dst, &IDENTITY, MATRIX_SIZE);
dst->m[0] = scale.x;
dst->m[5] = scale.y;
@ -261,7 +233,7 @@ void Matrix::createScale(float xScale, float yScale, float zScale, Matrix* dst)
{
GP_ASSERT(dst);
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
memcpy(dst, &IDENTITY, MATRIX_SIZE);
dst->m[0] = xScale;
dst->m[5] = yScale;
@ -371,7 +343,7 @@ void Matrix::createRotationX(float angle, Matrix* dst)
{
GP_ASSERT(dst);
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
memcpy(dst, &IDENTITY, MATRIX_SIZE);
float c = cos(angle);
float s = sin(angle);
@ -386,7 +358,7 @@ void Matrix::createRotationY(float angle, Matrix* dst)
{
GP_ASSERT(dst);
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
memcpy(dst, &IDENTITY, MATRIX_SIZE);
float c = cos(angle);
float s = sin(angle);
@ -401,7 +373,7 @@ void Matrix::createRotationZ(float angle, Matrix* dst)
{
GP_ASSERT(dst);
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
memcpy(dst, &IDENTITY, MATRIX_SIZE);
float c = cos(angle);
float s = sin(angle);
@ -416,7 +388,7 @@ void Matrix::createTranslation(const Vector3& translation, Matrix* dst)
{
GP_ASSERT(dst);
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
memcpy(dst, &IDENTITY, MATRIX_SIZE);
dst->m[12] = translation.x;
dst->m[13] = translation.y;
@ -427,7 +399,7 @@ void Matrix::createTranslation(float xTranslation, float yTranslation, float zTr
{
GP_ASSERT(dst);
memcpy(dst, MATRIX_IDENTITY, MATRIX_SIZE);
memcpy(dst, &IDENTITY, MATRIX_SIZE);
dst->m[12] = xTranslation;
dst->m[13] = yTranslation;
@ -712,7 +684,7 @@ bool Matrix::inverse()
bool Matrix::isIdentity() const
{
return (memcmp(m, MATRIX_IDENTITY, MATRIX_SIZE) == 0);
return (memcmp(m, &IDENTITY, MATRIX_SIZE) == 0);
}
void Matrix::multiply(float scalar)
@ -882,7 +854,7 @@ void Matrix::set(const Matrix& mat)
void Matrix::setIdentity()
{
memcpy(m, MATRIX_IDENTITY, MATRIX_SIZE);
memcpy(m, &IDENTITY, MATRIX_SIZE);
}
void Matrix::setZero()
@ -978,4 +950,16 @@ Matrix Matrix::getTransposed() const
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

View File

@ -138,25 +138,6 @@ public:
*/
~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.
*
@ -940,7 +921,12 @@ public:
* @return This matrix, after the multiplication occurs.
*/
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:
static void createBillboardHelper(const Vector3& objectPosition, const Vector3& cameraPosition,