MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / SqrDistancePointToSegment

Function SqrDistancePointToSegment

ogsr_engine/xrGame/Level_Bullet_Manager.cpp:283–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281#endif
282
283float SqrDistancePointToSegment(const Fvector& pt, const Fvector& orig, const Fvector& dir)
284{
285 Fvector diff;
286 diff.sub(pt, orig);
287 float fT = diff.dotproduct(dir);
288
289 if (fT <= 0.0f)
290 {
291 fT = 0.0f;
292 }
293 else
294 {
295 float fSqrLen = dir.square_magnitude();
296 if (fT >= fSqrLen)
297 {
298 fT = 1.0f;
299 diff.sub(dir);
300 }
301 else
302 {
303 fT /= fSqrLen;
304 diff.sub(Fvector().mul(dir, fT));
305 }
306 }
307
308 return diff.square_magnitude();
309}
310
311void CBulletManager::Render()
312{

Callers 1

RenderMethod · 0.85

Calls 4

subMethod · 0.45
dotproductMethod · 0.45
square_magnitudeMethod · 0.45
mulMethod · 0.45

Tested by

no test coverage detected