diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 9e5939c9b8..d0ac089972 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -658,11 +658,11 @@ void Armature::setBody(b2Body *body) _body = body; _body->SetUserData(this); - for(auto& object : *_children) + for(auto& object : _children) { if (Bone *bone = dynamic_cast(object)) { - Array *displayList = bone->getDisplayManager()->getDecorativeDisplayList(); + auto displayList = bone->getDisplayManager()->getDecorativeDisplayList(); for(auto displayObject : displayList) { @@ -708,18 +708,18 @@ void Armature::setBody(cpBody *body) { if (Bone *bone = dynamic_cast(object)) { - Array *displayList = bone->getDisplayManager()->getDecorativeDisplayList(); + auto displayList = bone->getDisplayManager()->getDecorativeDisplayList(); - for_each(displayList->begin(), displayList->end(), [&_body](DecorativeDisplay* displayObject) + for_each(displayList.begin(), displayList.end(), [&body](DecorativeDisplay* displayObject) { ColliderDetector *detector = displayObject->getColliderDetector(); if (detector != nullptr) { - detector->setBody(_body); + detector->setBody(body); } }); } - }); + } } cpShape *Armature::getShapeList() diff --git a/cocos/editor-support/cocostudio/CCBone.cpp b/cocos/editor-support/cocostudio/CCBone.cpp index cfb0f9d907..1aadd0893c 100644 --- a/cocos/editor-support/cocostudio/CCBone.cpp +++ b/cocos/editor-support/cocostudio/CCBone.cpp @@ -462,9 +462,9 @@ ColliderDetector* Bone::getColliderDetector() const #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT void Bone::setColliderFilter(ColliderFilter *filter) { - Array *array = _displayManager->getDecorativeDisplayList(); + auto array = _displayManager->getDecorativeDisplayList(); - for(auto& object : *array) + for(auto& object : array) { DecorativeDisplay *decoDisplay = static_cast(object); if (ColliderDetector *detector = decoDisplay->getColliderDetector()) diff --git a/cocos/editor-support/cocostudio/CCColliderDetector.cpp b/cocos/editor-support/cocostudio/CCColliderDetector.cpp index 1624bc8491..d07397e65b 100644 --- a/cocos/editor-support/cocostudio/CCColliderDetector.cpp +++ b/cocos/editor-support/cocostudio/CCColliderDetector.cpp @@ -250,7 +250,7 @@ void ColliderDetector::setActive(bool active) } else { - for(auto& object : *_colliderBodyList) + for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; b2Fixture *fixture = colliderBody->getB2Fixture(); @@ -265,7 +265,7 @@ void ColliderDetector::setActive(bool active) { if (_active) { - for(auto& object : *_colliderBodyList) + for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; cpShape *shape = colliderBody->getShape(); @@ -277,7 +277,7 @@ void ColliderDetector::setActive(bool active) } else { - for(auto& object : *_colliderBodyList) + for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; cpShape *shape = colliderBody->getShape(); @@ -307,7 +307,7 @@ void ColliderDetector::setColliderFilter(ColliderFilter *filter) { *_filter = *filter; - for(auto& object : *_colliderBodyList) + for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; colliderBody->setColliderFilter(filter); @@ -396,7 +396,7 @@ void ColliderDetector::updateTransform(kmMat4 &t) } #if ENABLE_PHYSICS_CHIPMUNK_DETECT - cpConvexHull(num, shape->verts, nullptr, nullptr, 0); + cpConvexHull((int)num, shape->verts, nullptr, nullptr, 0); for (unsigned long i = 0; i < num; i++) { cpVect b = shape->verts[(i + 1) % shape->numVerts]; @@ -415,26 +415,23 @@ void ColliderDetector::setBody(b2Body *pBody) { _body = pBody; - for(auto& object : *_colliderBodyList) + for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; ContourData *contourData = colliderBody->getContourData(); - Array *array = &contourData->vertexList; - Object *object = nullptr; - + b2Vec2 *b2bv = new b2Vec2[contourData->vertexList.size()]; int i = 0; - for(auto& object : *array) + for(auto& v : contourData->vertexList) { - ContourVertex2 *v = (ContourVertex2 *)object; - b2bv[i].Set(v->x / PT_RATIO, v->y / PT_RATIO); + b2bv[i].Set(v.x / PT_RATIO, v.y / PT_RATIO); i++; } b2PolygonShape polygon; - polygon.Set(b2bv, contourData->vertexList.size()); + polygon.Set(b2bv, (int)contourData->vertexList.size()); CC_SAFE_DELETE(b2bv); @@ -465,22 +462,22 @@ void ColliderDetector::setBody(cpBody *pBody) { _body = pBody; - for(auto& object : *_colliderBodyList) + for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; ContourData *contourData = colliderBody->getContourData(); - int num = contourData->vertexList.count(); - ContourVertex2 **vs = (ContourVertex2 **)contourData->vertexList.data->arr; + ssize_t num = contourData->vertexList.size(); + auto vs = contourData->vertexList; cpVect *verts = new cpVect[num]; for (int i = 0; i < num; i++) { - verts[num - 1 - i].x = vs[i]->x; - verts[num - 1 - i].y = vs[i]->y; + verts[num - 1 - i].x = vs.at(i).x; + verts[num - 1 - i].y = vs.at(i).y; } - cpShape *shape = cpPolyShapeNew(_body, num, verts, cpvzero); + cpShape *shape = cpPolyShapeNew(_body, (int)num, verts, cpvzero); shape->sensor = true; shape->data = _bone; diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index d9ce7baaeb..5a80d77b24 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -888,7 +888,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) - cocos2d::Vector &frames = movBoneData->frameList; + auto frames = movBoneData->frameList; for (long j = movBoneData->frameList.size() - 1; j >= 0; j--) { if (j > 0) @@ -1513,7 +1513,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json, Dat if (dataInfo->cocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE) { //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) - cocos2d::Vector &frames = movementBoneData->frameList; + auto frames = movementBoneData->frameList; for (long i = frames.size() - 1; i >= 0; i--) { if (i > 0) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index ec71771d2a..5eea71f764 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -864,8 +864,7 @@ void TestColliderDetector::update(float delta) { Contact &contact = *it; - Bone *ba = (Bone *)contact.fixtureA->GetUserData(); - Bone *bb = (Bone *)contact.fixtureB->GetUserData(); + Bone *bb = static_cast(contact.fixtureB->GetUserData); bb->getArmature()->setVisible(false); }