Differential D1739 Diff 5899 extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
Changeset View
Changeset View
Standalone View
Standalone View
extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
| void btHeightfieldTerrainShape::initialize | void btHeightfieldTerrainShape::initialize | ||||
| ( | ( | ||||
| int heightStickWidth, int heightStickLength, const void* heightfieldData, | int heightStickWidth, int heightStickLength, const void* heightfieldData, | ||||
| btScalar heightScale, btScalar minHeight, btScalar maxHeight, int upAxis, | btScalar heightScale, btScalar minHeight, btScalar maxHeight, int upAxis, | ||||
| PHY_ScalarType hdt, bool flipQuadEdges | PHY_ScalarType hdt, bool flipQuadEdges | ||||
| ) | ) | ||||
| { | { | ||||
| // validation | // validation | ||||
| btAssert(heightStickWidth > 1 && "bad width"); | btAssert(heightStickWidth > 1);// && "bad width"); | ||||
| btAssert(heightStickLength > 1 && "bad length"); | btAssert(heightStickLength > 1);// && "bad length"); | ||||
| btAssert(heightfieldData && "null heightfield data"); | btAssert(heightfieldData);// && "null heightfield data"); | ||||
| // btAssert(heightScale) -- do we care? Trust caller here | // btAssert(heightScale) -- do we care? Trust caller here | ||||
| btAssert(minHeight <= maxHeight && "bad min/max height"); | btAssert(minHeight <= maxHeight);// && "bad min/max height"); | ||||
| btAssert(upAxis >= 0 && upAxis < 3 && | btAssert(upAxis >= 0 && upAxis < 3);// && "bad upAxis--should be in range [0,2]"); | ||||
| "bad upAxis--should be in range [0,2]"); | btAssert(hdt != PHY_UCHAR || hdt != PHY_FLOAT || hdt != PHY_SHORT);// && "Bad height data type enum"); | ||||
| btAssert(hdt != PHY_UCHAR || hdt != PHY_FLOAT || hdt != PHY_SHORT && | |||||
| "Bad height data type enum"); | |||||
| // initialize member variables | // initialize member variables | ||||
| m_shapeType = TERRAIN_SHAPE_PROXYTYPE; | m_shapeType = TERRAIN_SHAPE_PROXYTYPE; | ||||
| m_heightStickWidth = heightStickWidth; | m_heightStickWidth = heightStickWidth; | ||||
| m_heightStickLength = heightStickLength; | m_heightStickLength = heightStickLength; | ||||
| m_minHeight = minHeight; | m_minHeight = minHeight; | ||||
| m_maxHeight = maxHeight; | m_maxHeight = maxHeight; | ||||
| m_width = (btScalar) (heightStickWidth - 1); | m_width = (btScalar) (heightStickWidth - 1); | ||||
| Show All 26 Lines | case 2: | ||||
| { | { | ||||
| m_localAabbMin.setValue(0, 0, m_minHeight); | m_localAabbMin.setValue(0, 0, m_minHeight); | ||||
| m_localAabbMax.setValue(m_width, m_length, m_maxHeight); | m_localAabbMax.setValue(m_width, m_length, m_maxHeight); | ||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| { | { | ||||
| //need to get valid m_upAxis | //need to get valid m_upAxis | ||||
| btAssert(0 && "Bad m_upAxis"); | btAssert(0);// && "Bad m_upAxis"); | ||||
| } | } | ||||
| } | } | ||||
| // remember origin (defined as exact middle of aabb) | // remember origin (defined as exact middle of aabb) | ||||
| m_localOrigin = btScalar(0.5) * (m_localAabbMin + m_localAabbMax); | m_localOrigin = btScalar(0.5) * (m_localAabbMin + m_localAabbMax); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const | ||||
| { | { | ||||
| for(int x=startX; x<endX; x++) | for(int x=startX; x<endX; x++) | ||||
| { | { | ||||
| btVector3 vertices[3]; | btVector3 vertices[3]; | ||||
| if (m_flipQuadEdges || (m_useDiamondSubdivision && !((j+x) & 1))|| (m_useZigzagSubdivision && !(j & 1))) | if (m_flipQuadEdges || (m_useDiamondSubdivision && !((j+x) & 1))|| (m_useZigzagSubdivision && !(j & 1))) | ||||
| { | { | ||||
| //first triangle | //first triangle | ||||
| getVertex(x,j,vertices[0]); | getVertex(x,j,vertices[0]); | ||||
| getVertex(x+1,j,vertices[1]); | getVertex(x, j + 1, vertices[1]); | ||||
| getVertex(x+1,j+1,vertices[2]); | getVertex(x + 1, j + 1, vertices[2]); | ||||
| callback->processTriangle(vertices,x,j); | callback->processTriangle(vertices,x,j); | ||||
| //second triangle | //second triangle | ||||
| // getVertex(x,j,vertices[0]);//already got this vertex before, thanks to Danny Chapman | // getVertex(x,j,vertices[0]);//already got this vertex before, thanks to Danny Chapman | ||||
| getVertex(x+1,j+1,vertices[1]); | getVertex(x+1,j+1,vertices[1]); | ||||
| getVertex(x,j+1,vertices[2]); | getVertex(x + 1, j, vertices[2]); | ||||
| callback->processTriangle(vertices,x,j); | callback->processTriangle(vertices, x, j); | ||||
| } else | } else | ||||
| { | { | ||||
| //first triangle | //first triangle | ||||
| getVertex(x,j,vertices[0]); | getVertex(x,j,vertices[0]); | ||||
| getVertex(x,j+1,vertices[1]); | getVertex(x,j+1,vertices[1]); | ||||
| getVertex(x+1,j,vertices[2]); | getVertex(x+1,j,vertices[2]); | ||||
| callback->processTriangle(vertices,x,j); | callback->processTriangle(vertices,x,j); | ||||
| //second triangle | //second triangle | ||||
| Show All 27 Lines | |||||