MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / addTrees

Method addTrees

deps/physx/physx/samples/samplelargeworld/ChunkLoader.cpp:230–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230void SampleLargeWorld::addTrees(const PxTriangleMeshGeometry& meshGeom, const PxBounds3& bound, PxCollection& outCollection)
231{
232 const char* filename = getSampleMediaFilename("tree.obj");
233 const char* filenameCooked = getSampleOutputFilePath("tree.obj", "");
234
235 PxReal maxDist = 2*(bound.maximum.y - bound.minimum.y);
236 for(PxU32 i = (PxU32)bound.minimum.z; i < (PxU32)bound.maximum.z; i += 80)
237 {
238 PxVec3 rayStart(bound.minimum.x, bound.maximum.y, (PxReal)i);
239
240 PxRaycastBuffer hit;
241 PxQueryFilterData filter(PxQueryFlag::eSTATIC);
242 PxScene& scene = getActiveScene();
243 bool ret = false;
244 {
245 PxSceneReadLock scopedLock(scene);
246 ret = scene.raycast(rayStart, PxVec3(0.0f,-1.0f,0.0f), maxDist, hit, PxHitFlag::ePOSITION, filter);
247 }
248 if( ret )
249 {
250 MeshBuilder::addObjMeshToPxCollection(
251 getPhysics(), getCooking(), getDefaultMaterial(),
252 filename, filenameCooked,
253 PxTransform(hit.block.position, PxQuat(-PxHalfPi, PxVec3(1,0,0))), PxVec3(200, 200, 200),
254 outCollection, gTreeName);
255
256 }
257 }
258
259}
260
261static void flattenChunk(SampleArray<PxVec3>& terrainVertices, const PxBounds3& bound, PxReal dataY)
262{

Callers

nothing calls this directly

Calls 5

getSampleMediaFilenameFunction · 0.85
PxVec3Class · 0.50
PxTransformClass · 0.50
PxQuatClass · 0.50
raycastMethod · 0.45

Tested by

no test coverage detected