MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / buildBridge

Function buildBridge

physx/samples/samplebridges/SampleBridges.cpp:180–309  ·  view source on GitHub ↗

PT: TODO: share this function with original code in Visual Tests?

Source from the content-addressed store, hash-verified

178
179// PT: TODO: share this function with original code in Visual Tests?
180static void buildBridge(PxScene& scene, PxPhysics& physics, PxMaterial& material, std::vector<PxRigidActor*>& actors, std::vector<PxJoint*>& joints, const PxTransform& tr, PxReal scale, BridgeJoint type)
181{
182 const PxVec3 offset(0,0,0);
183
184 const PxReal groundLength = 5.0f;
185 const PxReal groundHeight = 5.0f;
186
187 // create ground under character
188 if(1)
189 {
190 PxTransform boxPose = tr * PxTransform(PxVec3(0.0f, -groundHeight, -10.0f-groundLength)*scale, PxQuat(PxIdentity));
191 boxPose.p += offset;
192
193 const PxVec3 boxSize = PxVec3(1.0f, groundHeight, groundLength) * scale;
194 PxRigidActor* box = createBox(scene, physics, boxPose, boxSize, 0.0f, material, NULL, 0);
195 actors.push_back(box);
196 }
197
198 // create bridge...
199 if(1)
200 {
201 const PxReal plankWidth = 1.0f;
202 const PxReal plankHeight = 0.02f;
203 const PxReal plankDepth = 0.5f;
204 const PxReal plankDensity = 0.03f;
205// const PxReal plankDensity = 0.3f;
206 PxRigidDynamic* lastPlank = 0;
207
208 for(PxReal z = -10.0f+plankDepth; z<10.0f; z+= plankDepth*2)
209 {
210 const PxVec3 boxSize = PxVec3(plankWidth, plankHeight, plankDepth) * scale;
211
212 PxTransform boxPose = tr * PxTransform(PxVec3(0,-plankHeight,z)*scale);
213
214 PxRigidDynamic* plank = createBox(scene, physics, boxPose, boxSize, plankDensity, material, NULL, 0)->is<PxRigidDynamic>();
215 if(plank)
216 {
217#ifdef CCT_ON_BRIDGES
218 plank->setName(gPlankName);
219#endif
220 actors.push_back(plank);
221
222 //plank->setSolverIterationCounts(1, 1);
223// plank->setSolverIterationCounts(255, 255);
224// plank->setSolverIterationCounts(10, 10);
225 plank->setSolverIterationCounts(8, 8);
226 plank->setLinearDamping(1.0f);
227 plank->setAngularDamping(1.0f);
228// plank->putToSleep();
229
230 if(!lastPlank)
231 {
232 // plank = first plank...
233 plank->setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, true);
234 }
235 else
236 {
237 // joint together plank and lastPlank...

Callers 1

newShapeMethod · 0.85

Calls 12

setRigidBodyFlagMethod · 0.80
createBoxFunction · 0.70
PxTransformClass · 0.50
PxVec3Class · 0.50
PxQuatClass · 0.50
setNameMethod · 0.45
setLinearDampingMethod · 0.45
setAngularDampingMethod · 0.45
sizeMethod · 0.45
setBreakForceMethod · 0.45

Tested by

no test coverage detected