Skip to content

Commit

Permalink
!B (Sandbox) Fix inability to select entities by clicking on their ed…
Browse files Browse the repository at this point in the history
…itor-only helper object

Copied from Perforce
 Change: 1540579
  • Loading branch information
Cry-59 committed Aug 1, 2017
1 parent 9d7c338 commit 7c3c283
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions Code/Sandbox/Plugins/SmartObjectEditor/SmartObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,20 @@ bool CSmartObject::HitTest(HitContext& hc)
{
if (GetIStatObj())
{
float hitEpsilon = hc.view->GetScreenScaleFactor(GetWorldPos()) * 0.01f;
float hitDist;
Matrix34 invertedWorldTransform = GetWorldTM().GetInverted();

float fScale = GetScale().x;
AABB boxScaled;
GetLocalBounds(boxScaled);
boxScaled.min *= fScale;
boxScaled.max *= fScale;
Vec3 raySrc = invertedWorldTransform.TransformPoint(hc.raySrc);
Vec3 rayDir = invertedWorldTransform.TransformVector(hc.rayDir).GetNormalized();

Matrix34 invertWTM = GetWorldTM();
invertWTM.Invert();
SRayHitInfo hitInfo;
hitInfo.inReferencePoint = raySrc;
hitInfo.inRay = Ray(raySrc, rayDir);

Vec3 xformedRaySrc = invertWTM.TransformPoint(hc.raySrc);
Vec3 xformedRayDir = invertWTM.TransformVector(hc.rayDir);
xformedRayDir.Normalize();

Vec3 intPnt;
// Check intersection with bbox edges.
if (Intersect::Ray_AABBEdge(xformedRaySrc, xformedRayDir, boxScaled, hitEpsilon, hitDist, intPnt))
if (GetIStatObj()->RayIntersection(hitInfo))
{
hc.dist = xformedRaySrc.GetDistance(intPnt);
// World space distance.
Vec3 worldHitPos = GetWorldTM().TransformPoint(hitInfo.vHitPos);
hc.dist = hc.raySrc.GetDistance(worldHitPos);
hc.object = this;
return true;
}
Expand Down

0 comments on commit 7c3c283

Please sign in to comment.