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

Method clickOnLine

Engine/source/environment/meshRoad.cpp:283–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283S32 MeshRoadProfile::clickOnLine(Point3F &p)
284{
285 Point3F newProfilePt;
286 Point3F ptOnSegment;
287 F32 dist = 0.0f;
288 F32 minDist = 99999.0f;
289 U32 idx = 0;
290
291 for(U32 i=0; i < mNodes.size()-1; i++)
292 {
293 ptOnSegment = MathUtils::mClosestPointOnSegment(mNodes[i].getPosition(), mNodes[i+1].getPosition(), p);
294
295 dist = (p - ptOnSegment).len();
296
297 if(dist < minDist)
298 {
299 minDist = dist;
300 newProfilePt = ptOnSegment;
301 idx = i+1;
302 }
303 }
304
305 if(minDist <= 0.1f)
306 {
307 p.set(newProfilePt.x, newProfilePt.y, newProfilePt.z);
308
309 return idx;
310 }
311
312 return -1;
313}
314
315void MeshRoadProfile::addPoint(U32 nodeId, Point3F &p)
316{

Callers 1

on3DMouseDownMethod · 0.80

Calls 5

mClosestPointOnSegmentFunction · 0.85
sizeMethod · 0.45
getPositionMethod · 0.45
lenMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected