mirror of https://github.com/axmolengine/axmol.git
Replace unsigned int with size_t to avoid implicit conversion (#17297)
This commit is contained in:
parent
88c3fcde67
commit
e2ad8946cb
|
@ -468,16 +468,16 @@ void Director::resetMatrixStack()
|
||||||
initMatrixStack();
|
initMatrixStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::initProjectionMatrixStack(unsigned int stackCount)
|
void Director::initProjectionMatrixStack(size_t stackCount)
|
||||||
{
|
{
|
||||||
_projectionMatrixStackList.clear();
|
_projectionMatrixStackList.clear();
|
||||||
std::stack<Mat4> projectionMatrixStack;
|
std::stack<Mat4> projectionMatrixStack;
|
||||||
projectionMatrixStack.push(Mat4::IDENTITY);
|
projectionMatrixStack.push(Mat4::IDENTITY);
|
||||||
for (unsigned int i = 0; i < stackCount; ++i)
|
for (size_t i = 0; i < stackCount; ++i)
|
||||||
_projectionMatrixStackList.push_back(projectionMatrixStack);
|
_projectionMatrixStackList.push_back(projectionMatrixStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Director::getProjectionMatrixStackSize()
|
size_t Director::getProjectionMatrixStackSize()
|
||||||
{
|
{
|
||||||
return _projectionMatrixStackList.size();
|
return _projectionMatrixStackList.size();
|
||||||
}
|
}
|
||||||
|
@ -502,7 +502,7 @@ void Director::popMatrix(MATRIX_STACK_TYPE type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::popProjectionMatrix(unsigned int index)
|
void Director::popProjectionMatrix(size_t index)
|
||||||
{
|
{
|
||||||
_projectionMatrixStackList[index].pop();
|
_projectionMatrixStackList[index].pop();
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ void Director::loadIdentityMatrix(MATRIX_STACK_TYPE type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::loadProjectionIdentityMatrix(unsigned int index)
|
void Director::loadProjectionIdentityMatrix(size_t index)
|
||||||
{
|
{
|
||||||
_projectionMatrixStackList[index].top() = Mat4::IDENTITY;
|
_projectionMatrixStackList[index].top() = Mat4::IDENTITY;
|
||||||
}
|
}
|
||||||
|
@ -552,7 +552,7 @@ void Director::loadMatrix(MATRIX_STACK_TYPE type, const Mat4& mat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::loadProjectionMatrix(const Mat4& mat, unsigned int index)
|
void Director::loadProjectionMatrix(const Mat4& mat, size_t index)
|
||||||
{
|
{
|
||||||
_projectionMatrixStackList[index].top() = mat;
|
_projectionMatrixStackList[index].top() = mat;
|
||||||
}
|
}
|
||||||
|
@ -577,7 +577,7 @@ void Director::multiplyMatrix(MATRIX_STACK_TYPE type, const Mat4& mat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::multiplyProjectionMatrix(const Mat4& mat, unsigned int index)
|
void Director::multiplyProjectionMatrix(const Mat4& mat, size_t index)
|
||||||
{
|
{
|
||||||
_projectionMatrixStackList[index].top() *= mat;
|
_projectionMatrixStackList[index].top() *= mat;
|
||||||
}
|
}
|
||||||
|
@ -602,7 +602,7 @@ void Director::pushMatrix(MATRIX_STACK_TYPE type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::pushProjectionMatrix(unsigned int index)
|
void Director::pushProjectionMatrix(size_t index)
|
||||||
{
|
{
|
||||||
_projectionMatrixStackList[index].push(_projectionMatrixStackList[index].top());
|
_projectionMatrixStackList[index].push(_projectionMatrixStackList[index].top());
|
||||||
}
|
}
|
||||||
|
@ -626,7 +626,7 @@ const Mat4& Director::getMatrix(MATRIX_STACK_TYPE type) const
|
||||||
return _modelViewMatrixStack.top();
|
return _modelViewMatrixStack.top();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Mat4& Director::getProjectionMatrix(unsigned int index) const
|
const Mat4& Director::getProjectionMatrix(size_t index) const
|
||||||
{
|
{
|
||||||
return _projectionMatrixStackList[index].top();
|
return _projectionMatrixStackList[index].top();
|
||||||
}
|
}
|
||||||
|
|
|
@ -462,7 +462,7 @@ public:
|
||||||
* @param index The index of projection matrix stack.
|
* @param index The index of projection matrix stack.
|
||||||
* @js NA
|
* @js NA
|
||||||
*/
|
*/
|
||||||
void pushProjectionMatrix(unsigned int index);
|
void pushProjectionMatrix(size_t index);
|
||||||
|
|
||||||
/** Pops the top matrix of the specified type of matrix stack.
|
/** Pops the top matrix of the specified type of matrix stack.
|
||||||
* @js NA
|
* @js NA
|
||||||
|
@ -473,7 +473,7 @@ public:
|
||||||
* @param index The index of projection matrix stack.
|
* @param index The index of projection matrix stack.
|
||||||
* @js NA
|
* @js NA
|
||||||
*/
|
*/
|
||||||
void popProjectionMatrix(unsigned int index);
|
void popProjectionMatrix(size_t index);
|
||||||
|
|
||||||
/** Adds an identity matrix to the top of specified type of matrix stack.
|
/** Adds an identity matrix to the top of specified type of matrix stack.
|
||||||
* @js NA
|
* @js NA
|
||||||
|
@ -484,7 +484,7 @@ public:
|
||||||
* @param index The index of projection matrix stack.
|
* @param index The index of projection matrix stack.
|
||||||
* @js NA
|
* @js NA
|
||||||
*/
|
*/
|
||||||
void loadProjectionIdentityMatrix(unsigned int index);
|
void loadProjectionIdentityMatrix(size_t index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a matrix to the top of specified type of matrix stack.
|
* Adds a matrix to the top of specified type of matrix stack.
|
||||||
|
@ -502,7 +502,7 @@ public:
|
||||||
* @param index The index of projection matrix stack.
|
* @param index The index of projection matrix stack.
|
||||||
* @js NA
|
* @js NA
|
||||||
*/
|
*/
|
||||||
void loadProjectionMatrix(const Mat4& mat, unsigned int index);
|
void loadProjectionMatrix(const Mat4& mat, size_t index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiplies a matrix to the top of specified type of matrix stack.
|
* Multiplies a matrix to the top of specified type of matrix stack.
|
||||||
|
@ -520,7 +520,7 @@ public:
|
||||||
* @param index The index of projection matrix stack.
|
* @param index The index of projection matrix stack.
|
||||||
* @js NA
|
* @js NA
|
||||||
*/
|
*/
|
||||||
void multiplyProjectionMatrix(const Mat4& mat, unsigned int index);
|
void multiplyProjectionMatrix(const Mat4& mat, size_t index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the top matrix of specified type of matrix stack.
|
* Gets the top matrix of specified type of matrix stack.
|
||||||
|
@ -533,7 +533,7 @@ public:
|
||||||
* @param index The index of projection matrix stack.
|
* @param index The index of projection matrix stack.
|
||||||
* @js NA
|
* @js NA
|
||||||
*/
|
*/
|
||||||
const Mat4& getProjectionMatrix(unsigned int index) const;
|
const Mat4& getProjectionMatrix(size_t index) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all types of matrix stack, and add identity matrix to these matrix stacks.
|
* Clear all types of matrix stack, and add identity matrix to these matrix stacks.
|
||||||
|
@ -546,13 +546,13 @@ public:
|
||||||
* @param stackCount The size of projection matrix stack.
|
* @param stackCount The size of projection matrix stack.
|
||||||
* @js NA
|
* @js NA
|
||||||
*/
|
*/
|
||||||
void initProjectionMatrixStack(unsigned int stackCount);
|
void initProjectionMatrixStack(size_t stackCount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the size of projection matrix stack.
|
* Get the size of projection matrix stack.
|
||||||
* @js NA
|
* @js NA
|
||||||
*/
|
*/
|
||||||
unsigned int getProjectionMatrixStackSize();
|
size_t getProjectionMatrixStackSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the cocos2d thread id.
|
* returns the cocos2d thread id.
|
||||||
|
|
|
@ -925,9 +925,8 @@ void GLProgram::setUniformsForBuiltins(const Mat4 &matrixMV)
|
||||||
if (_flags.usesMultiViewP)
|
if (_flags.usesMultiViewP)
|
||||||
{
|
{
|
||||||
Mat4 mats[4];
|
Mat4 mats[4];
|
||||||
unsigned int stackSize = _director->getProjectionMatrixStackSize() <= 4?
|
const auto stackSize = std::min<size_t>(_director->getProjectionMatrixStackSize(), 4);
|
||||||
_director->getProjectionMatrixStackSize(): 4;
|
for (size_t i = 0; i < stackSize; ++i) {
|
||||||
for (unsigned int i = 0; i < stackSize; ++i) {
|
|
||||||
mats[i] = _director->getProjectionMatrix(i);
|
mats[i] = _director->getProjectionMatrix(i);
|
||||||
}
|
}
|
||||||
setUniformLocationWithMatrix4fv(_builtInUniforms[UNIFORM_MULTIVIEW_P_MATRIX], mats[0].m, 4);
|
setUniformLocationWithMatrix4fv(_builtInUniforms[UNIFORM_MULTIVIEW_P_MATRIX], mats[0].m, 4);
|
||||||
|
@ -945,9 +944,8 @@ void GLProgram::setUniformsForBuiltins(const Mat4 &matrixMV)
|
||||||
if (_flags.usesMultiViewMVP)
|
if (_flags.usesMultiViewMVP)
|
||||||
{
|
{
|
||||||
Mat4 mats[4];
|
Mat4 mats[4];
|
||||||
unsigned int stackSize = _director->getProjectionMatrixStackSize() <= 4?
|
const auto stackSize = std::min<size_t>(_director->getProjectionMatrixStackSize(), 4);
|
||||||
_director->getProjectionMatrixStackSize(): 4;
|
for (size_t i = 0; i < stackSize; ++i) {
|
||||||
for (unsigned int i = 0; i < stackSize; ++i) {
|
|
||||||
mats[i] = _director->getProjectionMatrix(i) * matrixMV;
|
mats[i] = _director->getProjectionMatrix(i) * matrixMV;
|
||||||
}
|
}
|
||||||
setUniformLocationWithMatrix4fv(_builtInUniforms[UNIFORM_MULTIVIEW_MVP_MATRIX], mats[0].m, 4);
|
setUniformLocationWithMatrix4fv(_builtInUniforms[UNIFORM_MULTIVIEW_MVP_MATRIX], mats[0].m, 4);
|
||||||
|
|
Loading…
Reference in New Issue