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

Method collide

Engine/source/gui/worldEditor/terrainEditor.cpp:1177–1248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1175//------------------------------------------------------------------------------
1176
1177TerrainBlock* TerrainEditor::collide(const Gui3DMouseEvent & evt, Point3F & pos)
1178{
1179 PROFILE_SCOPE( TerrainEditor_Collide );
1180
1181 if (mTerrainBlocks.size() == 0)
1182 return NULL;
1183
1184 if ( mMouseDown && !String::compare(getCurrentAction(),"paintMaterial") )
1185 {
1186 if ( !mActiveTerrain )
1187 return NULL;
1188
1189 Point3F tpos, tvec;
1190
1191 tpos = evt.pos;
1192 tvec = evt.vec;
1193
1194 mMousePlane.intersect( evt.pos, evt.vec, &pos );
1195
1196 return mActiveTerrain;
1197 }
1198
1199 const U32 mask = TerrainObjectType;
1200
1201 Point3F start( evt.pos );
1202 Point3F end( evt.pos + ( evt.vec * 10000.0f ) );
1203
1204 RayInfo rinfo;
1205 bool hit = gServerContainer.castRay( start, end, mask, &rinfo );
1206
1207 if ( !hit )
1208 return NULL;
1209
1210 pos = rinfo.point;
1211
1212 return (TerrainBlock*)(rinfo.object);
1213
1214 //
1215 //// call the terrain block's ray collision routine directly
1216 //Point3F startPnt = event.pos;
1217 //Point3F endPnt = event.pos + event.vec * 1000.0f;
1218
1219 //S32 blockIndex = -1;
1220 //F32 nearT = 1.0f;
1221
1222 //for (U32 i = 0; i < mTerrainBlocks.size(); i++)
1223 //{
1224 // Point3F tStartPnt, tEndPnt;
1225
1226 // mTerrainBlocks[i]->getWorldTransform().mulP(startPnt, &tStartPnt);
1227 // mTerrainBlocks[i]->getWorldTransform().mulP(endPnt, &tEndPnt);
1228
1229 // RayInfo ri;
1230 // if (mTerrainBlocks[i]->castRayI(tStartPnt, tEndPnt, &ri, true))
1231 // {
1232 // if (ri.t < nearT)
1233 // {
1234 // blockIndex = i;

Callers

nothing calls this directly

Calls 4

compareFunction · 0.85
sizeMethod · 0.45
intersectMethod · 0.45
castRayMethod · 0.45

Tested by

no test coverage detected