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

Method _updateGeometry

Engine/source/T3D/portal.cpp:583–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

581//-----------------------------------------------------------------------------
582
583void Portal::_updateGeometry()
584{
585 const F32 boxHalfWidth = getScale().x * 0.5f;
586 const F32 boxHalfHeight = getScale().z * 0.5f;
587
588 const Point3F center = getTransform().getPosition();
589 const Point3F up = getTransform().getUpVector() * boxHalfHeight;
590 const Point3F right = getTransform().getRightVector() * boxHalfWidth;
591
592 // Update the portal polygon and plane.
593
594 if( mIsBox )
595 {
596 // It's a box so the portal polygon is a rectangle.
597 // Simply compute the corner points by stepping from the
598 // center to the corners using the up and right vector.
599
600 mPortalPolygonWS.setSize( 4 );
601
602 mPortalPolygonWS[ 0 ] = center + right - up; // bottom right
603 mPortalPolygonWS[ 1 ] = center - right - up; // bottom left
604 mPortalPolygonWS[ 2 ] = center - right + up; // top left
605 mPortalPolygonWS[ 3 ] = center + right + up; // top right
606
607 // Update the plane by going through three of the points.
608
609 mPortalPlane = PlaneF(
610 mPortalPolygonWS[ 0 ],
611 mPortalPolygonWS[ 1 ],
612 mPortalPolygonWS[ 2 ]
613 );
614 }
615 else
616 {
617 // It's not necessarily a box so we must use the general
618 // routine.
619
620 // Update the portal plane by building a plane that cuts the
621 // OBB in half vertically along its Y axis.
622
623 mPortalPlane = PlaneF(
624 center + right - up,
625 center - right - up,
626 center - right + up
627 );
628
629 // Slice the polyhedron along the same plane in object space.
630
631 const PlaneF slicePlane = PlaneF( Point3F::Zero, Point3F( 0.f, 1.f, 0.f ) );
632
633 mPortalPolygonWS.setSize( mPolyhedron.getNumEdges() );
634 U32 numPoints = mPolyhedron.constructIntersection( slicePlane, mPortalPolygonWS.address(), mPortalPolygonWS.size() );
635 mPortalPolygonWS.setSize( numPoints );
636
637 // Transform the polygon to world space.
638
639 for( U32 i = 0; i < numPoints; ++ i )
640 {

Callers 3

updateShapeMethod · 0.45
synchClientObjectMethod · 0.45
undoMethod · 0.45

Calls 12

getUpVectorMethod · 0.80
getRightVectorMethod · 0.80
constructIntersectionMethod · 0.80
mulPMethod · 0.80
PlaneFClass · 0.50
Point3FClass · 0.50
getPositionMethod · 0.45
setSizeMethod · 0.45
getNumEdgesMethod · 0.45
addressMethod · 0.45
sizeMethod · 0.45
convolveMethod · 0.45

Tested by

no test coverage detected