Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3-audioengine-freeze-fix

This commit is contained in:
WenhaiLin 2015-01-29 13:49:05 +08:00
commit 99056726ec
143 changed files with 3758 additions and 733 deletions

View File

@ -1071,6 +1071,12 @@ Developers:
AknEp
Fix FileUtils::fullPathForFilename return empty string if file not found
kompjoefriek
Fix compiling warnings
tmr111116
fix random int overflow
Retired Core Developers:
WenSheng Yang

View File

@ -1,15 +1,26 @@
cocos2d-x-3.4 Jan.23 2015
cocos2d-x-3.4 xxx
[FIX] Animate3D: `setSpeed` has not effect if `Animate3D` is used in Sequence
[FIX] C++: will crash if built with armeabi-v7a enabled on Android devices that with armeabi-v7a architecture but doesn't support NEON instructions
[FIX] C++: may crash if VAO is not supported
[FIX] EditBox: content is not clipped correctly on windows
[FIX] GLProgram: will cause crash on some devices that don't support more than 8 atrributes
[FIX] ImageView: rendered content size is wrong if `ignoreSize` is true and `Scale9` is not enabled
[FIX] HttpClient: not set response code when connecting failed on Android
[FIX] Label: alpha channel of text color of system font has not effect
[FIX] Label: use int for dimensions that will lose the precision
[FIX] Label: labels will become white block after resume from background on some Android devices, such as xiaomi3
[FIX] Label: improved parsing performance of bitmap font
[FIX] Lua-binding:studio-support: AnimationInfo is not binded
[FIX] New audio: not close file descriptor leads to that may causes game freeze if playing two many times(may be more than 1000) on Android
[FIX] Node: anchor point has not effect to rotation, it always rotate along (0, 0)
[FIX] Physics integration: Scale9Sprite can't run `Move` action and `Scale` action if used physical scene
[FIX] SpriteFrameCache: `addSpriteFramesWithFil`e may crash if plist file doesn't exist
[FIX] Sprite3D: material files (.mtl) are not loaded for any object when creating from an .obj file
[FIX] UI::ImageView: rendered content size is wrong if `ignoreSize` is true and `Scale9` is not enabled
[FIX] UI::Slider: when scale9 is enabled, the progress bar's rendering height is wrong
[FIX] UI:Scale9Sprite: some position information will be lost when toggling `Scale9` state
[FIX] UI::TextField: will get wrong event message if clicking `TextField` twice
[FIX] UI::TextField: result of `getContentSize` is wrong if it is invoked in insert or delete event callback
[FIX] UI::WebView: base URL can not work
cocos2d-x-3.4rc1 Jan.15 2015
[NEW] C++: added CC_USE_CULLING macro to control if enable auto culling or not

View File

@ -91,13 +91,6 @@ Camera::~Camera()
}
void Camera::setPosition3D(const Vec3& position)
{
Node::setPosition3D(position);
_transformUpdated = _transformDirty = _inverseDirty = true;
}
const Mat4& Camera::getProjectionMatrix() const
{
return _projection;

View File

@ -102,10 +102,6 @@ public:
/**get & set Camera flag*/
CameraFlag getCameraFlag() const { return (CameraFlag)_cameraFlag; }
void setCameraFlag(CameraFlag flag) { _cameraFlag = (unsigned short)flag; }
/**
* Sets the position (X, Y, and Z) in its parent's coordinate system
*/
virtual void setPosition3D(const Vec3& position) override;
/**
* Make Camera looks at target

View File

@ -144,11 +144,11 @@ DrawNode::~DrawNode()
if (Configuration::getInstance()->supportsShareableVAO())
{
GL::bindVAO(0);
glDeleteVertexArrays(1, &_vao);
glDeleteVertexArrays(1, &_vaoGLLine);
glDeleteVertexArrays(1, &_vaoGLPoint);
GL::bindVAO(0);
_vao = 0;
_vao = _vaoGLLine = _vaoGLPoint = 0;
}
}
@ -214,60 +214,66 @@ bool DrawNode::init()
{
glGenVertexArrays(1, &_vao);
GL::bindVAO(_vao);
}
glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW);
// vertex
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
// color
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
// texcood
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORD);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
if (Configuration::getInstance()->supportsShareableVAO())
{
glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW);
// vertex
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
// color
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
// texcood
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORD);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
glGenVertexArrays(1, &_vaoGLLine);
GL::bindVAO(_vaoGLLine);
}
glGenBuffers(1, &_vboGLLine);
glBindBuffer(GL_ARRAY_BUFFER, _vboGLLine);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLLine, _bufferGLLine, GL_STREAM_DRAW);
// vertex
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
// color
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
// texcood
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORD);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
if (Configuration::getInstance()->supportsShareableVAO())
{
glGenBuffers(1, &_vboGLLine);
glBindBuffer(GL_ARRAY_BUFFER, _vboGLLine);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLLine, _bufferGLLine, GL_STREAM_DRAW);
// vertex
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
// color
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
// texcood
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORD);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
glGenVertexArrays(1, &_vaoGLPoint);
GL::bindVAO(_vaoGLPoint);
}
glGenBuffers(1, &_vboGLPoint);
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW);
// vertex
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
// color
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
// Texture coord as pointsize
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORD);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
glBindBuffer(GL_ARRAY_BUFFER, 0);
if (Configuration::getInstance()->supportsShareableVAO())
{
glGenBuffers(1, &_vboGLPoint);
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW);
// vertex
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
// color
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
// Texture coord as pointsize
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORD);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
GL::bindVAO(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
else
{
glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW);
glGenBuffers(1, &_vboGLLine);
glBindBuffer(GL_ARRAY_BUFFER, _vboGLLine);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLLine, _bufferGLLine, GL_STREAM_DRAW);
glGenBuffers(1, &_vboGLPoint);
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW);
}
CHECK_GL_ERROR_DEBUG();
@ -348,6 +354,11 @@ void DrawNode::onDraw(const Mat4 &transform, uint32_t flags)
glDrawArrays(GL_TRIANGLES, 0, _bufferCount);
glBindBuffer(GL_ARRAY_BUFFER, 0);
if (Configuration::getInstance()->supportsShareableVAO())
{
GL::bindVAO(0);
}
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _bufferCount);
CHECK_GL_ERROR_DEBUG();
}
@ -381,6 +392,12 @@ void DrawNode::onDrawGLLine(const Mat4 &transform, uint32_t flags)
}
glLineWidth(2);
glDrawArrays(GL_LINES, 0, _bufferCountGLLine);
if (Configuration::getInstance()->supportsShareableVAO())
{
GL::bindVAO(0);
}
glBindBuffer(GL_ARRAY_BUFFER, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCountGLLine);
@ -415,6 +432,12 @@ void DrawNode::onDrawGLPoint(const Mat4 &transform, uint32_t flags)
}
glDrawArrays(GL_POINTS, 0, _bufferCountGLPoint);
if (Configuration::getInstance()->supportsShareableVAO())
{
GL::bindVAO(0);
}
glBindBuffer(GL_ARRAY_BUFFER, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCountGLPoint);

View File

@ -154,7 +154,7 @@ void TMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags)
_dirty = false;
}
if(_renderCommands.size() < _primitives.size())
if(_renderCommands.size() < static_cast<size_t>(_primitives.size()))
{
_renderCommands.resize(_primitives.size());
}

View File

@ -317,10 +317,10 @@ void Grid3D::beforeBlit()
{
if(_needDepthTestForBlit)
{
_oldDepthTestValue = glIsEnabled(GL_DEPTH_TEST);
_oldDepthTestValue = glIsEnabled(GL_DEPTH_TEST) != GL_FALSE;
GLboolean depthWriteMask;
glGetBooleanv(GL_DEPTH_WRITEMASK, &depthWriteMask);
_oldDepthWriteValue = depthWriteMask;
_oldDepthWriteValue = depthWriteMask != GL_FALSE;
CHECK_GL_ERROR_DEBUG();
glEnable(GL_DEPTH_TEST);
glDepthMask(true);

View File

@ -594,8 +594,9 @@ void LayerColor::onDraw(const Mat4& transform, uint32_t flags)
{
getGLProgram()->use();
getGLProgram()->setUniformsForBuiltins(transform);
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR );
//
// Attributes
//
@ -606,10 +607,11 @@ void LayerColor::onDraw(const Mat4& transform, uint32_t flags)
setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, 0);
#else
glBindBuffer(GL_ARRAY_BUFFER, 0);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _noMVPVertices);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, _squareColors);
#endif // EMSCRIPTEN
GL::blendFunc( _blendFunc.src, _blendFunc.dst );
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

View File

@ -126,6 +126,7 @@ Node::Node(void)
, _physicsScaleStartY(1.0f)
, _physicsRotation(0.0f)
, _physicsTransformDirty(true)
, _updateTransformFromPhysics(true)
#endif
, _displayedOpacity(255)
, _realOpacity(255)
@ -330,6 +331,11 @@ void Node::setRotation(float rotation)
_rotationZ_X = _rotationZ_Y = rotation;
_transformUpdated = _transformDirty = _inverseDirty = true;
#if CC_USE_PHYSICS
if (_physicsBody && _physicsBody->getWorld()) {
_physicsBody->getWorld()->_updateBodyTransform = true;
}
#endif
updateRotationQuat();
}
@ -466,6 +472,11 @@ void Node::setScale(float scale)
_scaleX = _scaleY = _scaleZ = scale;
_transformUpdated = _transformDirty = _inverseDirty = true;
#if CC_USE_PHYSICS
if (_physicsBody && _physicsBody->getWorld()) {
_physicsBody->getWorld()->_updateBodyTransform = true;
}
#endif
}
/// scaleX getter
@ -483,6 +494,11 @@ void Node::setScale(float scaleX,float scaleY)
_scaleX = scaleX;
_scaleY = scaleY;
_transformUpdated = _transformDirty = _inverseDirty = true;
#if CC_USE_PHYSICS
if (_physicsBody && _physicsBody->getWorld()) {
_physicsBody->getWorld()->_updateBodyTransform = true;
}
#endif
}
/// scaleX setter
@ -493,6 +509,11 @@ void Node::setScaleX(float scaleX)
_scaleX = scaleX;
_transformUpdated = _transformDirty = _inverseDirty = true;
#if CC_USE_PHYSICS
if (_physicsBody && _physicsBody->getWorld()) {
_physicsBody->getWorld()->_updateBodyTransform = true;
}
#endif
}
/// scaleY getter
@ -532,6 +553,11 @@ void Node::setScaleY(float scaleY)
_scaleY = scaleY;
_transformUpdated = _transformDirty = _inverseDirty = true;
#if CC_USE_PHYSICS
if (_physicsBody && _physicsBody->getWorld()) {
_physicsBody->getWorld()->_updateBodyTransform = true;
}
#endif
}
@ -563,6 +589,11 @@ void Node::setPosition(float x, float y)
_transformUpdated = _transformDirty = _inverseDirty = true;
_usingNormalizedPosition = false;
#if CC_USE_PHYSICS
if (_physicsBody && _physicsBody->getWorld()) {
_physicsBody->getWorld()->_updateBodyTransform = true;
}
#endif
}
void Node::setPosition3D(const Vec3& position)
@ -609,10 +640,6 @@ void Node::setPositionZ(float positionZ)
_transformUpdated = _transformDirty = _inverseDirty = true;
_positionZ = positionZ;
// FIXME: BUG
// Global Z Order should based on the modelViewTransform
setGlobalZOrder(positionZ);
}
/// position getter
@ -631,6 +658,11 @@ void Node::setNormalizedPosition(const Vec2& position)
_usingNormalizedPosition = true;
_normalizedPositionDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
#if CC_USE_PHYSICS
if (_physicsBody && _physicsBody->getWorld()) {
_physicsBody->getWorld()->_updateBodyTransform = true;
}
#endif
}
ssize_t Node::getChildrenCount() const
@ -1270,9 +1302,16 @@ uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFl
if(flags & FLAGS_DIRTY_MASK)
_modelViewTransform = this->transform(parentTransform);
#if CC_USE_PHYSICS
if (_updateTransformFromPhysics) {
_transformUpdated = false;
_contentSizeDirty = false;
}
#else
_transformUpdated = false;
_contentSizeDirty = false;
#endif
return flags;
}
@ -1280,7 +1319,7 @@ uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFl
bool Node::isVisitableByVisitingCamera() const
{
auto camera = Camera::getVisitingCamera();
bool visibleByCamera = camera ? (unsigned short)camera->getCameraFlag() & _cameraMask : true;
bool visibleByCamera = camera ? ((unsigned short)camera->getCameraFlag() & _cameraMask) != 0 : true;
return visibleByCamera;
}
@ -2021,7 +2060,7 @@ void Node::setPhysicsBody(PhysicsBody* body)
}
}
void Node::updatePhysicsBodyTransform(Scene* scene, const Mat4& parentTransform, uint32_t parentFlags, float parentScaleX, float parentScaleY)
void Node::updatePhysicsBodyTransform(const Mat4& parentTransform, uint32_t parentFlags, float parentScaleX, float parentScaleY)
{
_updateTransformFromPhysics = false;
auto flags = processParentFlags(parentTransform, parentFlags);
@ -2046,7 +2085,7 @@ void Node::updatePhysicsBodyTransform(Scene* scene, const Mat4& parentTransform,
for (auto node : _children)
{
node->updatePhysicsBodyTransform(scene, _modelViewTransform, flags, scaleX, scaleY);
node->updatePhysicsBodyTransform(_modelViewTransform, flags, scaleX, scaleY);
}
}

View File

@ -1122,7 +1122,7 @@ public:
*
* @return An Action pointer
*/
Action* runAction(Action* action);
virtual Action* runAction(Action* action);
/**
* Stops and removes all actions from the running action list .
@ -1543,7 +1543,7 @@ public:
void updateTransformFromPhysics(const Mat4& parentTransform, uint32_t parentFlags);
virtual void updatePhysicsBodyTransform(Scene* scene, const Mat4& parentTransform, uint32_t parentFlags, float parentScaleX, float parentScaleY);
virtual void updatePhysicsBodyTransform(const Mat4& parentTransform, uint32_t parentFlags, float parentScaleX, float parentScaleY);
#endif
// overrides

View File

@ -102,6 +102,9 @@ void BillBoard::visit(Renderer *renderer, const Mat4& parentTransform, uint32_t
{
return;
}
bool visibleByCamera = isVisitableByVisitingCamera();
if (!visibleByCamera && _children.empty())
return;
uint32_t flags = processParentFlags(parentTransform, parentFlags);
@ -119,7 +122,7 @@ void BillBoard::visit(Renderer *renderer, const Mat4& parentTransform, uint32_t
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
bool visibleByCamera = isVisitableByVisitingCamera();
int i = 0;
@ -158,7 +161,7 @@ bool BillBoard::calculateBillbaordTransform()
const Mat4& camWorldMat = camera->getNodeToWorldTransform();
//TODO: use math lib to calculate math lib Make it easier to read and maintain
if (memcmp(_camWorldMat.m, camWorldMat.m, sizeof(float) * 16) != 0 || _transformDirty || _modeDirty)
if (memcmp(_camWorldMat.m, camWorldMat.m, sizeof(float) * 16) != 0 || memcmp(_mvTransform.m, _modelViewTransform.m, sizeof(float) * 16) != 0 || _modeDirty || true)
{
//Rotate based on anchor point
Vec3 anchorPoint(_anchorPointInPoints.x , _anchorPointInPoints.y , 0.0f);
@ -190,13 +193,9 @@ bool BillBoard::calculateBillbaordTransform()
Quaternion rotationQuaternion;
this->getNodeToWorldTransform().getRotation(&rotationQuaternion);
// fetch the rotation angle of z
float rotationZ = atan2(2*(rotationQuaternion.w*rotationQuaternion.z + rotationQuaternion.x*rotationQuaternion.y),
(1 - 2* (rotationQuaternion.y*rotationQuaternion.y + rotationQuaternion.z *rotationQuaternion.z)));
Mat4 rotationMatrix;
rotationMatrix.setIdentity();
rotationMatrix.rotateZ(rotationZ);
Vec3 upAxis = Vec3(rotationMatrix.m[4],rotationMatrix.m[5],rotationMatrix.m[6]);
Vec3 x, y;
camWorldMat.transformVector(upAxis, &y);
@ -217,7 +216,7 @@ bool BillBoard::calculateBillbaordTransform()
billboardTransform.m[12] = localToWorld.m[12]; billboardTransform.m[13] = localToWorld.m[13]; billboardTransform.m[14] = localToWorld.m[14];
billboardTransform.translate(-anchorPoint);
_modelViewTransform = billboardTransform;
_mvTransform = _modelViewTransform = billboardTransform;
_camWorldMat = camWorldMat;

View File

@ -105,6 +105,7 @@ protected:
bool calculateBillbaordTransform();
Mat4 _camWorldMat;
Mat4 _mvTransform;
Mode _mode;
bool _modeDirty;

View File

@ -207,8 +207,14 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, MaterialDatas& materialdatas, NodeD
materialdatas.resetData();
nodedatas.resetData();
std::string mtlPath = "";
if (mtl_basepath)
mtlPath = mtl_basepath;
else
mtlPath = fullPath.substr(0, fullPath.find_last_of("\\/") + 1).c_str();
ObjLoader::shapes_t shapes;
auto ret = ObjLoader::LoadObj(shapes, fullPath.c_str(), mtl_basepath);
auto ret = ObjLoader::LoadObj(shapes, fullPath.c_str(), mtlPath.c_str());
if (ret.empty())
{
//fill data
@ -1791,7 +1797,7 @@ NodeData* Bundle3D::parseNodesRecursivelyBinary(bool& skeleton)
CCLOG("warning: Failed to read nodedata: uvMapping '%s'.", _path.c_str());
return nullptr;
}
for( int j = 0 ;j < uvMapping ; j++ )
for(int j = 0 ; j < uvMapping ; j++)
{
unsigned int textureIndexSize=0;
if (_binaryReader.read(&textureIndexSize, 4, 1) != 1)
@ -1799,7 +1805,7 @@ NodeData* Bundle3D::parseNodesRecursivelyBinary(bool& skeleton)
CCLOG("warning: Failed to read meshdata: attribCount '%s'.", _path.c_str());
return nullptr;
}
for(int k =0; k < textureIndexSize ; k++ )
for(unsigned int k = 0; k < textureIndexSize ; k++)
{
unsigned int index=0;
if (_binaryReader.read(&index, 4, 1) != 1)

View File

@ -161,7 +161,7 @@ static ssize_t updateVertex( std::map<vertex_index, ssize_t>& vertexCache, std::
return it->second;
}
assert(in_positions.size() > (3*i.v_idx+2));
assert(in_positions.size() > static_cast<size_t>(3*i.v_idx+2));
positions.push_back(in_positions[3*i.v_idx+0]);
positions.push_back(in_positions[3*i.v_idx+1]);

View File

@ -275,7 +275,7 @@ ssize_t Skeleton3D::getBoneCount() const
//get bone
Bone3D* Skeleton3D::getBoneByIndex(unsigned int index) const
{
if (index < _bones.size())
if (index < static_cast<unsigned int>(_bones.size()))
return _bones.at(index);
return nullptr;

View File

@ -741,6 +741,10 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
}
//support tint and fade
meshCommand.setDisplayColor(Vec4(color.r, color.g, color.b, color.a));
if (_forceDepthWrite)
{
meshCommand.setDepthWriteEnabled(true);
}
meshCommand.setTransparent(isTransparent);
renderer->addCommand(&meshCommand);
}
@ -801,6 +805,12 @@ const AABB& Sprite3D::getAABB() const
return _aabb;
}
Action* Sprite3D::runAction(Action *action)
{
setForceDepthWrite(true);
return Node::runAction(action);
}
Rect Sprite3D::getBoundingBox() const
{
AABB aabb = getAABB();

View File

@ -126,6 +126,22 @@ public:
*/
const AABB& getAABB() const;
/**
* Executes an action, and returns the action that is executed. For Sprite3D special logic are needed to take care of Fading.
*
* This node becomes the action's target. Refer to Action::getTarget()
* @warning Actions don't retain their target.
*
* @return An Action pointer
*/
virtual Action* runAction(Action* action) override;
/**
* Force to write to depth buffer, this is useful if you want to achieve effects like fading.
*/
void setForceDepthWrite(bool value) { _forceDepthWrite = value; }
bool isForceDepthWrite() const { return _forceDepthWrite;};
/**
* Returns 2d bounding-box
* Note: the bouding-box is just get from the AABB which as Z=0, so that is not very accurate.
@ -200,6 +216,7 @@ protected:
bool _aabbDirty;
unsigned int _lightMask;
bool _shaderUsingLight; // is current shader using light ?
bool _forceDepthWrite; // Always write to depth buffer
struct AsyncLoadParam
{

View File

@ -54,7 +54,7 @@ const float AudioEngine::TIME_UNKNOWN = -1.0f;
std::unordered_map<std::string,std::list<int>> AudioEngine::_audioPathIDMap;
//profileName,ProfileHelper
std::unordered_map<std::string, AudioEngine::ProfileHelper> AudioEngine::_audioPathProfileHelperMap;
int AudioEngine::_maxInstances = MAX_AUDIOINSTANCES;
unsigned int AudioEngine::_maxInstances = MAX_AUDIOINSTANCES;
AudioEngine::ProfileHelper* AudioEngine::_defaultProfileHelper = nullptr;
std::unordered_map<int, AudioEngine::AudioInfo> AudioEngine::_audioIDInfoMap;
AudioEngineImpl* AudioEngine::_audioEngineImpl = nullptr;

View File

@ -262,7 +262,7 @@ protected:
//profileName,ProfileHelper
static std::unordered_map<std::string, ProfileHelper> _audioPathProfileHelperMap;
static int _maxInstances;
static unsigned int _maxInstances;
static ProfileHelper* _defaultProfileHelper;

View File

@ -300,6 +300,12 @@ void Director::drawScene()
_runningScene->render(_renderer);
_eventDispatcher->dispatchEvent(_eventAfterVisit);
#if CC_USE_PHYSICS
if(physicsWorld)
{
physicsWorld->_updateBodyTransform = false;
}
#endif
}
// draw the notifications node

View File

@ -36,7 +36,7 @@
// The renderer[android:GLSurfaceView.Renderer WP8:Cocos2dRenderer] was recreated.
// This message is used for reloading resources before renderer is recreated on Android/WP8.
// This message is posted in cocos/platform/android/javaactivity.cpp and cocos\platform\wp8-xaml\cpp\Cocos2dRenderer.cpp.
#define EVENT_RENDERER_RECREATED "event_renderer_recreated"
#define EVENT_RENDERER_RECREATED "event_renderer_recreated"
// The application will come to background.
// This message is used for doing something before coming to background, such as save RenderTexture.

View File

@ -249,7 +249,7 @@ protected:
_allocated += _pageSize;
size_t aligned_size = AllocatorBase::nextPow2BlockSize(block_size);
uint8_t* block = (uint8_t*)p;
for (int i = 0; i < _pageSize; ++i, block += aligned_size)
for (unsigned int i = 0; i < _pageSize; ++i, block += aligned_size)
{
push_front(block);
}

View File

@ -44,7 +44,7 @@ public:
template<typename T>
static inline T random_int(T min, T max) {
std::uniform_int_distribution<> dist(min, max);
std::uniform_int_distribution<T> dist(min, max);
auto &mt = RandomHelper::getEngine();
return dist(mt);
}
@ -57,7 +57,7 @@ private:
*/
template<typename T>
inline T random(T min, T max) {
return RandomHelper::random_int(min, max);
return RandomHelper::random_int<T>(min, max);
}
template<>

View File

@ -181,7 +181,11 @@ ActionTimeline* ActionTimeline::clone() const
newAction->addTimeline(newTimeline);
}
}
for( auto info : _animationInfos)
{
newAction->addAnimationInfo(info.second);
}
return newAction;
}

View File

@ -33,6 +33,13 @@ NS_TIMELINE_BEGIN
struct AnimationInfo
{
AnimationInfo():startIndex(0),endIndex(0){}
AnimationInfo(const std::string& otherName, int otherStartIndex, int otherEndIndex)
:name(otherName),
startIndex(otherStartIndex),
endIndex(otherEndIndex)
{
}
std::string name;
int startIndex;
int endIndex;

View File

@ -55,6 +55,7 @@ static const char* Property_CColor = "CColor";
static const char* Property_FileData = "FileData";
static const char* Property_FrameEvent = "FrameEvent";
static const char* Property_Alpha = "Alpha";
static const char* Property_AnchorPoint = "AnchorPoint";
static const char* Property_ZOrder = "ZOrder";
static const char* Property_ActionValue = "ActionValue";
@ -533,6 +534,11 @@ Timeline* ActionTimelineCache::loadTimelineWithFlatBuffers(const flatbuffers::Ti
auto intFrame = frameFlatbuf->intFrame();
frame = loadAlphaFrameWithFlatBuffers(intFrame);
}
else if (property == Property_AnchorPoint)
{
auto scaleFrame = frameFlatbuf->scaleFrame();
frame = loadAnchorPointFrameWithFlatBuffers(scaleFrame);
}
else if (property == Property_ZOrder)
{
auto intFrame = frameFlatbuf->intFrame();
@ -560,14 +566,14 @@ Frame* ActionTimelineCache::loadVisibleFrameWithFlatBuffers(const flatbuffers::B
{
VisibleFrame* frame = VisibleFrame::create();
bool visible = flatbuffers->value();
bool visible = flatbuffers->value() != 0;
frame->setVisible(visible);
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
bool tween = flatbuffers->tween() != 0;
frame->setTween(tween);
return frame;
@ -584,7 +590,7 @@ Frame* ActionTimelineCache::loadPositionFrameWithFlatBuffers(const flatbuffers::
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
bool tween = flatbuffers->tween() != 0;
frame->setTween(tween);
return frame;
@ -602,7 +608,7 @@ Frame* ActionTimelineCache::loadScaleFrameWithFlatBuffers(const flatbuffers::Sca
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
bool tween = flatbuffers->tween() != 0;
frame->setTween(tween);
return frame;
@ -620,7 +626,7 @@ Frame* ActionTimelineCache::loadRotationSkewFrameWithFlatBuffers(const flatbuffe
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
bool tween = flatbuffers->tween() != 0;
frame->setTween(tween);
return frame;
@ -637,7 +643,7 @@ Frame* ActionTimelineCache::loadColorFrameWithFlatBuffers(const flatbuffers::Col
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
bool tween = flatbuffers->tween() != 0;
frame->setTween(tween);
return frame;
@ -694,7 +700,7 @@ Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::T
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
bool tween = flatbuffers->tween() != 0;
frame->setTween(tween);
return frame;
@ -714,7 +720,7 @@ Frame* ActionTimelineCache::loadEventFrameWithFlatBuffers(const flatbuffers::Eve
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
bool tween = flatbuffers->tween() != 0;
frame->setTween(tween);
return frame;
@ -731,12 +737,29 @@ Frame* ActionTimelineCache::loadAlphaFrameWithFlatBuffers(const flatbuffers::Int
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
bool tween = flatbuffers->tween() != 0;
frame->setTween(tween);
return frame;
}
Frame* ActionTimelineCache::loadAnchorPointFrameWithFlatBuffers(const flatbuffers::ScaleFrame *flatbuffers)
{
AnchorPointFrame* frame = AnchorPointFrame::create();
auto f_scale = flatbuffers->scale();
Vec2 scale(f_scale->scaleX(), f_scale->scaleY());
frame->setAnchorPoint(scale);
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween() != 0;
frame->setTween(tween);
return frame;
}
Frame* ActionTimelineCache::loadZOrderFrameWithFlatBuffers(const flatbuffers::IntFrame *flatbuffers)
{
ZOrderFrame* frame = ZOrderFrame::create();
@ -748,7 +771,7 @@ Frame* ActionTimelineCache::loadZOrderFrameWithFlatBuffers(const flatbuffers::In
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
bool tween = flatbuffers->tween() != 0;
frame->setTween(tween);
return frame;
@ -767,7 +790,7 @@ Frame* ActionTimelineCache::loadInnerActionFrameWithFlatBuffers(const flatbuffer
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
bool tween = flatbuffers->tween() != 0;
frame->setTween(tween);
frame->setInnerActionType(innerActionType);

View File

@ -112,6 +112,7 @@ protected:
Frame* loadTextureFrameWithFlatBuffers (const flatbuffers::TextureFrame* flatbuffers);
Frame* loadEventFrameWithFlatBuffers (const flatbuffers::EventFrame* flatbuffers);
Frame* loadAlphaFrameWithFlatBuffers (const flatbuffers::IntFrame* flatbuffers);
Frame* loadAnchorPointFrameWithFlatBuffers (const flatbuffers::ScaleFrame* flatbuffers);
Frame* loadZOrderFrameWithFlatBuffers (const flatbuffers::IntFrame* flatbuffers);
Frame* loadInnerActionFrameWithFlatBuffers (const flatbuffers::InnerActionFrame* flatbuffers);

View File

@ -481,6 +481,9 @@ InnerActionFrame::InnerActionFrame()
void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{
auto innerActiontimeline = static_cast<ActionTimeline*>(_node->getActionByTag(_node->getTag()));
if( nullptr == innerActiontimeline)
return;
if (InnerActionType::SingleFrame == _innerActionType)
{
innerActiontimeline->gotoFrameAndPause(_singleFrameIndex);
@ -525,7 +528,7 @@ void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
}
}
void InnerActionFrame::setStartFrameIndex(int frameIndex) throw()
void InnerActionFrame::setStartFrameIndex(int frameIndex)
{
if(_enterWithName)
{
@ -536,7 +539,7 @@ void InnerActionFrame::setStartFrameIndex(int frameIndex) throw()
}
void InnerActionFrame::setEndFrameIndex(int frameIndex) throw()
void InnerActionFrame::setEndFrameIndex(int frameIndex)
{
if(_enterWithName)
{
@ -546,7 +549,7 @@ void InnerActionFrame::setEndFrameIndex(int frameIndex) throw()
_endFrameIndex = frameIndex;
}
void InnerActionFrame::setAnimationName(const std::string& animationName) throw()
void InnerActionFrame::setAnimationName(const std::string& animationName)
{
if(!_enterWithName)
{

View File

@ -268,13 +268,13 @@ public:
inline void setEnterWithName(bool isEnterWithName) { _enterWithName = isEnterWithName;}
void setStartFrameIndex(int frameIndex) throw();
void setStartFrameIndex(int frameIndex);
inline int getStartFrameIndex() const { return _startFrameIndex; }
void setEndFrameIndex(int frameIndex) throw();
void setEndFrameIndex(int frameIndex);
inline int getEndFrameIndex() const { return _endFrameIndex; }
void setAnimationName(const std::string& animationNamed) throw();
void setAnimationName(const std::string& animationNamed);
inline void setSingleFrameIndex(int frameIndex) { _singleFrameIndex = frameIndex;}
inline int getSingleFrameIndex() const { return _singleFrameIndex;}

View File

@ -833,19 +833,22 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree)
auto projectNodeOptions = (ProjectNodeOptions*)options->data();
std::string filePath = projectNodeOptions->fileName()->c_str();
CCLOG("filePath = %s", filePath.c_str());
cocostudio::timeline::ActionTimeline* action = nullptr;
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
{
node = createNodeWithFlatBuffersFile(filePath);
reader->setPropsWithFlatBuffers(node, options->data());
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
if (action)
{
node->runAction(action);
action->gotoFrameAndPause(0);
}
action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
}
else
{
node = Node::create();
}
reader->setPropsWithFlatBuffers(node, options->data());
if (action)
{
node->runAction(action);
action->gotoFrameAndPause(0);
}
}
else if (classname == "SimpleAudio")
@ -1164,17 +1167,21 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
std::string filePath = projectNodeOptions->fileName()->c_str();
CCLOG("filePath = %s", filePath.c_str());
cocostudio::timeline::ActionTimeline* action = nullptr;
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
{
node = createNodeWithFlatBuffersForSimulator(filePath);
reader->setPropsWithFlatBuffers(node, options->data());
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator(filePath);
if (action)
{
node->runAction(action);
action->gotoFrameAndPause(0);
}
action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator(filePath);
}
else
{
node = Node::create();
}
reader->setPropsWithFlatBuffers(node, options->data());
if (action)
{
node->runAction(action);
action->gotoFrameAndPause(0);
}
}
else if (classname == "SimpleAudio")

View File

@ -76,6 +76,7 @@ static const char* Property_CColor = "CColor";
static const char* Property_FileData = "FileData";
static const char* Property_FrameEvent = "FrameEvent";
static const char* Property_Alpha = "Alpha";
static const char* Property_AnchorPoint = "AnchorPoint";
static const char* Property_ZOrder = "ZOrder";
static const char* Property_ActionValue = "ActionValue";
@ -703,6 +704,13 @@ Offset<TimeLine> FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement
0, // EventFrame
intFrame);
}
else if (property == Property_AnchorPoint)
{
auto scaleFrame = createScaleFrame(frameElement);
frame = CreateFrame(*_builder,
0, // PointFrame
scaleFrame);
}
else if (property == Property_ZOrder)
{
auto intFrame = createIntFrame(frameElement);

View File

@ -544,7 +544,7 @@ namespace cocostudio
Button* button = static_cast<Button*>(node);
auto options = (ButtonOptions*)buttonOptions;
bool scale9Enabled = options->scale9Enabled();
bool scale9Enabled = options->scale9Enabled() != 0;
button->setScale9Enabled(scale9Enabled);
bool normalFileExist = false;
@ -777,7 +777,7 @@ namespace cocostudio
}
}
bool displaystate = options->displaystate();
bool displaystate = options->displaystate() != 0;
button->setBright(displaystate);
button->setEnabled(displaystate);

View File

@ -753,10 +753,10 @@ namespace cocostudio
checkBox->addChild(label);
}
bool selectedstate = options->selectedState();
bool selectedstate = options->selectedState() != 0;
checkBox->setSelected(selectedstate);
bool displaystate = options->displaystate();
bool displaystate = options->displaystate() != 0;
checkBox->setBright(displaystate);
checkBox->setEnabled(displaystate);

View File

@ -181,11 +181,10 @@ namespace cocostudio
break;
}
bool loop = options->loop();
bool loop = options->loop() != 0;
audio->setLoop(loop);
audio->setName(options->name()->c_str());
audio->setLoop(options->loop());
return component;
}

View File

@ -24,6 +24,8 @@
#include "GameMapReader.h"
#include "2d/CCTMXXMLParser.h"
#include "cocostudio/CSParseBinary_generated.h"
#include "cocostudio/WidgetReader/NodeReader/NodeReader.h"
@ -159,6 +161,77 @@ namespace cocostudio
}
if (fileExist)
{
/* Whether tileset is valid. */
auto mapInfo = TMXMapInfo::create(path);
auto& layers = mapInfo->getLayers();
bool valid = false;
std::string layerName = "";
for (const auto &layerInfo : layers)
{
valid = false;
if (layerInfo->_visible)
{
Size size = layerInfo->_layerSize;
auto& tilesets = mapInfo->getTilesets();
if (tilesets.size()>0)
{
TMXTilesetInfo* tileset = nullptr;
for (auto iter = tilesets.crbegin(); iter != tilesets.crend(); ++iter)
{
tileset = *iter;
if (tileset)
{
for( int y=0; y < size.height; y++ )
{
for( int x=0; x < size.width; x++ )
{
int pos = static_cast<int>(x + size.width * y);
int gid = layerInfo->_tiles[ pos ];
if( gid != 0 )
{
if( (gid & kTMXFlippedMask) >= tileset->_firstGid )
{
valid = true;
break;
}
}
}
if (valid)
{
break;
}
}
}
}
}
if (!valid)
{
layerName = layerInfo->_name;
break;
}
}
else
{
valid = true;
}
}
if (!valid)
{
Node* node = Node::create();
setPropsWithFlatBuffers(node, (Table*)gameMapOptions);
auto label = Label::create();
label->setString(__String::createWithFormat("Some error of gid are in TMX Layer '%s'", layerName.c_str())->getCString());
node->setScale(1.0f);
node->addChild(label);
return node;
}
/**/
tmx = TMXTiledMap::create(path);
if (tmx)
{

View File

@ -355,7 +355,7 @@ namespace cocostudio
imageView->addChild(label);
}
bool scale9Enabled = options->scale9Enabled();
bool scale9Enabled = options->scale9Enabled() != 0;
imageView->setScale9Enabled(scale9Enabled);
auto widgetReader = WidgetReader::getInstance();

View File

@ -570,10 +570,10 @@ namespace cocostudio
Layout* panel = static_cast<Layout*>(node);
auto options = (PanelOptions*)layoutOptions;
bool clipEnabled = options->clipEnabled();
bool clipEnabled = options->clipEnabled() != 0;
panel->setClippingEnabled(clipEnabled);
bool backGroundScale9Enabled = options->backGroundScale9Enabled();
bool backGroundScale9Enabled = options->backGroundScale9Enabled() != 0;
panel->setBackGroundImageScale9Enabled(backGroundScale9Enabled);

View File

@ -398,10 +398,10 @@ namespace cocostudio
ListView* listView = static_cast<ListView*>(node);
auto options = (ListViewOptions*)listViewOptions;
bool clipEnabled = options->clipEnabled();
bool clipEnabled = options->clipEnabled() != 0;
listView->setClippingEnabled(clipEnabled);
bool backGroundScale9Enabled = options->backGroundScale9Enabled();
bool backGroundScale9Enabled = options->backGroundScale9Enabled() != 0;
listView->setBackGroundImageScale9Enabled(backGroundScale9Enabled);
@ -506,7 +506,7 @@ namespace cocostudio
listView->setInnerContainerSize(innerSize);
// int direction = options->direction();
// listView->setDirection((ScrollView::Direction)direction);
bool bounceEnabled = options->bounceEnabled();
bool bounceEnabled = options->bounceEnabled() != 0;
listView->setBounceEnabled(bounceEnabled);
// int gravityValue = options->gravity();

View File

@ -472,7 +472,7 @@ namespace cocostudio
int zorder = options->zOrder();
int tag = options->tag();
int actionTag = options->actionTag();
bool visible = options->visible();
bool visible = options->visible() != 0;
float w = options->size()->width();
float h = options->size()->height();
int alpha = options->alpha();
@ -521,16 +521,16 @@ namespace cocostudio
auto layoutComponent = ui::LayoutComponent::bindLayoutComponent(node);
bool positionXPercentEnabled = layoutComponentTable->positionXPercentEnabled();
bool positionYPercentEnabled = layoutComponentTable->positionYPercentEnabled();
bool positionXPercentEnabled = layoutComponentTable->positionXPercentEnabled() != 0;
bool positionYPercentEnabled = layoutComponentTable->positionYPercentEnabled() != 0;
float positionXPercent = layoutComponentTable->positionXPercent();
float positionYPercent = layoutComponentTable->positionYPercent();
bool sizeXPercentEnable = layoutComponentTable->sizeXPercentEnable();
bool sizeYPercentEnable = layoutComponentTable->sizeYPercentEnable();
bool sizeXPercentEnable = layoutComponentTable->sizeXPercentEnable() != 0;
bool sizeYPercentEnable = layoutComponentTable->sizeYPercentEnable() != 0;
float sizeXPercent = layoutComponentTable->sizeXPercent();
float sizeYPercent = layoutComponentTable->sizeYPercent();
bool stretchHorizontalEnabled = layoutComponentTable->stretchHorizontalEnabled();
bool stretchVerticalEnabled = layoutComponentTable->stretchVerticalEnabled();
bool stretchHorizontalEnabled = layoutComponentTable->stretchHorizontalEnabled() != 0;
bool stretchVerticalEnabled = layoutComponentTable->stretchVerticalEnabled() != 0;
std::string horizontalEdge = layoutComponentTable->horizontalEdge()->c_str();
std::string verticalEdge = layoutComponentTable->verticalEdge()->c_str();
float leftMargin = layoutComponentTable->leftMargin();

View File

@ -311,10 +311,10 @@ namespace cocostudio
PageView* pageView = static_cast<PageView*>(node);
auto options = (PageViewOptions*)pageViewOptions;
bool clipEnabled = options->clipEnabled();
bool clipEnabled = options->clipEnabled() != 0;
pageView->setClippingEnabled(clipEnabled);
bool backGroundScale9Enabled = options->backGroundScale9Enabled();
bool backGroundScale9Enabled = options->backGroundScale9Enabled() != 0;
pageView->setBackGroundImageScale9Enabled(backGroundScale9Enabled);

View File

@ -397,10 +397,10 @@ namespace cocostudio
ScrollView* scrollView = static_cast<ScrollView*>(node);
auto options = (ScrollViewOptions*)scrollViewOptions;
bool clipEnabled = options->clipEnabled();
bool clipEnabled = options->clipEnabled() != 0;
scrollView->setClippingEnabled(clipEnabled);
bool backGroundScale9Enabled = options->backGroundScale9Enabled();
bool backGroundScale9Enabled = options->backGroundScale9Enabled() != 0;
scrollView->setBackGroundImageScale9Enabled(backGroundScale9Enabled);
@ -505,7 +505,7 @@ namespace cocostudio
scrollView->setInnerContainerSize(innerSize);
int direction = options->direction();
scrollView->setDirection((ScrollView::Direction)direction);
bool bounceEnabled = options->bounceEnabled();
bool bounceEnabled = options->bounceEnabled() != 0;
scrollView->setBounceEnabled(bounceEnabled);

View File

@ -787,7 +787,7 @@ namespace cocostudio
slider->addChild(label);
}
bool displaystate = options->displaystate();
bool displaystate = options->displaystate() != 0;
slider->setBright(displaystate);
slider->setEnabled(displaystate);

View File

@ -224,8 +224,8 @@ namespace cocostudio
sprite->setColor(Color3B(red, green, blue));
}
bool flipX = nodeOptions->flipX();
bool flipY = nodeOptions->flipY();
bool flipX = nodeOptions->flipX() != 0;
bool flipY = nodeOptions->flipY() != 0;
if(flipX != false)
sprite->setFlippedX(flipX);

View File

@ -267,6 +267,8 @@ namespace cocostudio
auto widgetReader = WidgetReader::getInstance();
widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
labelAtlas->ignoreContentAdaptWithSize(true);
}
Node* TextAtlasReader::createNodeWithFlatBuffers(const flatbuffers::Table *textAtlasOptions)

View File

@ -241,6 +241,8 @@ namespace cocostudio
auto widgetReader = WidgetReader::getInstance();
widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
labelBMFont->ignoreContentAdaptWithSize(true);
}
Node* TextBMFontReader::createNodeWithFlatBuffers(const flatbuffers::Table *textBMFontOptions)

View File

@ -291,7 +291,7 @@ namespace cocostudio
std::string fontName = options->fontName()->c_str();
textField->setFontName(fontName);
bool maxLengthEnabled = options->maxLengthEnabled();
bool maxLengthEnabled = options->maxLengthEnabled() != 0;
textField->setMaxLengthEnabled(maxLengthEnabled);
if (maxLengthEnabled)
@ -299,7 +299,7 @@ namespace cocostudio
int maxLength = options->maxLength();
textField->setMaxLength(maxLength);
}
bool passwordEnabled = options->passwordEnabled();
bool passwordEnabled = options->passwordEnabled() != 0;
textField->setPasswordEnabled(passwordEnabled);
if (passwordEnabled)
{

View File

@ -292,7 +292,7 @@ namespace cocostudio
Text* label = static_cast<Text*>(node);
auto options = (TextOptions*)textOptions;
bool touchScaleEnabled = options->touchScaleEnable();
bool touchScaleEnabled = options->touchScaleEnable() != 0;
label->setTouchScaleChangeEnabled(touchScaleEnabled);
std::string text = options->text()->c_str();
@ -348,7 +348,7 @@ namespace cocostudio
label->setUnifySizeEnabled(false);
bool IsCustomSize = options->isCustomSize();
bool IsCustomSize = options->isCustomSize() != 0;
label->ignoreContentAdaptWithSize(!IsCustomSize);
auto widgetOptions = options->widgetOptions();

View File

@ -772,7 +772,7 @@ namespace cocostudio
widget->setAnchorPoint(Vec2::ZERO);
widget->setUnifySizeEnabled(true);
bool ignoreSize = options->ignoreSize();
bool ignoreSize = options->ignoreSize() != 0;
widget->ignoreContentAdaptWithSize(ignoreSize);
widget->setUnifySizeEnabled(false);
@ -788,7 +788,7 @@ namespace cocostudio
widget->setActionTag(actionTag);
widget->setUserObject(timeline::ActionTimelineData::create(actionTag));
bool touchEnabled = options->touchEnabled();
bool touchEnabled = options->touchEnabled() != 0;
widget->setTouchEnabled(touchEnabled);
std::string name = options->name()->c_str();
@ -807,7 +807,7 @@ namespace cocostudio
float rotationSkewY = options->rotationSkew()->rotationSkewY();
widget->setRotationSkewY(rotationSkewY);
bool visible = options->visible();
bool visible = options->visible() != 0;
widget->setVisible(visible);
int zOrder = options->zOrder();
@ -824,9 +824,9 @@ namespace cocostudio
Vec2 anchorPoint(f_anchorPoint->scaleX(), f_anchorPoint->scaleY());
widget->setAnchorPoint(anchorPoint);
bool flippedX = options->flipX();
bool flippedX = options->flipX() != 0;
widget->setFlippedX(flippedX);
bool flippedY = options->flipY();
bool flippedY = options->flipY() != 0;
widget->setFlippedY(flippedY);
std::string callbackType = options->callBackType()->c_str();
@ -844,16 +844,16 @@ namespace cocostudio
auto layoutComponent = ui::LayoutComponent::bindLayoutComponent(node);
bool positionXPercentEnabled = layoutComponentTable->positionXPercentEnabled();
bool positionYPercentEnabled = layoutComponentTable->positionYPercentEnabled();
bool positionXPercentEnabled = layoutComponentTable->positionXPercentEnabled() != 0;
bool positionYPercentEnabled = layoutComponentTable->positionYPercentEnabled() != 0;
float positionXPercent = layoutComponentTable->positionXPercent();
float positionYPercent = layoutComponentTable->positionYPercent();
bool sizeXPercentEnable = layoutComponentTable->sizeXPercentEnable();
bool sizeYPercentEnable = layoutComponentTable->sizeYPercentEnable();
bool sizeXPercentEnable = layoutComponentTable->sizeXPercentEnable() != 0;
bool sizeYPercentEnable = layoutComponentTable->sizeYPercentEnable() != 0;
float sizeXPercent = layoutComponentTable->sizeXPercent();
float sizeYPercent = layoutComponentTable->sizeYPercent();
bool stretchHorizontalEnabled = layoutComponentTable->stretchHorizontalEnabled();
bool stretchVerticalEnabled = layoutComponentTable->stretchVerticalEnabled();
bool stretchHorizontalEnabled = layoutComponentTable->stretchHorizontalEnabled() != 0;
bool stretchVerticalEnabled = layoutComponentTable->stretchVerticalEnabled() != 0;
std::string horizontalEdge = layoutComponentTable->horizontalEdge()->c_str();
std::string verticalEdge = layoutComponentTable->verticalEdge()->c_str();
float leftMargin = layoutComponentTable->leftMargin();

View File

@ -687,6 +687,7 @@ static void processResponse(HttpResponse* response, std::string& responseMessage
{
response->setSucceed(false);
response->setErrorBuffer("connect failed");
response->setResponseCode(responseCode);
return;
}

View File

@ -334,7 +334,7 @@ void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Vec2& point1,
{
if (!_delayAddBodies.empty() || !_delayRemoveBodies.empty())
{
_scene->updatePhysicsBodyTransform(_scene, _scene->getNodeToParentTransform(), 0, 1.0f, 1.0f);
_scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f);
updateBodies();
}
RayCastCallbackInfo info = { this, func, point1, point2, data };
@ -358,7 +358,7 @@ void PhysicsWorld::queryRect(PhysicsQueryRectCallbackFunc func, const Rect& rect
{
if (!_delayAddBodies.empty() || !_delayRemoveBodies.empty())
{
_scene->updatePhysicsBodyTransform(_scene, _scene->getNodeToParentTransform(), 0, 1.0f, 1.0f);
_scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f);
updateBodies();
}
RectQueryCallbackInfo info = {this, func, data};
@ -381,7 +381,7 @@ void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Vec2& po
{
if (!_delayAddBodies.empty() || !_delayRemoveBodies.empty())
{
_scene->updatePhysicsBodyTransform(_scene, _scene->getNodeToParentTransform(), 0, 1.0f, 1.0f);
_scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f);
updateBodies();
}
PointQueryCallbackInfo info = {this, func, data};
@ -823,9 +823,13 @@ void PhysicsWorld::update(float delta, bool userCall/* = false*/)
return;
}
_scene->updatePhysicsBodyTransform(_scene, _scene->getNodeToParentTransform(), 0, 1.0f, 1.0f);
if (!_delayAddBodies.empty() || !_delayRemoveBodies.empty())
if(_updateBodyTransform || !_delayAddBodies.empty())
{
_scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f);
updateBodies();
_updateBodyTransform = false;
}
else if (!_delayRemoveBodies.empty())
{
updateBodies();
}
@ -880,6 +884,7 @@ PhysicsWorld::PhysicsWorld()
, _autoStep(true)
, _debugDraw(nullptr)
, _debugDrawMask(DEBUGDRAW_NONE)
, _updateBodyTransform(false)
{
}

View File

@ -204,6 +204,7 @@ protected:
int _substeps;
cpSpace* _cpSpace;
bool _updateBodyTransform;
Vector<PhysicsBody*> _bodies;
std::list<PhysicsJoint*> _joints;
Scene* _scene;

View File

@ -1103,7 +1103,7 @@ bool FileUtils::createDirectory(const std::string& path)
if ((GetFileAttributesA(path.c_str())) == INVALID_FILE_ATTRIBUTES)
{
subpath = "";
for (int i = 0; i < dirs.size(); ++i)
for (unsigned int i = 0; i < dirs.size(); ++i)
{
subpath += dirs[i];
if (!isDirectoryExist(subpath))

View File

@ -54,7 +54,6 @@ public class Cocos2dxWebViewHelper {
onJsCallback(index, message);
}
@SuppressWarnings("unused")
public static int createWebView() {
final int index = viewTag;
sCocos2dxActivity.runOnUiThread(new Runnable() {
@ -72,7 +71,6 @@ public class Cocos2dxWebViewHelper {
return viewTag++;
}
@SuppressWarnings("unused")
public static void removeWebView(final int index) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
@ -86,7 +84,6 @@ public class Cocos2dxWebViewHelper {
});
}
@SuppressWarnings("unused")
public static void setVisible(final int index, final boolean visible) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
@ -99,7 +96,6 @@ public class Cocos2dxWebViewHelper {
});
}
@SuppressWarnings("unused")
public static void setWebViewRect(final int index, final int left, final int top, final int maxWidth, final int maxHeight) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
@ -112,7 +108,6 @@ public class Cocos2dxWebViewHelper {
});
}
@SuppressWarnings("unused")
public static void setJavascriptInterfaceScheme(final int index, final String scheme) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
@ -125,33 +120,30 @@ public class Cocos2dxWebViewHelper {
});
}
@SuppressWarnings("unused")
public static void loadData(final int index, final String data, final String mimeType, final String encoding, final String baseURL) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Cocos2dxWebView webView = webViews.get(index);
if (webView != null) {
webView.loadDataWithBaseURL(baseURL, data, mimeType, encoding, null);
webView.loadDataWithBaseURL(baseURL, data, mimeType, encoding, null);
}
}
});
}
@SuppressWarnings("unused")
public static void loadHTMLString(final int index, final String htmlString, final String mimeType, final String encoding) {
public static void loadHTMLString(final int index, final String data, final String baseUrl) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Cocos2dxWebView webView = webViews.get(index);
if (webView != null) {
webView.loadData(htmlString, mimeType, encoding);
webView.loadDataWithBaseURL(baseUrl, data, null, null, null);
}
}
});
}
@SuppressWarnings("unused")
public static void loadUrl(final int index, final String url) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
@ -164,7 +156,6 @@ public class Cocos2dxWebViewHelper {
});
}
@SuppressWarnings("unused")
public static void loadFile(final int index, final String filePath) {
if (CocosPlayClient.isEnabled() && !CocosPlayClient.isDemo()) {
CocosPlayClient.updateAssets(filePath);
@ -212,7 +203,6 @@ public class Cocos2dxWebViewHelper {
return task.get();
}
@SuppressWarnings("unused")
public static boolean canGoBack(final int index) {
Callable<Boolean> callable = new Callable<Boolean>() {
@Override
@ -230,7 +220,6 @@ public class Cocos2dxWebViewHelper {
}
}
@SuppressWarnings("unused")
public static boolean canGoForward(final int index) {
Callable<Boolean> callable = new Callable<Boolean>() {
@Override
@ -248,7 +237,6 @@ public class Cocos2dxWebViewHelper {
}
}
@SuppressWarnings("unused")
public static void goBack(final int index) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
@ -261,7 +249,6 @@ public class Cocos2dxWebViewHelper {
});
}
@SuppressWarnings("unused")
public static void goForward(final int index) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
@ -274,7 +261,6 @@ public class Cocos2dxWebViewHelper {
});
}
@SuppressWarnings("unused")
public static void evaluateJS(final int index, final String js) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
@ -287,7 +273,6 @@ public class Cocos2dxWebViewHelper {
});
}
@SuppressWarnings("unused")
public static void setScalesPageToFit(final int index, final boolean scalesPageToFit) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override

View File

@ -163,7 +163,7 @@ GLProgram::~GLProgram()
for (auto e : _hashForUniforms)
{
free(e.second);
free(e.second.first);
}
_hashForUniforms.clear();
}
@ -666,17 +666,24 @@ bool GLProgram::updateUniformLocation(GLint location, const GLvoid* data, unsign
{
GLvoid* value = malloc(bytes);
memcpy(value, data, bytes );
_hashForUniforms.insert(std::make_pair(location, value));
_hashForUniforms.insert(std::make_pair(location, std::make_pair(value, bytes)));
}
else
{
if (memcmp(element->second, data, bytes) == 0)
if (memcmp(element->second.first, data, bytes) == 0)
{
updated = false;
}
else
{
memcpy(element->second, data, bytes);
if (element->second.second < bytes)
{
GLvoid* value = realloc(element->second.first, bytes);
memcpy(value, data, bytes );
_hashForUniforms[location] = std::make_pair(value, bytes);
}
else
memcpy(element->second.first, data, bytes);
}
}
@ -937,7 +944,7 @@ void GLProgram::reset()
for (auto e: _hashForUniforms)
{
free(e.second);
free(e.second.first);
}
_hashForUniforms.clear();

View File

@ -361,7 +361,7 @@ protected:
std::unordered_map<std::string, Uniform> _userUniforms;
std::unordered_map<std::string, VertexAttrib> _vertexAttribs;
std::unordered_map<GLint, GLvoid*> _hashForUniforms;
std::unordered_map<GLint, std::pair<GLvoid*, unsigned int>> _hashForUniforms;
//cached director pointer for calling
Director* _director;
};

View File

@ -42,12 +42,6 @@
NS_CC_BEGIN
//render state
static bool s_cullFaceEnabled = false;
static GLenum s_cullFace = 0;
static bool s_depthTestEnabled = false;
static bool s_depthWriteEnabled = false;
static const char *s_dirLightUniformColorName = "u_DirLightSourceColor";
static std::vector<Vec3> s_dirLightUniformColorValues;
static const char *s_dirLightUniformDirName = "u_DirLightSourceDirection";
@ -159,6 +153,7 @@ void MeshCommand::setDepthTestEnabled(bool enable)
void MeshCommand::setDepthWriteEnabled(bool enable)
{
_forceDepthWrite = enable;
_depthWriteEnabled = enable;
}
@ -172,7 +167,11 @@ void MeshCommand::setTransparent(bool value)
_isTransparent = value;
//Skip batching for transparent mesh
_skipBatching = value;
setDepthWriteEnabled(!_isTransparent);
if (!_forceDepthWrite)
{
_depthWriteEnabled = true;
}
}
MeshCommand::~MeshCommand()
@ -185,46 +184,48 @@ MeshCommand::~MeshCommand()
void MeshCommand::applyRenderState()
{
if (_cullFaceEnabled && !s_cullFaceEnabled)
_renderStateCullFace = glIsEnabled(GL_CULL_FACE);
_renderStateDepthTest = glIsEnabled(GL_DEPTH_TEST);
glGetBooleanv(GL_DEPTH_WRITEMASK, &_renderStateDepthWrite);
if (_cullFaceEnabled && !_renderStateCullFace)
{
glEnable(GL_CULL_FACE);
s_cullFaceEnabled = true;
}
if (s_cullFace != _cullFace)
{
glCullFace(_cullFace);
s_cullFace = _cullFace;
}
if (_depthTestEnabled && !s_depthTestEnabled)
glCullFace(_cullFace);
if (_depthTestEnabled && !_renderStateDepthTest)
{
glEnable(GL_DEPTH_TEST);
s_depthTestEnabled = true;
}
if (_depthWriteEnabled && !s_depthWriteEnabled)
if (_depthWriteEnabled && !_renderStateDepthWrite)
{
glDepthMask(GL_TRUE);
s_depthWriteEnabled = true;
}
}
void MeshCommand::restoreRenderState()
{
if (s_cullFaceEnabled)
if (_renderStateCullFace)
{
glEnable(GL_CULL_FACE);
}
else
{
glDisable(GL_CULL_FACE);
s_cullFaceEnabled = false;
}
if (s_depthTestEnabled)
if (_renderStateDepthTest)
{
glEnable(GL_DEPTH_TEST);
}
else
{
glDisable(GL_DEPTH_TEST);
s_depthTestEnabled = false;
}
if (s_depthWriteEnabled)
{
glDepthMask(GL_FALSE);
s_depthWriteEnabled = false;
}
s_cullFace = 0;
glDepthMask(_renderStateDepthTest);
}
void MeshCommand::genMaterialID(GLuint texID, void* glProgramState, GLuint vertexBuffer, GLuint indexBuffer, const BlendFunc& blend)

View File

@ -127,6 +127,11 @@ protected:
GLenum _cullFace;
bool _depthTestEnabled;
bool _depthWriteEnabled;
bool _forceDepthWrite;
bool _renderStateCullFace;
bool _renderStateDepthTest;
GLboolean _renderStateDepthWrite;
// ModelView transform
Mat4 _mv;

View File

@ -35,6 +35,7 @@ RenderCommand::RenderCommand()
, _isTransparent(true)
, _skipBatching(false)
, _is3D(false)
, _depth(0)
{
}
@ -44,14 +45,16 @@ RenderCommand::~RenderCommand()
void RenderCommand::init(float globalZOrder, const cocos2d::Mat4 &transform, uint32_t flags)
{
_globalOrder = globalZOrder;
if (flags & Node::FLAGS_RENDER_AS_3D)
{
_globalOrder = Camera::getVisitingCamera()->getDepthInView(transform);
_depth = Camera::getVisitingCamera()->getDepthInView(transform);
set3D(true);
}
else
{
_globalOrder = globalZOrder;
set3D(false);
_depth = 0;
}
}

View File

@ -77,7 +77,9 @@ public:
inline bool is3D() const { return _is3D; }
inline void set3D(bool value) { _is3D = value; }
inline float getDepth() const { return _depth; }
protected:
RenderCommand();
virtual ~RenderCommand();
@ -98,6 +100,9 @@ protected:
// is the command been rendered on 3D pass
bool _is3D;
// depth
float _depth;
};
NS_CC_END

View File

@ -53,7 +53,7 @@ static bool compareRenderCommand(RenderCommand* a, RenderCommand* b)
static bool compare3DCommand(RenderCommand* a, RenderCommand* b)
{
return a->getGlobalOrder() > b->getGlobalOrder();
return a->getDepth() > b->getDepth();
}
// queue
@ -61,74 +61,113 @@ static bool compare3DCommand(RenderCommand* a, RenderCommand* b)
void RenderQueue::push_back(RenderCommand* command)
{
float z = command->getGlobalOrder();
if(command->is3D())
if(z < 0)
{
if(command->isTransparent())
_commands[QUEUE_GROUP::GLOBALZ_NEG].push_back(command);
}
else if(z > 0)
{
_commands[QUEUE_GROUP::GLOBALZ_POS].push_back(command);
}
else
{
if(command->is3D())
{
_queue3DTransparent.push_back(command);
if(command->isTransparent())
{
_commands[QUEUE_GROUP::TRANSPARENT_3D].push_back(command);
}
else
{
_commands[QUEUE_GROUP::OPAQUE_3D].push_back(command);
}
}
else
{
_queue3DOpaque.push_back(command);
_commands[QUEUE_GROUP::GLOBALZ_ZERO].push_back(command);
}
}
else if(z < 0)
_queueNegZ.push_back(command);
else if(z > 0)
_queuePosZ.push_back(command);
else
_queue0.push_back(command);
}
ssize_t RenderQueue::size() const
{
return _queue3DOpaque.size() + _queue3DTransparent.size() + _queueNegZ.size() + _queue0.size() + _queuePosZ.size();
ssize_t result(0);
for(int index = 0; index < QUEUE_GROUP::QUEUE_COUNT; ++index)
{
result += _commands[index].size();
}
return result;
}
void RenderQueue::sort()
{
// Don't sort _queue0, it already comes sorted
std::sort(std::begin(_queue3DTransparent), std::end(_queue3DTransparent), compare3DCommand);
std::sort(std::begin(_queueNegZ), std::end(_queueNegZ), compareRenderCommand);
std::sort(std::begin(_queuePosZ), std::end(_queuePosZ), compareRenderCommand);
std::sort(std::begin(_commands[QUEUE_GROUP::TRANSPARENT_3D]), std::end(_commands[QUEUE_GROUP::TRANSPARENT_3D]), compare3DCommand);
std::sort(std::begin(_commands[QUEUE_GROUP::GLOBALZ_NEG]), std::end(_commands[QUEUE_GROUP::GLOBALZ_NEG]), compareRenderCommand);
std::sort(std::begin(_commands[QUEUE_GROUP::GLOBALZ_POS]), std::end(_commands[QUEUE_GROUP::GLOBALZ_POS]), compareRenderCommand);
}
RenderCommand* RenderQueue::operator[](ssize_t index) const
{
if(index < static_cast<ssize_t>(_queue3DOpaque.size()))
return _queue3DOpaque[index];
index -= _queue3DOpaque.size();
if(index < static_cast<ssize_t>(_queue3DTransparent.size()))
return _queue3DTransparent[index];
for(int queIndex = 0; queIndex < QUEUE_GROUP::QUEUE_COUNT; ++queIndex)
{
if(index < static_cast<ssize_t>(_commands[queIndex].size()))
return _commands[queIndex][index];
else
{
index -= _commands[queIndex].size();
}
}
index -= _queue3DTransparent.size();
if(index < static_cast<ssize_t>(_queueNegZ.size()))
return _queueNegZ[index];
index -= _queueNegZ.size();
if(index < static_cast<ssize_t>(_queue0.size()))
return _queue0[index];
index -= _queue0.size();
if(index < static_cast<ssize_t>(_queuePosZ.size()))
return _queuePosZ[index];
CCASSERT(false, "invalid index");
return nullptr;
}
void RenderQueue::clear()
{
_queue3DOpaque.clear();
_queue3DTransparent.clear();
_queueNegZ.clear();
_queue0.clear();
_queuePosZ.clear();
_commands.clear();
for(int index = 0; index < QUEUE_COUNT; ++index)
{
_commands.push_back(std::vector<RenderCommand*>());
}
}
void RenderQueue::saveRenderState()
{
_isDepthEnabled = glIsEnabled(GL_DEPTH_TEST);
_isCullEnabled = glIsEnabled(GL_CULL_FACE);
glGetBooleanv(GL_DEPTH_WRITEMASK, &_isDepthWrite);
CHECK_GL_ERROR_DEBUG();
}
void RenderQueue::restoreRenderState()
{
if (_isCullEnabled)
{
glEnable(GL_CULL_FACE);
}
else
{
glDisable(GL_CULL_FACE);
}
if (_isDepthEnabled)
{
glEnable(GL_DEPTH_TEST);
}
else
{
glDisable(GL_DEPTH_TEST);
}
glDepthMask(_isDepthWrite);
CHECK_GL_ERROR_DEBUG();
}
//
@ -465,48 +504,103 @@ void Renderer::processRenderCommand(RenderCommand* command)
}
}
void Renderer::visitRenderQueue(const RenderQueue& queue)
void Renderer::visitRenderQueue(RenderQueue& queue)
{
ssize_t size = queue.size();
queue.saveRenderState();
//Process Opaque Object
const std::vector<RenderCommand*>& opaqueQueue = queue.getOpaqueCommands();
if (opaqueQueue.size() > 0)
//
//Process Global-Z < 0 Objects
//
const auto& zNegQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_NEG);
if (zNegQueue.size() > 0)
{
glDepthMask(true);
glEnable(GL_DEPTH_TEST);
for (auto it = opaqueQueue.cbegin(); it != opaqueQueue.cend(); ++it) {
if(_isDepthTestFor2D)
{
glEnable(GL_DEPTH_TEST);
glDepthMask(true);
}
else
{
glDisable(GL_DEPTH_TEST);
glDepthMask(false);
}
for (auto it = zNegQueue.cbegin(); it != zNegQueue.cend(); ++it)
{
processRenderCommand(*it);
}
glDisable(GL_DEPTH_TEST);
glDepthMask(false);
flush();
}
flush();
//Setup Transparent rendering
//
//Process Opaque Object
//
const auto& opaqueQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::OPAQUE_3D);
if (opaqueQueue.size() > 0)
{
glEnable(GL_DEPTH_TEST);
}
else
{
glDisable(GL_DEPTH_TEST);
}
if(_isDepthTestFor2D)
{
glEnable(GL_DEPTH_TEST);
//Clear depth to achieve layered rendering
glDepthMask(true);
glEnable(GL_DEPTH_TEST);
for (auto it = opaqueQueue.cbegin(); it != opaqueQueue.cend(); ++it)
{
processRenderCommand(*it);
}
flush();
}
//Process Transparent Object
for (ssize_t index = queue.getOpaqueQueueSize(); index < size; ++index)
//
//Process 3D Transparent object
//
const auto& transQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::TRANSPARENT_3D);
if (transQueue.size() > 0)
{
processRenderCommand(queue[index]);
glEnable(GL_DEPTH_TEST);
glDepthMask(false);
for (auto it = transQueue.cbegin(); it != transQueue.cend(); ++it)
{
processRenderCommand(*it);
}
flush();
}
flush();
//
//Process Global-Z = 0 Queue
//
const auto& zZeroQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_ZERO);
if (zZeroQueue.size() > 0)
{
if(_isDepthTestFor2D)
{
glEnable(GL_DEPTH_TEST);
glDepthMask(true);
}
else
{
glDisable(GL_DEPTH_TEST);
glDepthMask(false);
}
for (auto it = zZeroQueue.cbegin(); it != zZeroQueue.cend(); ++it)
{
processRenderCommand(*it);
}
flush();
}
//
//Process Global-Z > 0 Queue
//
const auto& zPosQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_POS);
if (zPosQueue.size() > 0)
{
for (auto it = zPosQueue.cbegin(); it != zPosQueue.cend(); ++it)
{
processRenderCommand(*it);
}
flush();
}
queue.restoreRenderState();
}
void Renderer::render()

View File

@ -47,22 +47,41 @@ class MeshCommand;
are the ones that have `z < 0` and `z > 0`.
*/
class RenderQueue {
public:
enum QUEUE_GROUP
{
GLOBALZ_NEG = 0,
OPAQUE_3D = 1,
TRANSPARENT_3D = 2,
GLOBALZ_ZERO = 3,
GLOBALZ_POS = 4,
QUEUE_COUNT = 5,
};
public:
RenderQueue()
{
clear();
}
void push_back(RenderCommand* command);
ssize_t size() const;
void sort();
RenderCommand* operator[](ssize_t index) const;
void clear();
ssize_t getOpaqueQueueSize() const { return _queue3DOpaque.size(); }
const std::vector<RenderCommand*>& getOpaqueCommands() const { return _queue3DOpaque; }
inline std::vector<RenderCommand*>& getSubQueue(QUEUE_GROUP group) { return _commands[group]; }
inline ssize_t getSubQueueSize(QUEUE_GROUP group) const { return _commands[group].size();}
void saveRenderState();
void restoreRenderState();
protected:
std::vector<RenderCommand*> _queue3DOpaque;
std::vector<RenderCommand*> _queue3DTransparent;
std::vector<RenderCommand*> _queueNegZ;
std::vector<RenderCommand*> _queue0;
std::vector<RenderCommand*> _queuePosZ;
std::vector<std::vector<RenderCommand*>> _commands;
//Render State related
bool _isCullEnabled;
bool _isDepthEnabled;
GLboolean _isDepthWrite;
};
struct RenderStackElement
@ -162,7 +181,7 @@ protected:
void flushTriangles();
void processRenderCommand(RenderCommand* command);
void visitRenderQueue(const RenderQueue& queue);
void visitRenderQueue(RenderQueue& queue);
void fillVerticesAndIndices(const TrianglesCommand* cmd);
void fillQuads(const QuadCommand* cmd);

View File

@ -222,9 +222,11 @@ void enableVertexAttribs(uint32_t flags)
// hardcoded!
for(int i=0; i < MAX_ATTRIBUTES; i++) {
unsigned int bit = 1 << i;
bool enabled = flags & bit;
bool enabledBefore = s_attributeFlags & bit;
if(enabled != enabledBefore) {
//FIXME:Cache is disabled, try to enable cache as before
bool enabled = (flags & bit) != 0;
bool enabledBefore = (s_attributeFlags & bit) != 0;
if(enabled != enabledBefore)
{
if( enabled )
glEnableVertexAttribArray(i);
else

View File

@ -14,6 +14,7 @@ include_directories(
${cocos_root}/cocos/ui
${cocos_root}/cocos/2d
${cocos_root}/cocos/3d
${cocos_root}/cocos/base
${cocos_root}/cocos/editor-support/spine
${cocos_root}/cocos/editor-support/cocostudio
${cocos_root}/cocos/editor-support/cocostudio/ActionTimeline

View File

@ -0,0 +1,26 @@
--------------------------------
-- @module AsyncTaskPool
-- @parent_module cc
--------------------------------
-- stop tasks<br>
-- param type task type you want to stop
-- @function [parent=#AsyncTaskPool] stopTasks
-- @param self
-- @param #int type
-- @return AsyncTaskPool#AsyncTaskPool self (return value: cc.AsyncTaskPool)
--------------------------------
-- destroy instance
-- @function [parent=#AsyncTaskPool] destoryInstance
-- @param self
-- @return AsyncTaskPool#AsyncTaskPool self (return value: cc.AsyncTaskPool)
--------------------------------
-- get instance
-- @function [parent=#AsyncTaskPool] getInstance
-- @param self
-- @return AsyncTaskPool#AsyncTaskPool ret (return value: cc.AsyncTaskPool)
return nil

View File

@ -115,11 +115,4 @@
-- @param self
-- @return Camera#Camera ret (return value: cc.Camera)
--------------------------------
-- Sets the position (X, Y, and Z) in its parent's coordinate system
-- @function [parent=#Camera] setPosition3D
-- @param self
-- @param #vec3_table position
-- @return Camera#Camera self (return value: cc.Camera)
return nil

View File

@ -254,6 +254,12 @@
-- @param #vec2_table anchorPoint
-- @return EditBox#EditBox self (return value: ccui.EditBox)
--------------------------------
-- Returns the "class name" of widget.
-- @function [parent=#EditBox] getDescription
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
--
-- @function [parent=#EditBox] setPosition

View File

@ -4,6 +4,12 @@
-- @extend Ref
-- @parent_module cc
--------------------------------
-- get mesh vertex attribute count
-- @function [parent=#Mesh] getMeshVertexAttribCount
-- @param self
-- @return long#long ret (return value: long)
--------------------------------
-- @overload self, cc.Texture2D
-- @overload self, string
@ -31,12 +37,25 @@
-- @param #cc.BlendFunc blendFunc
-- @return Mesh#Mesh self (return value: cc.Mesh)
--------------------------------
-- get per vertex size in bytes
-- @function [parent=#Mesh] getVertexSizeInBytes
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
--
-- @function [parent=#Mesh] getBlendFunc
-- @param self
-- @return BlendFunc#BlendFunc ret (return value: cc.BlendFunc)
--------------------------------
-- get MeshVertexAttribute by index
-- @function [parent=#Mesh] getMeshVertexAttribute
-- @param self
-- @param #int idx
-- @return MeshVertexAttrib#MeshVertexAttrib ret (return value: cc.MeshVertexAttrib)
--------------------------------
--
-- @function [parent=#Mesh] isVisible

View File

@ -4,6 +4,12 @@
-- @extend Node,BlendProtocol
-- @parent_module cc
--------------------------------
--
-- @function [parent=#Sprite3D] isForceDepthWrite
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#Sprite3D] setCullFaceEnabled
@ -90,6 +96,13 @@
-- @param #int index
-- @return Mesh#Mesh ret (return value: cc.Mesh)
--------------------------------
-- Force to write to depth buffer, this is useful if you want to achieve effects like fading.
-- @function [parent=#Sprite3D] setForceDepthWrite
-- @param self
-- @param #bool value
-- @return Sprite3D#Sprite3D self (return value: cc.Sprite3D)
--------------------------------
-- get Mesh by Name, it returns the first one if there are more than one mesh with the same name
-- @function [parent=#Sprite3D] getMeshByName
@ -114,17 +127,6 @@
-- @param #string texturePath
-- @return Sprite3D#Sprite3D ret (return value: cc.Sprite3D)
--------------------------------
-- @overload self, string, string, function, void
-- @overload self, string, function, void
-- @function [parent=#Sprite3D] createAsync
-- @param self
-- @param #string modelPath
-- @param #string texturePath
-- @param #function callback
-- @param #void callbackparam
-- @return Sprite3D#Sprite3D self (return value: cc.Sprite3D)
--------------------------------
-- Returns 2d bounding-box<br>
-- Note: the bouding-box is just get from the AABB which as Z=0, so that is not very accurate.
@ -139,6 +141,16 @@
-- @param #cc.GLProgramState glProgramState
-- @return Sprite3D#Sprite3D self (return value: cc.Sprite3D)
--------------------------------
-- Executes an action, and returns the action that is executed. For Sprite3D special logic are needed to take care of Fading.<br>
-- This node becomes the action's target. Refer to Action::getTarget()<br>
-- warning Actions don't retain their target.<br>
-- return An Action pointer
-- @function [parent=#Sprite3D] runAction
-- @param self
-- @param #cc.Action action
-- @return Action#Action ret (return value: cc.Action)
--------------------------------
-- just rember bind attributes
-- @function [parent=#Sprite3D] setGLProgram

View File

@ -0,0 +1,31 @@
--------------------------------
-- @module Sprite3DCache
-- @parent_module cc
--------------------------------
--
-- @function [parent=#Sprite3DCache] removeSprite3DData
-- @param self
-- @param #string key
-- @return Sprite3DCache#Sprite3DCache self (return value: cc.Sprite3DCache)
--------------------------------
--
-- @function [parent=#Sprite3DCache] removeAllSprite3DData
-- @param self
-- @return Sprite3DCache#Sprite3DCache self (return value: cc.Sprite3DCache)
--------------------------------
--
-- @function [parent=#Sprite3DCache] destroyInstance
-- @param self
-- @return Sprite3DCache#Sprite3DCache self (return value: cc.Sprite3DCache)
--------------------------------
-- get & destroy
-- @function [parent=#Sprite3DCache] getInstance
-- @param self
-- @return Sprite3DCache#Sprite3DCache ret (return value: cc.Sprite3DCache)
return nil

View File

@ -145,13 +145,6 @@
-- @param self
-- @return LayoutParameter#LayoutParameter ret (return value: ccui.LayoutParameter)
--------------------------------
-- Set a event handler to the widget in order to use cocostudio editor and framework
-- @function [parent=#Widget] addCCSEventListener
-- @param self
-- @param #function callback
-- @return Widget#Widget self (return value: ccui.Widget)
--------------------------------
-- Gets the position type of the widget<br>
-- see PositionType<br>
@ -402,13 +395,6 @@
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
--
-- @function [parent=#Widget] addTouchEventListener
-- @param self
-- @param #function callback
-- @return Widget#Widget self (return value: ccui.Widget)
--------------------------------
--
-- @function [parent=#Widget] getTouchEndPosition
@ -423,13 +409,6 @@
-- @param self
-- @return vec2_table#vec2_table ret (return value: vec2_table)
--------------------------------
-- Set a click event handler to the widget
-- @function [parent=#Widget] addClickEventListener
-- @param self
-- @param #function callback
-- @return Widget#Widget self (return value: ccui.Widget)
--------------------------------
-- Returns the flag which indicates whether the widget is flipped horizontally or not.<br>
-- It only flips the texture of the widget, and not the texture of the widget's children.<br>

View File

@ -11,6 +11,11 @@
-- @field [parent=#cc] Sprite3D#Sprite3D Sprite3D preloaded module
--------------------------------------------------------
-- the cc Sprite3DCache
-- @field [parent=#cc] Sprite3DCache#Sprite3DCache Sprite3DCache preloaded module
--------------------------------------------------------
-- the cc Mesh
-- @field [parent=#cc] Mesh#Mesh Mesh preloaded module

View File

@ -1246,4 +1246,9 @@
-- @field [parent=#cc] Component#Component Component preloaded module
--------------------------------------------------------
-- the cc AsyncTaskPool
-- @field [parent=#cc] AsyncTaskPool#AsyncTaskPool AsyncTaskPool preloaded module
return nil

View File

@ -372,6 +372,53 @@ int lua_register_cocos2dx_3d_Skeleton3D(lua_State* tolua_S)
return 1;
}
int lua_cocos2dx_3d_Sprite3D_isForceDepthWrite(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Sprite3D* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_isForceDepthWrite'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_isForceDepthWrite'", nullptr);
return 0;
}
bool ret = cobj->isForceDepthWrite();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:isForceDepthWrite",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_isForceDepthWrite'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_Sprite3D_setCullFaceEnabled(lua_State* tolua_S)
{
int argc = 0;
@ -1009,6 +1056,56 @@ int lua_cocos2dx_3d_Sprite3D_getMeshByIndex(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_3d_Sprite3D_setForceDepthWrite(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Sprite3D* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setForceDepthWrite'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Sprite3D:setForceDepthWrite");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_setForceDepthWrite'", nullptr);
return 0;
}
cobj->setForceDepthWrite(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setForceDepthWrite",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setForceDepthWrite'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_Sprite3D_getMeshByName(lua_State* tolua_S)
{
int argc = 0;
@ -1170,79 +1267,6 @@ int lua_cocos2dx_3d_Sprite3D_create(lua_State* tolua_S)
#endif
return 0;
}
int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 4)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite3D:createAsync");
if (!ok) { break; }
std::string arg1;
ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.Sprite3D:createAsync");
if (!ok) { break; }
std::function<void (cocos2d::Sprite3D *, void *)> arg2;
do {
// Lambda binding for lua is not supported.
assert(false);
} while(0)
;
if (!ok) { break; }
void* arg3;
#pragma warning NO CONVERSION TO NATIVE FOR void*
ok = false;
if (!ok) { break; }
cocos2d::Sprite3D::createAsync(arg0, arg1, arg2, arg3);
lua_settop(tolua_S, 1);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 3)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite3D:createAsync");
if (!ok) { break; }
std::function<void (cocos2d::Sprite3D *, void *)> arg1;
do {
// Lambda binding for lua is not supported.
assert(false);
} while(0)
;
if (!ok) { break; }
void* arg2;
#pragma warning NO CONVERSION TO NATIVE FOR void*
ok = false;
if (!ok) { break; }
cocos2d::Sprite3D::createAsync(arg0, arg1, arg2);
lua_settop(tolua_S, 1);
return 1;
}
} while (0);
ok = true;
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite3D:createAsync",argc, 3);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_createAsync'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_3d_Sprite3D_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (Sprite3D)");
@ -1255,6 +1279,7 @@ int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S)
tolua_cclass(tolua_S,"Sprite3D","cc.Sprite3D","cc.Node",nullptr);
tolua_beginmodule(tolua_S,"Sprite3D");
tolua_function(tolua_S,"isForceDepthWrite",lua_cocos2dx_3d_Sprite3D_isForceDepthWrite);
tolua_function(tolua_S,"setCullFaceEnabled",lua_cocos2dx_3d_Sprite3D_setCullFaceEnabled);
tolua_function(tolua_S,"setTexture",lua_cocos2dx_3d_Sprite3D_setTexture);
tolua_function(tolua_S,"getLightMask",lua_cocos2dx_3d_Sprite3D_getLightMask);
@ -1268,10 +1293,10 @@ int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S)
tolua_function(tolua_S,"removeAttachNode",lua_cocos2dx_3d_Sprite3D_removeAttachNode);
tolua_function(tolua_S,"getSkeleton",lua_cocos2dx_3d_Sprite3D_getSkeleton);
tolua_function(tolua_S,"getMeshByIndex",lua_cocos2dx_3d_Sprite3D_getMeshByIndex);
tolua_function(tolua_S,"setForceDepthWrite",lua_cocos2dx_3d_Sprite3D_setForceDepthWrite);
tolua_function(tolua_S,"getMeshByName",lua_cocos2dx_3d_Sprite3D_getMeshByName);
tolua_function(tolua_S,"getAttachNode",lua_cocos2dx_3d_Sprite3D_getAttachNode);
tolua_function(tolua_S,"create", lua_cocos2dx_3d_Sprite3D_create);
tolua_function(tolua_S,"createAsync", lua_cocos2dx_3d_Sprite3D_createAsync);
tolua_endmodule(tolua_S);
std::string typeName = typeid(cocos2d::Sprite3D).name();
g_luaType[typeName] = "cc.Sprite3D";
@ -1279,6 +1304,241 @@ int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S)
return 1;
}
int lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Sprite3DCache* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Sprite3DCache*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite3DCache:removeSprite3DData");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData'", nullptr);
return 0;
}
cobj->removeSprite3DData(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3DCache:removeSprite3DData",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Sprite3DCache* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Sprite3DCache*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData'", nullptr);
return 0;
}
cobj->removeAllSprite3DData();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3DCache:removeAllSprite3DData",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_Sprite3DCache_destroyInstance(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_destroyInstance'", nullptr);
return 0;
}
cocos2d::Sprite3DCache::destroyInstance();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite3DCache:destroyInstance",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_destroyInstance'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_Sprite3DCache_getInstance(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_getInstance'", nullptr);
return 0;
}
cocos2d::Sprite3DCache* ret = cocos2d::Sprite3DCache::getInstance();
object_to_luaval<cocos2d::Sprite3DCache>(tolua_S, "cc.Sprite3DCache",(cocos2d::Sprite3DCache*)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite3DCache:getInstance",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_getInstance'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_3d_Sprite3DCache_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (Sprite3DCache)");
return 0;
}
int lua_register_cocos2dx_3d_Sprite3DCache(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"cc.Sprite3DCache");
tolua_cclass(tolua_S,"Sprite3DCache","cc.Sprite3DCache","",nullptr);
tolua_beginmodule(tolua_S,"Sprite3DCache");
tolua_function(tolua_S,"removeSprite3DData",lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData);
tolua_function(tolua_S,"removeAllSprite3DData",lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData);
tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_3d_Sprite3DCache_destroyInstance);
tolua_function(tolua_S,"getInstance", lua_cocos2dx_3d_Sprite3DCache_getInstance);
tolua_endmodule(tolua_S);
std::string typeName = typeid(cocos2d::Sprite3DCache).name();
g_luaType[typeName] = "cc.Sprite3DCache";
g_typeCast["Sprite3DCache"] = "cc.Sprite3DCache";
return 1;
}
int lua_cocos2dx_3d_Mesh_getMeshVertexAttribCount(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Mesh* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Mesh",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Mesh*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Mesh_getMeshVertexAttribCount'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Mesh_getMeshVertexAttribCount'", nullptr);
return 0;
}
ssize_t ret = cobj->getMeshVertexAttribCount();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Mesh:getMeshVertexAttribCount",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Mesh_getMeshVertexAttribCount'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_Mesh_setTexture(lua_State* tolua_S)
{
int argc = 0;
@ -1478,6 +1738,53 @@ int lua_cocos2dx_3d_Mesh_setBlendFunc(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_3d_Mesh_getVertexSizeInBytes(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Mesh* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Mesh",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Mesh*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Mesh_getVertexSizeInBytes'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Mesh_getVertexSizeInBytes'", nullptr);
return 0;
}
int ret = cobj->getVertexSizeInBytes();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Mesh:getVertexSizeInBytes",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Mesh_getVertexSizeInBytes'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_Mesh_getBlendFunc(lua_State* tolua_S)
{
int argc = 0;
@ -1525,6 +1832,56 @@ int lua_cocos2dx_3d_Mesh_getBlendFunc(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_3d_Mesh_getMeshVertexAttribute(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Mesh* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Mesh",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Mesh*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Mesh_getMeshVertexAttribute'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Mesh:getMeshVertexAttribute");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Mesh_getMeshVertexAttribute'", nullptr);
return 0;
}
const cocos2d::MeshVertexAttrib& ret = cobj->getMeshVertexAttribute(arg0);
mesh_vertex_attrib_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Mesh:getMeshVertexAttribute",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Mesh_getMeshVertexAttribute'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_Mesh_isVisible(lua_State* tolua_S)
{
int argc = 0;
@ -1634,11 +1991,14 @@ int lua_register_cocos2dx_3d_Mesh(lua_State* tolua_S)
tolua_cclass(tolua_S,"Mesh","cc.Mesh","cc.Ref",nullptr);
tolua_beginmodule(tolua_S,"Mesh");
tolua_function(tolua_S,"getMeshVertexAttribCount",lua_cocos2dx_3d_Mesh_getMeshVertexAttribCount);
tolua_function(tolua_S,"setTexture",lua_cocos2dx_3d_Mesh_setTexture);
tolua_function(tolua_S,"getTexture",lua_cocos2dx_3d_Mesh_getTexture);
tolua_function(tolua_S,"getName",lua_cocos2dx_3d_Mesh_getName);
tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_3d_Mesh_setBlendFunc);
tolua_function(tolua_S,"getVertexSizeInBytes",lua_cocos2dx_3d_Mesh_getVertexSizeInBytes);
tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_3d_Mesh_getBlendFunc);
tolua_function(tolua_S,"getMeshVertexAttribute",lua_cocos2dx_3d_Mesh_getMeshVertexAttribute);
tolua_function(tolua_S,"isVisible",lua_cocos2dx_3d_Mesh_isVisible);
tolua_function(tolua_S,"setVisible",lua_cocos2dx_3d_Mesh_setVisible);
tolua_endmodule(tolua_S);
@ -2635,6 +2995,7 @@ TOLUA_API int register_all_cocos2dx_3d(lua_State* tolua_S)
lua_register_cocos2dx_3d_Animate3D(tolua_S);
lua_register_cocos2dx_3d_Sprite3D(tolua_S);
lua_register_cocos2dx_3d_AttachNode(tolua_S);
lua_register_cocos2dx_3d_Sprite3DCache(tolua_S);
lua_register_cocos2dx_3d_BillBoard(tolua_S);
lua_register_cocos2dx_3d_Animation3D(tolua_S);
lua_register_cocos2dx_3d_Skeleton3D(tolua_S);

View File

@ -57,6 +57,15 @@ int register_all_cocos2dx_3d(lua_State* tolua_S);

View File

@ -1,6 +1,7 @@
#include "lua_cocos2dx_auto.hpp"
#include "cocos2d.h"
#include "CCProtectedNode.h"
#include "CCAsyncTaskPool.h"
#include "tolua_fix.h"
#include "LuaBasicConversions.h"
@ -72824,6 +72825,146 @@ int lua_register_cocos2dx_Component(lua_State* tolua_S)
g_typeCast["Component"] = "cc.Component";
return 1;
}
int lua_cocos2dx_AsyncTaskPool_stopTasks(lua_State* tolua_S)
{
int argc = 0;
cocos2d::AsyncTaskPool* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.AsyncTaskPool",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::AsyncTaskPool*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AsyncTaskPool_stopTasks'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::AsyncTaskPool::TaskType arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AsyncTaskPool:stopTasks");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AsyncTaskPool_stopTasks'", nullptr);
return 0;
}
cobj->stopTasks(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AsyncTaskPool:stopTasks",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AsyncTaskPool_stopTasks'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_AsyncTaskPool_destoryInstance(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"cc.AsyncTaskPool",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AsyncTaskPool_destoryInstance'", nullptr);
return 0;
}
cocos2d::AsyncTaskPool::destoryInstance();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AsyncTaskPool:destoryInstance",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AsyncTaskPool_destoryInstance'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_AsyncTaskPool_getInstance(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"cc.AsyncTaskPool",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AsyncTaskPool_getInstance'", nullptr);
return 0;
}
cocos2d::AsyncTaskPool* ret = cocos2d::AsyncTaskPool::getInstance();
object_to_luaval<cocos2d::AsyncTaskPool>(tolua_S, "cc.AsyncTaskPool",(cocos2d::AsyncTaskPool*)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AsyncTaskPool:getInstance",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AsyncTaskPool_getInstance'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_AsyncTaskPool_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (AsyncTaskPool)");
return 0;
}
int lua_register_cocos2dx_AsyncTaskPool(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"cc.AsyncTaskPool");
tolua_cclass(tolua_S,"AsyncTaskPool","cc.AsyncTaskPool","",nullptr);
tolua_beginmodule(tolua_S,"AsyncTaskPool");
tolua_function(tolua_S,"stopTasks",lua_cocos2dx_AsyncTaskPool_stopTasks);
tolua_function(tolua_S,"destoryInstance", lua_cocos2dx_AsyncTaskPool_destoryInstance);
tolua_function(tolua_S,"getInstance", lua_cocos2dx_AsyncTaskPool_getInstance);
tolua_endmodule(tolua_S);
std::string typeName = typeid(cocos2d::AsyncTaskPool).name();
g_luaType[typeName] = "cc.AsyncTaskPool";
g_typeCast["AsyncTaskPool"] = "cc.AsyncTaskPool";
return 1;
}
TOLUA_API int register_all_cocos2dx(lua_State* tolua_S)
{
tolua_open(tolua_S);
@ -72925,6 +73066,7 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S)
lua_register_cocos2dx_Application(tolua_S);
lua_register_cocos2dx_DelayTime(tolua_S);
lua_register_cocos2dx_LabelAtlas(tolua_S);
lua_register_cocos2dx_AsyncTaskPool(tolua_S);
lua_register_cocos2dx_ParticleSnow(tolua_S);
lua_register_cocos2dx_EaseElasticIn(tolua_S);
lua_register_cocos2dx_EaseCircleActionInOut(tolua_S);

View File

@ -1637,6 +1637,10 @@ int register_all_cocos2dx(lua_State* tolua_S);

View File

@ -1792,60 +1792,6 @@ int lua_cocos2dx_ui_Widget_getLayoutParameter(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_ui_Widget_addCCSEventListener(lua_State* tolua_S)
{
int argc = 0;
cocos2d::ui::Widget* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_addCCSEventListener'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::function<void (cocos2d::Ref *, int)> arg0;
do {
// Lambda binding for lua is not supported.
assert(false);
} while(0)
;
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Widget_addCCSEventListener'", nullptr);
return 0;
}
cobj->addCCSEventListener(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Widget:addCCSEventListener",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_addCCSEventListener'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_ui_Widget_getPositionType(lua_State* tolua_S)
{
int argc = 0;
@ -3487,60 +3433,6 @@ int lua_cocos2dx_ui_Widget_getCallbackType(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_ui_Widget_addTouchEventListener(lua_State* tolua_S)
{
int argc = 0;
cocos2d::ui::Widget* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_addTouchEventListener'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::function<void (cocos2d::Ref *, cocos2d::ui::Widget::TouchEventType)> arg0;
do {
// Lambda binding for lua is not supported.
assert(false);
} while(0)
;
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Widget_addTouchEventListener'", nullptr);
return 0;
}
cobj->addTouchEventListener(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Widget:addTouchEventListener",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_addTouchEventListener'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_ui_Widget_getTouchEndPosition(lua_State* tolua_S)
{
int argc = 0;
@ -3635,60 +3527,6 @@ int lua_cocos2dx_ui_Widget_getPositionPercent(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_ui_Widget_addClickEventListener(lua_State* tolua_S)
{
int argc = 0;
cocos2d::ui::Widget* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_addClickEventListener'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::function<void (cocos2d::Ref *)> arg0;
do {
// Lambda binding for lua is not supported.
assert(false);
} while(0)
;
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Widget_addClickEventListener'", nullptr);
return 0;
}
cobj->addClickEventListener(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Widget:addClickEventListener",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_addClickEventListener'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_ui_Widget_isFlippedX(lua_State* tolua_S)
{
int argc = 0;
@ -4169,7 +4007,6 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S)
tolua_function(tolua_S,"getVirtualRendererSize",lua_cocos2dx_ui_Widget_getVirtualRendererSize);
tolua_function(tolua_S,"isHighlighted",lua_cocos2dx_ui_Widget_isHighlighted);
tolua_function(tolua_S,"getLayoutParameter",lua_cocos2dx_ui_Widget_getLayoutParameter);
tolua_function(tolua_S,"addCCSEventListener",lua_cocos2dx_ui_Widget_addCCSEventListener);
tolua_function(tolua_S,"getPositionType",lua_cocos2dx_ui_Widget_getPositionType);
tolua_function(tolua_S,"getTopBoundary",lua_cocos2dx_ui_Widget_getTopBoundary);
tolua_function(tolua_S,"ignoreContentAdaptWithSize",lua_cocos2dx_ui_Widget_ignoreContentAdaptWithSize);
@ -4204,10 +4041,8 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S)
tolua_function(tolua_S,"getTouchMovePosition",lua_cocos2dx_ui_Widget_getTouchMovePosition);
tolua_function(tolua_S,"getSizeType",lua_cocos2dx_ui_Widget_getSizeType);
tolua_function(tolua_S,"getCallbackType",lua_cocos2dx_ui_Widget_getCallbackType);
tolua_function(tolua_S,"addTouchEventListener",lua_cocos2dx_ui_Widget_addTouchEventListener);
tolua_function(tolua_S,"getTouchEndPosition",lua_cocos2dx_ui_Widget_getTouchEndPosition);
tolua_function(tolua_S,"getPositionPercent",lua_cocos2dx_ui_Widget_getPositionPercent);
tolua_function(tolua_S,"addClickEventListener",lua_cocos2dx_ui_Widget_addClickEventListener);
tolua_function(tolua_S,"isFlippedX",lua_cocos2dx_ui_Widget_isFlippedX);
tolua_function(tolua_S,"isFlippedY",lua_cocos2dx_ui_Widget_isFlippedY);
tolua_function(tolua_S,"isClippingParentContainsPoint",lua_cocos2dx_ui_Widget_isClippingParentContainsPoint);

View File

@ -545,9 +545,6 @@ int register_all_cocos2dx_ui(lua_State* tolua_S);

View File

@ -116,6 +116,89 @@ tolua_lerror:
return 0;
}
int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 3)
{
std::string modelPath;
ok &= luaval_to_std_string(tolua_S, 2,&modelPath, "cc.Sprite3D:createAsync");
if (!ok)
break;
std::string texturePath;
ok &= luaval_to_std_string(tolua_S, 3,&texturePath, "cc.Sprite3D:createAsync");
if (!ok)
break;
#if COCOS2D_DEBUG >= 1
if (!toluafix_isfunction(tolua_S,4,"LUA_FUNCTION",0,&tolua_err)) {
goto tolua_lerror;
}
#endif
LUA_FUNCTION handler = toluafix_ref_function(tolua_S,4,0);
cocos2d::Sprite3D::createAsync(modelPath, texturePath, [=](cocos2d::Sprite3D* sprite, void* callbackparam){
int id = (sprite) ? (int)sprite->_ID : -1;
int* luaID = (sprite) ? &sprite->_luaID : nullptr;
toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)sprite,"cc.Sprite3D");
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 1);
}, nullptr);
lua_settop(tolua_S, 1);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 2)
{
std::string modelPath;
ok &= luaval_to_std_string(tolua_S, 2,&modelPath, "cc.Sprite3D:createAsync");
if (!ok)
break;
#if COCOS2D_DEBUG >= 1
if (!toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err)) {
goto tolua_lerror;
}
#endif
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0);
cocos2d::Sprite3D::createAsync(modelPath, [=](cocos2d::Sprite3D* sprite, void* callbackparam){
int id = (sprite) ? (int)sprite->_ID : -1;
int* luaID = (sprite) ? &sprite->_luaID : nullptr;
toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)sprite,"cc.Sprite3D");
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 1);
}, nullptr);
lua_settop(tolua_S, 1);
return 1;
}
} while (0);
ok = true;
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite3D:createAsync",argc, 3);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_createAsync'.",&tolua_err);
#endif
return 0;
}
static void extendSprite3D(lua_State* L)
{
lua_pushstring(L, "cc.Sprite3D");
@ -124,6 +207,7 @@ static void extendSprite3D(lua_State* L)
{
tolua_function(L, "setBlendFunc", lua_cocos2dx_3d_Sprite3D_setBlendFunc01);
tolua_function(L, "getAABB", lua_cocos2dx_3d_Sprite3D_getAABB);
tolua_function(L, "createAsync", lua_cocos2dx_3d_Sprite3D_createAsync);
}
lua_pop(L, 1);
}

View File

@ -842,6 +842,19 @@ int LuaStack::luaLoadChunksFromZIP(lua_State *L)
ssize_t bufferSize = 0;
unsigned char *zbuffer = zip->getFileData(filename.c_str(), &bufferSize);
if (bufferSize) {
// remove extension
std::size_t found = filename.rfind(".lua");
if (found != std::string::npos)
{
filename.erase(found);
}
// replace path seperator '/' '\' to '.'
for (int i=0; i<filename.size(); i++) {
if (filename[i] == '/' || filename[i] == '\\') {
filename[i] = '.';
}
}
CCLOG("[luaLoadChunksFromZIP] add %s to preload", filename.c_str());
if (stack->luaLoadBuffer(L, (char*)zbuffer, (int)bufferSize, filename.c_str()) == 0) {
lua_setfield(L, -2, filename.c_str());
++count;

View File

@ -839,7 +839,7 @@ bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue , c
lua_pushstring(L, "fontName");
lua_gettable(L,lo);
outValue->_fontName = tolua_tocppstring(L,lo,defautlFontName);
outValue->_fontName = tolua_tocppstring(L, lua_gettop(L), defautlFontName);
lua_pop(L,1);
lua_pushstring(L, "fontSize");
@ -861,7 +861,7 @@ bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue , c
lua_gettable(L,lo);
if (!lua_isnil(L,-1))
{
luaval_to_color3b(L, -1, &outValue->_fontFillColor);
luaval_to_color3b(L, lua_gettop(L), &outValue->_fontFillColor);
}
lua_pop(L,1);
@ -869,7 +869,7 @@ bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue , c
lua_gettable(L,lo);
if (!lua_isnil(L,-1))
{
luaval_to_size(L, -1, &outValue->_dimensions);
luaval_to_size(L, lua_gettop(L), &outValue->_dimensions);
}
lua_pop(L,1);
@ -890,7 +890,7 @@ bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue , c
lua_gettable(L,lo);
if (!lua_isnil(L,-1))
{
luaval_to_size(L, -1, &outValue->_shadow._shadowOffset);
luaval_to_size(L, lua_gettop(L), &outValue->_shadow._shadowOffset);
}
lua_pop(L,1);
@ -927,7 +927,7 @@ bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue , c
lua_gettable(L,lo);
if (!lua_isnil(L,-1))
{
luaval_to_color3b(L, -1, &outValue->_stroke._strokeColor);
luaval_to_color3b(L, lua_gettop(L), &outValue->_stroke._strokeColor);
}
lua_pop(L,1);

View File

@ -694,11 +694,11 @@ static int tolua_Cocos2d_glClearColor00(lua_State* tolua_S)
else
#endif
{
unsigned int red = (unsigned int)tolua_tonumber(tolua_S,1,0);
unsigned int green = (unsigned int)tolua_tonumber(tolua_S,2,0);
unsigned int blue = (unsigned int)tolua_tonumber(tolua_S,3,0);
unsigned int alpha = (unsigned int)tolua_tonumber(tolua_S,4,0);
glClearColor((GLclampf)red , (GLclampf)green , (GLclampf)blue , (GLclampf)alpha);
GLclampf red = (GLclampf)tolua_tonumber(tolua_S,1,0);
GLclampf green = (GLclampf)tolua_tonumber(tolua_S,2,0);
GLclampf blue = (GLclampf)tolua_tonumber(tolua_S,3,0);
GLclampf alpha = (GLclampf)tolua_tonumber(tolua_S,4,0);
glClearColor(red , green , blue , alpha);
}
return 0;
#ifndef TOLUA_RELEASE

View File

@ -6718,7 +6718,7 @@ static int lua_cocos2dx_GLProgramState_setVertexAttribPointer(lua_State* tolua_S
unsigned int arg2;
bool arg3;
int arg4;
int arg5;
long arg5;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.GLProgramState:setVertexAttribPointer");
@ -6730,11 +6730,11 @@ static int lua_cocos2dx_GLProgramState_setVertexAttribPointer(lua_State* tolua_S
ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "cc.GLProgramState:setVertexAttribPointer");
ok &= luaval_to_int32(tolua_S, 7, (int *)&arg5, "cc.GLProgramState:setVertexAttribPointer");
ok &= luaval_to_long(tolua_S, 7, (long *)&arg5, "cc.GLProgramState:setVertexAttribPointer");
if(!ok)
return 0;
cobj->setVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, (void*)&arg5);
cobj->setVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, (void*)arg5);
lua_settop(tolua_S, 1);
return 1;
}
@ -7527,7 +7527,7 @@ static int tolua_cocos2d_Mat4_transformVector(lua_State* tolua_S)
!tolua_isnumber(tolua_S, 3, 0, &tolua_err) ||
!tolua_isnumber(tolua_S, 4, 0, &tolua_err) ||
!tolua_isnumber(tolua_S, 5, 0, &tolua_err) ||
!tolua_isnumber(tolua_S, 6, 0, &tolua_err))
!tolua_istable(tolua_S, 6, 0, &tolua_err) )
goto tolua_lerror;
else
#endif
@ -7566,10 +7566,11 @@ static int tolua_cocos2d_Mat4_decompose(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
!tolua_istable(tolua_S, 2, 0, &tolua_err) ||
!tolua_istable(tolua_S, 3, 0, &tolua_err) ||
!tolua_istable(tolua_S, 4, 0, &tolua_err))
(!lua_isnil(tolua_S, 2) && !tolua_istable(tolua_S, 2, 0, &tolua_err)) ||
(!lua_isnil(tolua_S, 3) && !tolua_istable(tolua_S, 3, 0, &tolua_err)) ||
(!lua_isnil(tolua_S, 4) && !tolua_istable(tolua_S, 4, 0, &tolua_err)) )
goto tolua_lerror;
else
#endif
@ -7579,27 +7580,210 @@ static int tolua_cocos2d_Mat4_decompose(lua_State* tolua_S)
cocos2d::Quaternion rotation;
cocos2d::Vec3 translation;
bool ok = true;
ok &= luaval_to_mat4(tolua_S, 1, &mat);
if (!ok)
return 0;
ok &= luaval_to_vec3(tolua_S, 2, &scale);
if (!ok)
return 0;
if (lua_isnil(tolua_S, 2) && !lua_isnil(tolua_S, 3) && !lua_isnil(tolua_S, 4))
{
ok &= luaval_to_quaternion(tolua_S, 3, &rotation);
if (!ok)
return 0;
ok &= luaval_to_quaternion(tolua_S, 3, &rotation);
if (!ok)
return 0;
ok &= luaval_to_vec3(tolua_S, 4, &translation);
if (!ok)
return 0;
mat.decompose(nullptr, &rotation, &translation);
lua_newtable(tolua_S);
lua_pushstring(tolua_S, "scale");
lua_pushnil(tolua_S);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "rotation");
quaternion_to_luaval(tolua_S, rotation);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "translation");
vec3_to_luaval(tolua_S, translation);
lua_rawset(tolua_S, -3);
return 1;
}
ok &= luaval_to_vec3(tolua_S, 2, &translation);
if (!ok)
return 0;
if (lua_isnil(tolua_S, 2) && lua_isnil(tolua_S, 3) && !lua_isnil(tolua_S, 4))
{
ok &= luaval_to_vec3(tolua_S, 4, &translation);
if (!ok)
return 0;
mat.decompose(nullptr, nullptr, &translation);
lua_newtable(tolua_S);
lua_pushstring(tolua_S, "scale");
lua_pushnil(tolua_S);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "rotation");
lua_pushnil(tolua_S);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "translation");
vec3_to_luaval(tolua_S, translation);
lua_rawset(tolua_S, -3);
return 1;
}
mat.decompose(&scale, &rotation, &translation);
vec3_to_luaval(tolua_S, scale);
quaternion_to_luaval(tolua_S, rotation);
vec3_to_luaval(tolua_S, translation);
return 3;
if (!lua_isnil(tolua_S, 2) && lua_isnil(tolua_S, 3) && !lua_isnil(tolua_S, 4))
{
ok &= luaval_to_vec3(tolua_S, 2, &scale);
if (!ok)
return 0;
ok &= luaval_to_vec3(tolua_S, 4, &translation);
if (!ok)
return 0;
mat.decompose(&scale, nullptr, &translation);
lua_newtable(tolua_S);
lua_pushstring(tolua_S, "scale");
vec3_to_luaval(tolua_S, scale);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "rotation");
lua_pushnil(tolua_S);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "translation");
vec3_to_luaval(tolua_S, translation);
lua_rawset(tolua_S, -3);
return 1;
}
if (!lua_isnil(tolua_S, 2) && lua_isnil(tolua_S, 3) && lua_isnil(tolua_S, 4))
{
ok &= luaval_to_vec3(tolua_S, 2, &scale);
if (!ok)
return 0;
mat.decompose(&scale, nullptr, nullptr);
lua_newtable(tolua_S);
lua_pushstring(tolua_S, "scale");
vec3_to_luaval(tolua_S, scale);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "rotation");
lua_pushnil(tolua_S);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "translation");
lua_pushnil(tolua_S);
lua_rawset(tolua_S, -3);
return 1;
}
if (!lua_isnil(tolua_S, 2) && !lua_isnil(tolua_S, 3) && lua_isnil(tolua_S, 4))
{
ok &= luaval_to_vec3(tolua_S, 2, &scale);
if (!ok)
return 0;
ok &= luaval_to_quaternion(tolua_S, 3, &rotation);
if (!ok)
return 0;
mat.decompose(&scale, &rotation, nullptr);
lua_newtable(tolua_S);
lua_pushstring(tolua_S, "scale");
vec3_to_luaval(tolua_S, scale);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "rotation");
quaternion_to_luaval(tolua_S, rotation);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "translation");
lua_pushnil(tolua_S);
lua_rawset(tolua_S, -3);
return 1;
}
if (lua_isnil(tolua_S, 2) && !lua_isnil(tolua_S, 3) && lua_isnil(tolua_S, 4))
{
ok &= luaval_to_quaternion(tolua_S, 3, &rotation);
if (!ok)
return 0;
mat.decompose(nullptr, &rotation, nullptr);
lua_newtable(tolua_S);
lua_pushstring(tolua_S, "scale");
lua_pushnil(tolua_S);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "rotation");
quaternion_to_luaval(tolua_S, rotation);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "translation");
lua_pushnil(tolua_S);
lua_rawset(tolua_S, -3);
}
if (!lua_isnil(tolua_S, 2) && !lua_isnil(tolua_S, 3) && !lua_isnil(tolua_S, 4))
{
ok &= luaval_to_vec3(tolua_S, 2, &scale);
if (!ok)
return 0;
ok &= luaval_to_quaternion(tolua_S, 3, &rotation);
if (!ok)
return 0;
ok &= luaval_to_vec3(tolua_S, 4, &translation);
if (!ok)
return 0;
mat.decompose(&scale, &rotation, &translation);
lua_newtable(tolua_S);
lua_pushstring(tolua_S, "scale");
vec3_to_luaval(tolua_S, scale);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "rotation");
quaternion_to_luaval(tolua_S, rotation);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "translation");
vec3_to_luaval(tolua_S, translation);
lua_rawset(tolua_S, -3);
return 1;
}
return 0;
}
return 0;
#if COCOS2D_DEBUG >= 1
@ -7617,7 +7801,7 @@ static int tolua_cocos2d_Vec3_cross(lua_State* tolua_S)
tolua_Error tolua_err;
#endif
if (1 == argc)
if (2 == argc)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
@ -7687,6 +7871,38 @@ tolua_lerror:
#endif
}
static int tolua_cocos2d_Mat4_multiply(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
!tolua_istable(tolua_S, 2, 0, &tolua_err) )
goto tolua_lerror;
else
#endif
{
cocos2d::Mat4 mat1;
bool ok = luaval_to_mat4(tolua_S, 1, &mat1);
if(!ok)
return 0;
cocos2d::Mat4 mat2;
ok = luaval_to_mat4(tolua_S, 2, &mat2);
if(!ok)
return 0;
cocos2d::Mat4 ret = mat1 * mat2;
mat4_to_luaval(tolua_S, ret);
return 1;
}
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'mat4_multiply'.",&tolua_err);
return 0;
#endif
}
int register_all_cocos2dx_math_manual(lua_State* tolua_S)
{
if (nullptr == tolua_S)
@ -7698,6 +7914,7 @@ int register_all_cocos2dx_math_manual(lua_State* tolua_S)
tolua_function(tolua_S, "mat4_getInversed", tolua_cocos2d_Mat4_getInversed);
tolua_function(tolua_S, "mat4_transformVector", tolua_cocos2d_Mat4_transformVector);
tolua_function(tolua_S, "mat4_decompose", tolua_cocos2d_Mat4_decompose);
tolua_function(tolua_S, "mat4_multiply", tolua_cocos2d_Mat4_multiply);
tolua_function(tolua_S, "vec3_cross", tolua_cocos2d_Vec3_cross);
tolua_endmodule(tolua_S);
return 0;

View File

@ -103,6 +103,62 @@ tolua_lerror:
#endif
}
static int lua_cocos2dx_Widget_addClickEventListener(lua_State* L)
{
if (nullptr == L)
return 0;
int argc = 0;
Widget* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(L,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<Widget*>(tolua_tousertype(L,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Widget_addClickEventListener'\n", NULL);
return 0;
}
#endif
argc = lua_gettop(L) - 1;
if (1 == argc)
{
#if COCOS2D_DEBUG >= 1
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err))
{
goto tolua_lerror;
}
#endif
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
self->addClickEventListener([=](cocos2d::Ref* sender){
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
stack->pushObject(sender, "cc.Ref");
stack->executeFunctionByHandler(handler, 1);
stack->clean();
});
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
return 0;
}
luaL_error(L, "'addClickEventListener' function of Widget has wrong number of arguments: %d, was expecting %d\n", argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'addClickEventListener'.",&tolua_err);
return 0;
#endif
}
static void extendWidget(lua_State* L)
{
lua_pushstring(L, "ccui.Widget");
@ -110,6 +166,7 @@ static void extendWidget(lua_State* L)
if (lua_istable(L,-1))
{
tolua_function(L, "addTouchEventListener", lua_cocos2dx_Widget_addTouchEventListener);
tolua_function(L, "addClickEventListener", lua_cocos2dx_Widget_addClickEventListener);
}
lua_pop(L, 1);
}

View File

@ -175,7 +175,7 @@ function cc.pIsSegmentIntersect(pt1,pt2,pt3,pt4)
ret,s,t =cc.pIsLineIntersect(pt1, pt2, pt3, pt4,s,t)
if ret and s >= 0.0 and s <= 1.0 and t >= 0.0 and t <= 0.0 then
return true;
return true
end
return false
@ -450,7 +450,6 @@ cc.mat4 = cc.mat4 or {}
function cc.mat4.new(...)
local params = {...}
local size = #params
local obj = {}
if 1 == size then
@ -463,10 +462,8 @@ function cc.mat4.new(...)
end
end
elseif 16 == size then
if params[i] ~= nil then
mat4[i] = params[i]
else
mat4[i] = 0
for i= 1, 16 do
obj[i] = params[i]
end
end
@ -482,3 +479,66 @@ end
function cc.mat4.transformVector(self, vector, dst)
return mat4_transformVector(self, vector, dst)
end
function cc.mat4.multiply(self, mat)
return mat4_multiply(self, mat)
end
function cc.mat4.decompose(self, scale, rotation, translation)
return mat4_decompose(self, scale ,rotation, translation)
end
function cc.mat4.createIdentity()
return cc.mat4.new(1.0 ,0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0)
end
function cc.mat4.createTranslation(translation, dst)
assert(type(translation) == "table" and type(dst) == "table", "The type of input parameters should be table")
dst = cc.mat4.createIdentity()
dst[13] = translation.x
dst[14] = translation.y
dst[15] = translation.z
return dst
end
function cc.mat4.createRotation(q, dst)
assert(type(q) == "table" and type(dst) == "table", "The type of input parameters should be table")
local x2 = q.x + q.x
local y2 = q.y + q.y
local z2 = q.z + q.z
local xx2 = q.x * x2
local yy2 = q.y * y2
local zz2 = q.z * z2
local xy2 = q.x * y2
local xz2 = q.x * z2
local yz2 = q.y * z2
local wx2 = q.w * x2
local wy2 = q.w * y2
local wz2 = q.w * z2
dst[1] = 1.0 - yy2 - zz2
dst[2] = xy2 + wz2
dst[3] = xz2 - wy2
dst[4] = 0.0
dst[5] = xy2 - wz2
dst[6] = 1.0 - xx2 - zz2
dst[7] = yz2 + wx2
dst[8] = 0.0
dst[9] = xz2 + wy2
dst[10] = yz2 - wx2
dst[11] = 1.0 - xx2 - yy2
dst[12] = 0.0
dst[13] = 0.0
dst[14] = 0.0
dst[15] = 0.0
dst[16] = 1.0
return dst
end

View File

@ -610,3 +610,12 @@ cc.LightFlag =
LIGHT14 = math.pow(2,14),
LIGHT15 = math.pow(2,15),
}
cc.AsyncTaskPool.TaskType =
{
TASK_IO = 0,
TASK_NETWORK = 1,
TASK_OTHER = 2,
TASK_MAX_TYPE = 3,
}

View File

@ -449,15 +449,9 @@ void Button::onPressStateChangedToPressed()
_buttonNormalRenderer->setScale(_pressedTextureScaleXInSize + _zoomScale, _pressedTextureScaleYInSize + _zoomScale);
_titleRenderer->stopAllActions();
Action *zoomTitleAction = ScaleTo::create(ZOOM_ACTION_TIME_STEP, 1.0f + _zoomScale, 1.0f + _zoomScale);
if (_unifySize)
{
_titleRenderer->runAction(zoomTitleAction);
}
else
{
_titleRenderer->runAction(zoomTitleAction->clone());
}
_titleRenderer->runAction(zoomTitleAction);
}
}
else

View File

@ -385,6 +385,11 @@ void EditBox::setAnchorPoint(const Vec2& anchorPoint)
}
}
std::string EditBox::getDescription() const
{
return "EditBox";
}
void EditBox::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
Widget::visit(renderer, parentTransform, parentFlags);

View File

@ -394,6 +394,12 @@ namespace ui {
virtual void setVisible(bool visible) override;
virtual void setContentSize(const Size& size) override;
virtual void setAnchorPoint(const Vec2& anchorPoint) override;
/**
* Returns the "class name" of widget.
*/
virtual std::string getDescription() const override;
/**
* @js NA
* @lua NA

View File

@ -517,6 +517,8 @@ void EditBoxImplWin::doAnimationWhenKeyboardMove(float duration, float distance)
{
}
static const int CC_EDIT_BOX_PADDING = 5;
bool EditBoxImplWin::initWithSize(const Size& size)
{
//! int fontSize = getFontSizeAccordingHeightJni(size.height-12);
@ -524,7 +526,7 @@ bool EditBoxImplWin::initWithSize(const Size& size)
_label->setSystemFontSize(size.height-12);
// align the text vertically center
_label->setAnchorPoint(Vec2(0, 0.5f));
_label->setPosition(Vec2(5, size.height / 2.0f));
_label->setPosition(Vec2(CC_EDIT_BOX_PADDING, size.height / 2.0f));
_label->setColor(_colText);
_editBox->addChild(_label);
@ -532,7 +534,7 @@ bool EditBoxImplWin::initWithSize(const Size& size)
_labelPlaceHolder->setSystemFontSize(size.height-12);
// align the text vertically center
_labelPlaceHolder->setAnchorPoint(Vec2(0, 0.5f));
_labelPlaceHolder->setPosition(5, size.height / 2.0f);
_labelPlaceHolder->setPosition(CC_EDIT_BOX_PADDING, size.height / 2.0f);
_labelPlaceHolder->setVisible(false);
_labelPlaceHolder->setColor(_colPlaceHolder);
_editBox->addChild(_labelPlaceHolder);
@ -631,7 +633,14 @@ void EditBoxImplWin::setText(const char* pText)
//! std::string strWithEllipsis = getStringWithEllipsisJni(strToShow.c_str(), _editSize.width, _editSize.height-12);
//! _label->setString(strWithEllipsis.c_str());
_label->setString(strToShow.c_str());
_label->setString(strToShow.c_str());
float maxWidth = _editSize.width - 2 * CC_EDIT_BOX_PADDING;
auto labelSize = _label->getContentSize();
if (labelSize.width > maxWidth)
{
_label->setDimensions(maxWidth, labelSize.height);
}
}
else
{

View File

@ -193,6 +193,8 @@ void LoadingBar::loadTexture(const std::string& texture,TextureResType texType)
barRendererScaleChangedWithSize();
updateContentSizeWithTextureSize(_barRendererTextureSize);
this->updateProgressBar();
_barRendererAdaptDirty = true;
}
@ -216,7 +218,7 @@ void LoadingBar::setScale9Enabled(bool enabled)
ignoreContentAdaptWithSize(_prevIgnoreSize);
}
setCapInsets(_capInsets);
setPercent(_percent);
this->updateProgressBar();
_barRendererAdaptDirty = true;
}
@ -255,18 +257,24 @@ void LoadingBar::setPercent(float percent)
return;
}
_percent = percent;
if (_totalLength <= 0)
{
return;
}
float res = _percent / 100.0f;
this->updateProgressBar();
}
void LoadingBar::updateProgressBar()
{
if (_scale9Enabled)
{
setScale9Scale();
}
else
{
float res = _percent / 100.0f;
Sprite* spriteRenderer = _barRenderer->getSprite();
Rect rect = spriteRenderer->getTextureRect();
rect.size.width = _barRendererTextureSize.width * res;
@ -334,7 +342,7 @@ void LoadingBar::barRendererScaleChangedWithSize()
_totalLength = _contentSize.width;
if (_scale9Enabled)
{
setScale9Scale();
this->setScale9Scale();
_barRenderer->setScale(1.0f);
}
else

View File

@ -148,6 +148,7 @@ protected:
virtual void onSizeChanged() override;
void setScale9Scale();
void updateProgressBar();
void barRendererScaleChangedWithSize();
virtual void adaptRenderers() override;

View File

@ -193,11 +193,22 @@ namespace ui {
this->cleanupSlicedSprites();
_protectedChildren.clear();
if(this->_scale9Image != sprite)
if(nullptr != sprite)
{
CC_SAFE_RELEASE(this->_scale9Image);
_scale9Image = sprite;
CC_SAFE_RETAIN(_scale9Image);
if (nullptr == sprite->getSpriteFrame())
{
return false;
}
if (nullptr == _scale9Image)
{
_scale9Image = sprite;
_scale9Image->retain();
}
else
{
_scale9Image->setSpriteFrame(sprite->getSpriteFrame());
}
}
if (!_scale9Image)

View File

@ -367,7 +367,7 @@ void Slider::setPercent(int percent)
_slidBallRenderer->setPosition(dis, _contentSize.height / 2.0f);
if (_scale9Enabled)
{
_progressBarRenderer->setPreferredSize(Size(dis,_progressBarTextureSize.height));
_progressBarRenderer->setPreferredSize(Size(dis,_contentSize.height));
}
else
{

View File

@ -594,31 +594,35 @@ const char* TextField::getPasswordStyleText()const
void TextField::update(float dt)
{
if (getAttachWithIME())
{
attachWithIMEEvent();
setAttachWithIME(false);
}
if (getDetachWithIME())
{
detachWithIMEEvent();
setDetachWithIME(false);
}
if (getAttachWithIME())
{
attachWithIMEEvent();
setAttachWithIME(false);
}
if (getInsertText())
{
//we update the content size first such that when user call getContentSize() in event callback won't be wrong
_textFieldRendererAdaptDirty = true;
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
insertTextEvent();
setInsertText(false);
_textFieldRendererAdaptDirty = true;
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
}
if (getDeleteBackward())
{
deleteBackwardEvent();
setDeleteBackward(false);
_textFieldRendererAdaptDirty = true;
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
deleteBackwardEvent();
setDeleteBackward(false);
}
}

View File

@ -72,7 +72,7 @@ public:
* @param string The content for the main page.
* @param baseURL The base URL for the content.
*/
void loadHTMLString(const std::string &string, const std::string &baseURL);
void loadHTMLString(const std::string &string, const std::string &baseURL = "");
/**
* Loads the given URL.

View File

@ -41,6 +41,39 @@
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,"",__VA_ARGS__)
static const std::string s_defaultBaseUrl = "file:///android_asset/";
static const std::string s_sdRootBaseUrl = "file://";
static std::string getFixedBaseUrl(const std::string& baseUrl)
{
std::string fixedBaseUrl;
if (baseUrl.empty())
{
fixedBaseUrl = s_defaultBaseUrl;
}
else if (baseUrl.find(s_sdRootBaseUrl) != std::string::npos)
{
fixedBaseUrl = baseUrl;
}
else if (baseUrl.c_str()[0] != '/') {
if(baseUrl.find("assets/") == 0) {
fixedBaseUrl = s_defaultBaseUrl + baseUrl.c_str()[7];
}
else {
fixedBaseUrl = s_defaultBaseUrl + baseUrl;
}
}
else {
fixedBaseUrl = s_sdRootBaseUrl + baseUrl;
}
if (fixedBaseUrl.c_str()[fixedBaseUrl.length() - 1] != '/') {
fixedBaseUrl += "/";
}
return fixedBaseUrl;
}
extern "C" {
/*
* Class: org_cocos2dx_lib_Cocos2dxWebViewHelper
@ -144,7 +177,7 @@ void loadDataJNI(const int index, const std::string &data, const std::string &MI
jstring jData = t.env->NewStringUTF(data.c_str());
jstring jMIMEType = t.env->NewStringUTF(MIMEType.c_str());
jstring jEncoding = t.env->NewStringUTF(encoding.c_str());
jstring jBaseURL = t.env->NewStringUTF(baseURL.c_str());
jstring jBaseURL = t.env->NewStringUTF(getFixedBaseUrl(baseURL).c_str());
t.env->CallStaticVoidMethod(t.classID, t.methodID, index, jData, jMIMEType, jEncoding, jBaseURL);
t.env->DeleteLocalRef(jData);
@ -158,10 +191,10 @@ void loadDataJNI(const int index, const std::string &data, const std::string &MI
void loadHTMLStringJNI(const int index, const std::string &string, const std::string &baseURL) {
// LOGD("error: %s,%d",__func__,__LINE__);
cocos2d::JniMethodInfo t;
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "loadHTMLString", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V")) {
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "loadHTMLString", "(ILjava/lang/String;Ljava/lang/String;)V")) {
jstring jString = t.env->NewStringUTF(string.c_str());
jstring jBaseURL = t.env->NewStringUTF(baseURL.c_str());
t.env->CallStaticVoidMethod(t.classID, t.methodID, index, jString, jBaseURL,nullptr);
jstring jBaseURL = t.env->NewStringUTF(getFixedBaseUrl(baseURL).c_str());
t.env->CallStaticVoidMethod(t.classID, t.methodID, index, jString, jBaseURL);
t.env->DeleteLocalRef(jString);
t.env->DeleteLocalRef(jBaseURL);

View File

@ -34,6 +34,30 @@
#include "platform/CCFileUtils.h"
#include "ui/UIWebView.h"
static std::string getFixedBaseUrl(const std::string& baseUrl)
{
std::string fixedBaseUrl;
if (baseUrl.empty() || baseUrl.c_str()[0] != '/') {
fixedBaseUrl = [[[NSBundle mainBundle] resourcePath] UTF8String];
fixedBaseUrl += "/";
fixedBaseUrl += baseUrl;
}
else {
fixedBaseUrl = baseUrl;
}
size_t pos = 0;
while ((pos = fixedBaseUrl.find(" ")) != std::string::npos) {
fixedBaseUrl.replace(pos, 1, "%20");
}
if (fixedBaseUrl.c_str()[fixedBaseUrl.length() - 1] != '/') {
fixedBaseUrl += "/";
}
return fixedBaseUrl;
}
@interface UIWebViewWrapper : NSObject
@property (nonatomic) std::function<bool(std::string url)> shouldStartLoading;
@property (nonatomic) std::function<void(std::string url)> didFinishLoading;
@ -136,11 +160,11 @@
[self.uiWebView loadData:[NSData dataWithBytes:data.c_str() length:data.length()]
MIMEType:@(MIMEType.c_str())
textEncodingName:@(encodingName.c_str())
baseURL:[NSURL URLWithString:@(baseURL.c_str())]];
baseURL:[NSURL URLWithString:@(getFixedBaseUrl(baseURL).c_str())]];
}
- (void)loadHTMLString:(const std::string &)string baseURL:(const std::string &)baseURL {
[self.uiWebView loadHTMLString:@(string.c_str()) baseURL:[NSURL URLWithString:@(baseURL.c_str())]];
[self.uiWebView loadHTMLString:@(string.c_str()) baseURL:[NSURL URLWithString:@(getFixedBaseUrl(baseURL).c_str())]];
}
- (void)loadUrl:(const std::string &)urlString {

View File

@ -823,7 +823,7 @@ void AssetsManagerEx::onProgress(double total, double downloaded, const std::str
{
if (customId == VERSION_ID || customId == MANIFEST_ID)
{
_percent = 100 * (total - downloaded) / total;
_percent = 100 * downloaded / total;
// Notify progression event
dispatchUpdateEvent(EventAssetsManagerEx::EventCode::UPDATE_PROGRESSION, customId);
return;
@ -865,7 +865,7 @@ void AssetsManagerEx::onProgress(double total, double downloaded, const std::str
if ((int)currentPercent != (int)_percent) {
_percent = currentPercent;
// Notify progression event
dispatchUpdateEvent(EventAssetsManagerEx::EventCode::UPDATE_PROGRESSION, "");
dispatchUpdateEvent(EventAssetsManagerEx::EventCode::UPDATE_PROGRESSION, customId);
}
}
}

View File

@ -52,7 +52,7 @@ size_t bufferWriteFunc(void *ptr, size_t size, size_t nmemb, void *userdata)
Downloader::StreamData *streamBuffer = (Downloader::StreamData *)userdata;
size_t written = size * nmemb;
// Avoid pointer overflow
if (streamBuffer->offset + written <= streamBuffer->total)
if (streamBuffer->offset + written <= static_cast<size_t>(streamBuffer->total))
{
memcpy(streamBuffer->buffer + streamBuffer->offset, ptr, written);
streamBuffer->offset += written;

Some files were not shown because too many files have changed in this diff Show More