issue #2404: Fixing wrong replace in Box2d.

This commit is contained in:
James Chen 2013-07-18 13:39:55 +08:00
parent 469e13607a
commit c1dd874b9f
6 changed files with 27 additions and 27 deletions

View File

@ -91,7 +91,7 @@ void b2ChainShape::GetChildEdge(b2EdgeShape* edge, int32 index) const
edge->m_radius = m_radius;
edge->m_vertex1 = m_vertices[index + 0];
edge->m_Vertex2F = m_vertices[index + 1];
edge->m_vertex2 = m_vertices[index + 1];
if (index > 0)
{
@ -106,13 +106,13 @@ void b2ChainShape::GetChildEdge(b2EdgeShape* edge, int32 index) const
if (index < m_count - 2)
{
edge->m_Vertex3F = m_vertices[index + 2];
edge->m_hasVertex3F = true;
edge->m_vertex3 = m_vertices[index + 2];
edge->m_hasVertex3 = true;
}
else
{
edge->m_Vertex3F = m_nextVertex;
edge->m_hasVertex3F = m_hasNextVertex;
edge->m_vertex3 = m_nextVertex;
edge->m_hasVertex3 = m_hasNextVertex;
}
}
@ -138,7 +138,7 @@ bool b2ChainShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
}
edgeShape.m_vertex1 = m_vertices[i1];
edgeShape.m_Vertex2F = m_vertices[i2];
edgeShape.m_vertex2 = m_vertices[i2];
return edgeShape.RayCast(output, input, xf, 0);
}

View File

@ -23,9 +23,9 @@ using namespace std;
void b2EdgeShape::Set(const b2Vec2& v1, const b2Vec2& v2)
{
m_vertex1 = v1;
m_Vertex2F = v2;
m_vertex2 = v2;
m_hasVertex0 = false;
m_hasVertex3F = false;
m_hasVertex3 = false;
}
b2Shape* b2EdgeShape::Clone(b2BlockAllocator* allocator) const
@ -63,7 +63,7 @@ bool b2EdgeShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
b2Vec2 d = p2 - p1;
b2Vec2 v1 = m_vertex1;
b2Vec2 v2 = m_Vertex2F;
b2Vec2 v2 = m_vertex2;
b2Vec2 e = v2 - v1;
b2Vec2 normal(e.y, -e.x);
normal.Normalize();
@ -119,7 +119,7 @@ void b2EdgeShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIn
B2_NOT_USED(childIndex);
b2Vec2 v1 = b2Mul(xf, m_vertex1);
b2Vec2 v2 = b2Mul(xf, m_Vertex2F);
b2Vec2 v2 = b2Mul(xf, m_vertex2);
b2Vec2 lower = b2Min(v1, v2);
b2Vec2 upper = b2Max(v1, v2);
@ -134,6 +134,6 @@ void b2EdgeShape::ComputeMass(b2MassData* massData, float32 density) const
B2_NOT_USED(density);
massData->mass = 0.0f;
massData->center = 0.5f * (m_vertex1 + m_Vertex2F);
massData->center = 0.5f * (m_vertex1 + m_vertex2);
massData->I = 0.0f;
}

View File

@ -52,11 +52,11 @@ public:
void ComputeMass(b2MassData* massData, float32 density) const;
/// These are the edge vertices
b2Vec2 m_vertex1, m_Vertex2F;
b2Vec2 m_vertex1, m_vertex2;
/// Optional adjacent vertices. These are used for smooth collision.
b2Vec2 m_vertex0, m_Vertex3F;
bool m_hasVertex0, m_hasVertex3F;
b2Vec2 m_vertex0, m_vertex3;
bool m_hasVertex0, m_hasVertex3;
};
inline b2EdgeShape::b2EdgeShape()
@ -65,10 +65,10 @@ inline b2EdgeShape::b2EdgeShape()
m_radius = b2_polygonRadius;
m_vertex0.x = 0.0f;
m_vertex0.y = 0.0f;
m_Vertex3F.x = 0.0f;
m_Vertex3F.y = 0.0f;
m_vertex3.x = 0.0f;
m_vertex3.y = 0.0f;
m_hasVertex0 = false;
m_hasVertex3F = false;
m_hasVertex3 = false;
}
#endif

View File

@ -33,7 +33,7 @@ void b2CollideEdgeAndCircle(b2Manifold* manifold,
// Compute circle in frame of edge
b2Vec2 Q = b2MulT(xfA, b2Mul(xfB, circleB->m_p));
b2Vec2 A = edgeA->m_vertex1, B = edgeA->m_Vertex2F;
b2Vec2 A = edgeA->m_vertex1, B = edgeA->m_vertex2;
b2Vec2 e = B - A;
// Barycentric coordinates
@ -96,9 +96,9 @@ void b2CollideEdgeAndCircle(b2Manifold* manifold,
}
// Is there an edge connected to B?
if (edgeA->m_hasVertex3F)
if (edgeA->m_hasVertex3)
{
b2Vec2 B2 = edgeA->m_Vertex3F;
b2Vec2 B2 = edgeA->m_vertex3;
b2Vec2 A2 = B;
b2Vec2 e2 = B2 - A2;
float32 v2 = b2Dot(e2, Q - A2);
@ -236,11 +236,11 @@ void b2EPCollider::Collide(b2Manifold* manifold, const b2EdgeShape* edgeA, const
m_v0 = edgeA->m_vertex0;
m_v1 = edgeA->m_vertex1;
m_v2 = edgeA->m_Vertex2F;
m_v3 = edgeA->m_Vertex3F;
m_v2 = edgeA->m_vertex2;
m_v3 = edgeA->m_vertex3;
bool hasVertex0 = edgeA->m_hasVertex0;
bool hasVertex3F = edgeA->m_hasVertex3F;
bool hasVertex3F = edgeA->m_hasVertex3;
b2Vec2 edge1 = m_v2 - m_v1;
edge1.Normalize();

View File

@ -255,10 +255,10 @@ void b2Fixture::Dump(int32 bodyIndex)
b2Log(" shape.m_radius = %.15lef;\n", s->m_radius);
b2Log(" shape.m_vertex0.Set(%.15lef, %.15lef);\n", s->m_vertex0.x, s->m_vertex0.y);
b2Log(" shape.m_vertex1.Set(%.15lef, %.15lef);\n", s->m_vertex1.x, s->m_vertex1.y);
b2Log(" shape.m_Vertex2F.Set(%.15lef, %.15lef);\n", s->m_Vertex2F.x, s->m_Vertex2F.y);
b2Log(" shape.m_Vertex3F.Set(%.15lef, %.15lef);\n", s->m_Vertex3F.x, s->m_Vertex3F.y);
b2Log(" shape.m_vertex2.Set(%.15lef, %.15lef);\n", s->m_vertex2.x, s->m_vertex2.y);
b2Log(" shape.m_vertex3.Set(%.15lef, %.15lef);\n", s->m_vertex3.x, s->m_vertex3.y);
b2Log(" shape.m_hasVertex0 = bool(%d);\n", s->m_hasVertex0);
b2Log(" shape.m_hasVertex3F = bool(%d);\n", s->m_hasVertex3F);
b2Log(" shape.m_hasVertex3 = bool(%d);\n", s->m_hasVertex3);
}
break;

View File

@ -1048,7 +1048,7 @@ void b2World::DrawShape(b2Fixture* fixture, const b2Transform& xf, const b2Color
{
b2EdgeShape* edge = (b2EdgeShape*)fixture->GetShape();
b2Vec2 v1 = b2Mul(xf, edge->m_vertex1);
b2Vec2 v2 = b2Mul(xf, edge->m_Vertex2F);
b2Vec2 v2 = b2Mul(xf, edge->m_vertex2);
m_debugDraw->DrawSegment(v1, v2, color);
}
break;