MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / initPhysics

Method initPhysics

examples/SoftDemo/SoftDemo.cpp:2030–2223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2028#endif
2029
2030void SoftDemo::initPhysics()
2031{
2032 ///create concave ground mesh
2033
2034 m_guiHelper->setUpAxis(1);
2035 // m_azi = 0;
2036
2037 //reset and disable motorcontrol at the start
2038 motorcontrol.goal = 0;
2039 motorcontrol.maxtorque = 0;
2040
2041 btCollisionShape* groundShape = 0;
2042 {
2043 int i;
2044 int j;
2045
2046 const int NUM_VERTS_X = 30;
2047 const int NUM_VERTS_Y = 30;
2048 const int totalVerts = NUM_VERTS_X * NUM_VERTS_Y;
2049 const int totalTriangles = 2 * (NUM_VERTS_X - 1) * (NUM_VERTS_Y - 1);
2050
2051 gGroundVertices = new btVector3[totalVerts];
2052 gGroundIndices = new int[totalTriangles * 3];
2053
2054 btScalar offset(-50);
2055
2056 for (i = 0; i < NUM_VERTS_X; i++)
2057 {
2058 for (j = 0; j < NUM_VERTS_Y; j++)
2059 {
2060 gGroundVertices[i + j * NUM_VERTS_X].setValue((i - NUM_VERTS_X * 0.5f) * TRIANGLE_SIZE,
2061 //0.f,
2062 waveheight * sinf((float)i) * cosf((float)j + offset),
2063 (j - NUM_VERTS_Y * 0.5f) * TRIANGLE_SIZE);
2064 }
2065 }
2066
2067 int vertStride = sizeof(btVector3);
2068 int indexStride = 3 * sizeof(int);
2069
2070 int index = 0;
2071 for (i = 0; i < NUM_VERTS_X - 1; i++)
2072 {
2073 for (int j = 0; j < NUM_VERTS_Y - 1; j++)
2074 {
2075 gGroundIndices[index++] = j * NUM_VERTS_X + i;
2076 gGroundIndices[index++] = (j + 1) * NUM_VERTS_X + i + 1;
2077 gGroundIndices[index++] = j * NUM_VERTS_X + i + 1;
2078 ;
2079
2080 gGroundIndices[index++] = j * NUM_VERTS_X + i;
2081 gGroundIndices[index++] = (j + 1) * NUM_VERTS_X + i;
2082 gGroundIndices[index++] = (j + 1) * NUM_VERTS_X + i + 1;
2083 }
2084 }
2085
2086 btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles,
2087 gGroundIndices,

Callers 5

mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
BInitMethod · 0.45
mainFunction · 0.45

Calls 15

btVector3Class · 0.50
initCLFunction · 0.50
setUpAxisMethod · 0.45
setValueMethod · 0.45
xMethod · 0.45
setMarginMethod · 0.45
push_backMethod · 0.45
setIdentityMethod · 0.45
addChildShapeMethod · 0.45
setRotationMethod · 0.45
setGravityMethod · 0.45

Tested by

no test coverage detected