本文整理汇总了C++中Portal::getSideRelativeToPortalPlane方法的典型用法代码示例。如果您正苦于以下问题:C++ Portal::getSideRelativeToPortalPlane方法的具体用法?C++ Portal::getSideRelativeToPortalPlane怎么用?C++ Portal::getSideRelativeToPortalPlane使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portal
的用法示例。
在下文中一共展示了Portal::getSideRelativeToPortalPlane方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _traverseConnectedZoneSpaces
void Portal::_traverseConnectedZoneSpaces( SceneTraversalState* state )
{
PROFILE_SCOPE( Portal_traverseConnectedZoneSpaces );
// Don't traverse out from the portal if it is invalid.
if( mClassification == InvalidPortal )
return;
AssertFatal( !mIsGeometryDirty, "Portal::_traverseConnectedZoneSpaces - Geometry not up-to-date!" );
// When starting traversal within a portal zone, we cannot really use the portal
// plane itself to direct our visibility queries. For example, the camera might
// actually be located in front of the portal plane and thus cannot actually look
// through the portal, though it will still see what lies on front of where the
// portal leads.
//
// So if we're the start of the traversal chain, i.e. the traversal has started
// out in the portal zone, then just put the traversal through to SceneZoneSpace
// so it can hand it over to all connected zone managers.
//
// Otherwise, just do a normal traversal by stepping through the portal.
if( state->getTraversalDepth() == 1 )
{
Parent::_traverseConnectedZoneSpaces( state );
return;
}
SceneCullingState* cullingState = state->getCullingState();
const SceneCameraState& cameraState = cullingState->getCameraState();
// Get the data of the zone we're coming from. Note that at this point
// the portal zone itself is already on top of the traversal stack, so
// we skip over the bottom-most entry.
const U32 sourceZoneId = state->getZoneIdFromStack( 1 );
const SceneZoneSpace* sourceZoneSpace = state->getZoneFromStack( 1 );
// Find out which side of the portal we are on given the
// source zone.
const Portal::Side currentZoneSide =
sourceZoneId == SceneZoneSpaceManager::RootZoneId
? ( getInteriorSideOfExteriorPortal() == FrontSide ? BackSide : FrontSide )
: getSideRelativeToPortalPlane( sourceZoneSpace->getPosition() );
// Don't step through portal if the side we're interested in isn't passable.
if( !isSidePassable( currentZoneSide ) )
return;
// If the viewpoint isn't on the same side of the portal as the source zone,
// then stepping through the portal would mean we are stepping back towards
// the viewpoint which doesn't make sense; so, skip the portal.
const Point3F& viewPos = cameraState.getViewPosition();
const F32 viewPosDistToPortal = mFabs( getPortalPlane().distToPlane( viewPos ) );
if( !mIsZero( viewPosDistToPortal ) && getSideRelativeToPortalPlane( viewPos ) != currentZoneSide )
return;
// Before we go ahead and do the real work, try to find out whether
// the portal is at a perpendicular or near-perpendicular angle to the view
// direction. If so, there's no point in going further since we can't really
// see much through the portal anyway. It also prevents us from stepping
// over front/back side ambiguities.
Point3F viewDirection = cameraState.getViewDirection();
const F32 dotProduct = mDot( viewDirection, getPortalPlane() );
if( mIsZero( dotProduct ) )
return;
// Finally, if we have come through a portal to the current zone, check if the target
// portal we are trying to step through now completely lies on the "backside"--i.e.
// the side of portal on which our current zone lies--of the source portal. If so,
// we can be sure this portal leads us in the wrong direction. This prevents the
// outdoor zone from having just arrived through a window on one side of a house just
// to go round the house and re-enter it from the other side.
Portal* sourcePortal = state->getTraversalDepth() > 2 ? dynamic_cast< Portal* >( state->getZoneFromStack( 2 ) ) : NULL;
if( sourcePortal != NULL )
{
const Side sourcePortalFrontSide =
sourceZoneId == SceneZoneSpaceManager::RootZoneId
? sourcePortal->getInteriorSideOfExteriorPortal()
: sourcePortal->getSideRelativeToPortalPlane( sourceZoneSpace->getPosition() );
const PlaneF::Side sourcePortalPlaneFrontSide =
sourcePortalFrontSide == FrontSide ? PlaneF::Front : PlaneF::Back;
bool allPortalVerticesOnBackside = true;
const U32 numVertices = mPortalPolygonWS.size();
for( U32 i = 0; i < numVertices; ++ i )
{
// Not using getSideRelativeToPortalPlane here since we want PlaneF::On to be
// counted as backside here.
if( sourcePortal->mPortalPlane.whichSide( mPortalPolygonWS[ i ] ) == sourcePortalPlaneFrontSide )
{
allPortalVerticesOnBackside = false;
break;
}
//.........这里部分代码省略.........