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

Method setupVertexBlock

Engine/source/environment/waterBlock.cpp:191–310  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Set up a block of vertices - the width is always the width of the entire waterBlock, so this is a block of full rows. -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

189// waterBlock, so this is a block of full rows.
190//-----------------------------------------------------------------------------
191void WaterBlock::setupVertexBlock( U32 width, U32 height, U32 rowOffset )
192{
193 RayInfo rInfo;
194 VectorF sunVector(-0.61f, 0.354f, 0.707f);
195
196 if ( LIGHTMGR )
197 {
198 LightInfo* linfo = LIGHTMGR->getSpecialLight( LightManager::slSunLightType );
199 if ( linfo )
200 sunVector = linfo->getDirection();
201 }
202
203 sunVector.normalize();
204
205 U32 numVerts = width * height;
206
207 GFXWaterVertex *verts = new GFXWaterVertex[ numVerts ];
208
209 U32 index = 0;
210 for( U32 i=0; i<height; i++ )
211 {
212 for( U32 j=0; j<width; j++, index++ )
213 {
214 F32 vertX = getMin((-mObjScale.x / 2.0f) + mGridElementSize * j, mObjScale.x / 2.0f);
215 F32 vertY = getMin((-mObjScale.y / 2.0f) + mGridElementSize * (i + rowOffset), mObjScale.y / 2.0f);
216 GFXWaterVertex *vert = &verts[index];
217 vert->point.x = vertX;
218 vert->point.y = vertY;
219 vert->point.z = 0.0;
220 vert->normal.set(0,0,1);
221 vert->undulateData.set( vertX, vertY );
222 vert->horizonFactor.set( 0, 0, 0, 0 );
223
224 // Calculate the water depth
225
226 /*
227 vert->depthData.set( 0.0f, 0.0f );
228
229 Point3F start, end;
230 Point3F worldPoint = vert->point + pos;
231
232 start.x = end.x = worldPoint.x;
233 start.y = end.y = worldPoint.y;
234 start.z = -2000; // Really high, might be over kill
235 end.z = 2000; // really low, might be overkill
236
237 // Cast a ray to see how deep the water is. We are
238 // currently just testing for terrain and atlas
239 // objects, but potentially any object that responds
240 // to a ray cast could detected.
241 if(gClientContainer.castRay(start, end,
242 //StaticObjectType |
243 //InteriorObjectType |
244 //ShapeBaseObjectType |
245 //StaticShapeObjectType |
246 //ItemObjectType |
247 //StaticTSObjectType |
248 TerrainObjectType

Callers

nothing calls this directly

Calls 8

getSpecialLightMethod · 0.80
dMemcpyFunction · 0.50
getDirectionMethod · 0.45
normalizeMethod · 0.45
setMethod · 0.45
lockMethod · 0.45
unlockMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected