fixed compile error

This commit is contained in:
yinkaile 2013-12-18 22:36:10 +08:00
parent d3a575e8cc
commit 57c33e0604
5 changed files with 27 additions and 31 deletions

View File

@ -658,11 +658,11 @@ void Armature::setBody(b2Body *body)
_body = body; _body = body;
_body->SetUserData(this); _body->SetUserData(this);
for(auto& object : *_children) for(auto& object : _children)
{ {
if (Bone *bone = dynamic_cast<Bone *>(object)) if (Bone *bone = dynamic_cast<Bone *>(object))
{ {
Array *displayList = bone->getDisplayManager()->getDecorativeDisplayList(); auto displayList = bone->getDisplayManager()->getDecorativeDisplayList();
for(auto displayObject : displayList) for(auto displayObject : displayList)
{ {
@ -708,18 +708,18 @@ void Armature::setBody(cpBody *body)
{ {
if (Bone *bone = dynamic_cast<Bone *>(object)) if (Bone *bone = dynamic_cast<Bone *>(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(); ColliderDetector *detector = displayObject->getColliderDetector();
if (detector != nullptr) if (detector != nullptr)
{ {
detector->setBody(_body); detector->setBody(body);
} }
}); });
} }
}); }
} }
cpShape *Armature::getShapeList() cpShape *Armature::getShapeList()

View File

@ -462,9 +462,9 @@ ColliderDetector* Bone::getColliderDetector() const
#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT
void Bone::setColliderFilter(ColliderFilter *filter) 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<DecorativeDisplay *>(object); DecorativeDisplay *decoDisplay = static_cast<DecorativeDisplay *>(object);
if (ColliderDetector *detector = decoDisplay->getColliderDetector()) if (ColliderDetector *detector = decoDisplay->getColliderDetector())

View File

@ -250,7 +250,7 @@ void ColliderDetector::setActive(bool active)
} }
else else
{ {
for(auto& object : *_colliderBodyList) for(auto& object : _colliderBodyList)
{ {
ColliderBody *colliderBody = (ColliderBody *)object; ColliderBody *colliderBody = (ColliderBody *)object;
b2Fixture *fixture = colliderBody->getB2Fixture(); b2Fixture *fixture = colliderBody->getB2Fixture();
@ -265,7 +265,7 @@ void ColliderDetector::setActive(bool active)
{ {
if (_active) if (_active)
{ {
for(auto& object : *_colliderBodyList) for(auto& object : _colliderBodyList)
{ {
ColliderBody *colliderBody = (ColliderBody *)object; ColliderBody *colliderBody = (ColliderBody *)object;
cpShape *shape = colliderBody->getShape(); cpShape *shape = colliderBody->getShape();
@ -277,7 +277,7 @@ void ColliderDetector::setActive(bool active)
} }
else else
{ {
for(auto& object : *_colliderBodyList) for(auto& object : _colliderBodyList)
{ {
ColliderBody *colliderBody = (ColliderBody *)object; ColliderBody *colliderBody = (ColliderBody *)object;
cpShape *shape = colliderBody->getShape(); cpShape *shape = colliderBody->getShape();
@ -307,7 +307,7 @@ void ColliderDetector::setColliderFilter(ColliderFilter *filter)
{ {
*_filter = *filter; *_filter = *filter;
for(auto& object : *_colliderBodyList) for(auto& object : _colliderBodyList)
{ {
ColliderBody *colliderBody = (ColliderBody *)object; ColliderBody *colliderBody = (ColliderBody *)object;
colliderBody->setColliderFilter(filter); colliderBody->setColliderFilter(filter);
@ -396,7 +396,7 @@ void ColliderDetector::updateTransform(kmMat4 &t)
} }
#if ENABLE_PHYSICS_CHIPMUNK_DETECT #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++) for (unsigned long i = 0; i < num; i++)
{ {
cpVect b = shape->verts[(i + 1) % shape->numVerts]; cpVect b = shape->verts[(i + 1) % shape->numVerts];
@ -415,26 +415,23 @@ void ColliderDetector::setBody(b2Body *pBody)
{ {
_body = pBody; _body = pBody;
for(auto& object : *_colliderBodyList) for(auto& object : _colliderBodyList)
{ {
ColliderBody *colliderBody = (ColliderBody *)object; ColliderBody *colliderBody = (ColliderBody *)object;
ContourData *contourData = colliderBody->getContourData(); ContourData *contourData = colliderBody->getContourData();
Array *array = &contourData->vertexList;
Object *object = nullptr;
b2Vec2 *b2bv = new b2Vec2[contourData->vertexList.size()]; b2Vec2 *b2bv = new b2Vec2[contourData->vertexList.size()];
int i = 0; 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++; i++;
} }
b2PolygonShape polygon; b2PolygonShape polygon;
polygon.Set(b2bv, contourData->vertexList.size()); polygon.Set(b2bv, (int)contourData->vertexList.size());
CC_SAFE_DELETE(b2bv); CC_SAFE_DELETE(b2bv);
@ -465,22 +462,22 @@ void ColliderDetector::setBody(cpBody *pBody)
{ {
_body = pBody; _body = pBody;
for(auto& object : *_colliderBodyList) for(auto& object : _colliderBodyList)
{ {
ColliderBody *colliderBody = (ColliderBody *)object; ColliderBody *colliderBody = (ColliderBody *)object;
ContourData *contourData = colliderBody->getContourData(); ContourData *contourData = colliderBody->getContourData();
int num = contourData->vertexList.count(); ssize_t num = contourData->vertexList.size();
ContourVertex2 **vs = (ContourVertex2 **)contourData->vertexList.data->arr; auto vs = contourData->vertexList;
cpVect *verts = new cpVect[num]; cpVect *verts = new cpVect[num];
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
{ {
verts[num - 1 - i].x = vs[i]->x; verts[num - 1 - i].x = vs.at(i).x;
verts[num - 1 - i].y = vs[i]->y; 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->sensor = true;
shape->data = _bone; shape->data = _bone;

View File

@ -888,7 +888,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity) //! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
cocos2d::Vector<FrameData*> &frames = movBoneData->frameList; auto frames = movBoneData->frameList;
for (long j = movBoneData->frameList.size() - 1; j >= 0; j--) for (long j = movBoneData->frameList.size() - 1; j >= 0; j--)
{ {
if (j > 0) if (j > 0)
@ -1513,7 +1513,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json, Dat
if (dataInfo->cocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE) if (dataInfo->cocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE)
{ {
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity) //! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
cocos2d::Vector<FrameData *> &frames = movementBoneData->frameList; auto frames = movementBoneData->frameList;
for (long i = frames.size() - 1; i >= 0; i--) for (long i = frames.size() - 1; i >= 0; i--)
{ {
if (i > 0) if (i > 0)

View File

@ -864,8 +864,7 @@ void TestColliderDetector::update(float delta)
{ {
Contact &contact = *it; Contact &contact = *it;
Bone *ba = (Bone *)contact.fixtureA->GetUserData(); Bone *bb = static_cast<Bone *>(contact.fixtureB->GetUserData);
Bone *bb = (Bone *)contact.fixtureB->GetUserData();
bb->getArmature()->setVisible(false); bb->getArmature()->setVisible(false);
} }