MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _generateVerts

Method _generateVerts

Engine/source/environment/meshRoad.cpp:2548–3166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2546}
2547
2548void MeshRoad::_generateVerts()
2549{
2550 const U32 widthDivisions = getMax( 0, mWidthSubdivisions );
2551 const F32 divisionStep = 1.0f / (F32)( widthDivisions + 1 );
2552 const U32 sliceCount = mSlices.size();
2553 const U32 segmentCount = mSegments.size();
2554
2555 U32 numProfSide, numProfTop, numProfBottom;
2556
2557 numProfSide = numProfTop = numProfBottom = 0;
2558
2559 // Find how many profile segments are set to side, top, and bottom materials
2560 for ( U32 i = 0; i < mSideProfile.mSegMtrls.size(); i++)
2561 {
2562 switch(mSideProfile.mSegMtrls[i])
2563 {
2564 case Side: numProfSide++; break;
2565 case Top: numProfTop++; break;
2566 case Bottom: numProfBottom++; break;
2567 }
2568 }
2569
2570 F32 profLen = mSideProfile.getProfileLen();
2571
2572 mVertCount[Top] = ( 2 + widthDivisions ) * sliceCount;
2573 mVertCount[Top] += sliceCount * numProfTop * 4;
2574 mTriangleCount[Top] = segmentCount * 2 * ( widthDivisions + 1 );
2575 mTriangleCount[Top] += segmentCount * numProfTop * 4;
2576
2577 mVertCount[Bottom] = sliceCount * 2;
2578 mVertCount[Bottom] += sliceCount * numProfBottom * 4;
2579 mTriangleCount[Bottom] = segmentCount * 2;
2580 mTriangleCount[Bottom] += segmentCount * numProfBottom * 4;
2581
2582 mVertCount[Side] = sliceCount * numProfSide * 4; // side verts
2583 mVertCount[Side] += mSideProfile.mNodes.size() * 4; // end cap verts
2584 mTriangleCount[Side] = segmentCount * numProfSide * 4; // side tris
2585 mTriangleCount[Side] += mSideProfile.mCap.getNumTris() * 2; // end cap tris
2586
2587 // Calculate TexCoords for Slices
2588
2589 F32 texCoordV = 0.0f;
2590 mSlices[0].texCoordV = 0.0f;
2591
2592 for ( U32 i = 1; i < sliceCount; i++ )
2593 {
2594 MeshRoadSlice &slice = mSlices[i];
2595 MeshRoadSlice &prevSlice = mSlices[i-1];
2596
2597 // Increment the textCoordV for the next slice.
2598 F32 len = ( slice.p1 - prevSlice.p1 ).len();
2599 texCoordV += len / mTextureLength;
2600
2601 slice.texCoordV = texCoordV;
2602 }
2603
2604 // Make Vertex Buffers
2605 GFXVertexPNTT *pVert = NULL;

Callers

nothing calls this directly

Calls 12

getMaxFunction · 0.85
getProfileLenMethod · 0.80
getNumTrisMethod · 0.80
getNodePosPercentMethod · 0.80
getTriIdxMethod · 0.80
sizeMethod · 0.45
lenMethod · 0.45
setMethod · 0.45
lockMethod · 0.45
interpolateMethod · 0.45
unlockMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected