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

Method castRayI

Engine/source/terrain/terrCollision.cpp:647–764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

645}
646
647bool TerrainBlock::castRayI(const Point3F &start, const Point3F &end, RayInfo *info, bool collideEmpty)
648{
649 lineCount = 0;
650 lineStart = start;
651 lineEnd = end;
652
653 info->object = this;
654
655 if(start.x == end.x && start.y == end.y)
656 {
657 if (end.z == start.z)
658 return false;
659
660 F32 height;
661 if(!getNormalAndHeight(Point2F(start.x, start.y), &info->normal, &height, true))
662 return false;
663
664 F32 t = (height - start.z) / (end.z - start.z);
665 if(t < 0 || t > 1)
666 return false;
667 info->t = t;
668
669 return true;
670 }
671
672 F32 invBlockWorldSize = 1 / getWorldBlockSize();
673
674 Point3F pStart(start.x * invBlockWorldSize, start.y * invBlockWorldSize, start.z);
675 Point3F pEnd(end.x * invBlockWorldSize, end.y * invBlockWorldSize, end.z);
676
677 S32 blockX = (S32)mFloor(pStart.x);
678 S32 blockY = (S32)mFloor(pStart.y);
679
680 S32 dx, dy;
681
682 F32 invDeltaX;
683 if(pEnd.x == pStart.x)
684 {
685 calcInterceptX = calcInterceptNone;
686 invDeltaX = 0;
687 dx = 0;
688 }
689 else
690 {
691 invDeltaX = 1 / (pEnd.x - pStart.x);
692 calcInterceptX = calcInterceptV;
693 if(pEnd.x < pStart.x)
694 dx = -1;
695 else
696 dx = 1;
697 }
698
699 F32 invDeltaY;
700 if(pEnd.y == pStart.y)
701 {
702 calcInterceptY = calcInterceptNone;
703 invDeltaY = 0;
704 dy = 0;

Callers 2

Calls 4

mFloorFunction · 0.85
Point2FClass · 0.50
Point2IClass · 0.50
normalizeMethod · 0.45

Tested by

no test coverage detected