本文整理汇总了C++中Opt::ClipScene方法的典型用法代码示例。如果您正苦于以下问题:C++ Opt::ClipScene方法的具体用法?C++ Opt::ClipScene怎么用?C++ Opt::ClipScene使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opt
的用法示例。
在下文中一共展示了Opt::ClipScene方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void CollisionSystem::Update( double DeltaTime )
{
static const auto enableCollision = Settings::Get().GetInt( "collisions.enable", 1 ) != 0;
if( !enableCollision )
{
return;
}
mUpdateTimer.Log( "start collision" );
mPerfTimer.Log( "pre build grid" );
std::vector<std::pair<Opt<CollisionSubSystem>, Actor*>> collisionAndActors;
for (auto actor : mScene.GetActorsFromMap( GetType_static() ))
{
Opt<ICollisionComponent> collisionC = actor->Get<ICollisionComponent>();
if ( collisionC.IsValid() )
{
Opt<CollisionSubSystem> collisionSS = GetCollisionSubSystem( collisionC->GetId() );
if ( collisionSS.IsValid() )
{
collisionAndActors.push_back( std::make_pair( collisionSS, actor ) );
collisionSS->ClipScene( *actor );
}
mCollisionGrid.AddActor( actor, DeltaTime, collisionC );
}
}
mPerfTimer.Log( "post build grid" );
PossibleCollisions_t const& PossibleCollisions = mCollisionGrid.GetPossibleCollisions();
for( PossibleCollisions_t::const_iterator i = PossibleCollisions.begin(), e = PossibleCollisions.end(); i != e; ++i )
{
Actor& A = *( i->A1 );
Actor& B = *( i->A2 );
Opt<ICollisionComponent> ACollisionC = A.Get<ICollisionComponent>();
Opt<ICollisionComponent> BCollisionC = B.Get<ICollisionComponent>();
BOOST_ASSERT( ACollisionC.IsValid() && BCollisionC.IsValid() ); //TODO: here this one should be true
CollisionModel const& CollModel = mCollisionStore.GetCollisionModel( ACollisionC->GetCollisionClass(), BCollisionC->GetCollisionClass() );
if( !CollModel.AreActorsColliding( A, B, DeltaTime ) )
{
continue;
}
//TODO: needs optimization, maybe a template parameter for SubSystemHolder to subsystem would do
Opt<CollisionSubSystem> ACollisionSS = GetCollisionSubSystem( ACollisionC->GetId() );
if ( ACollisionSS.IsValid() )
{
ACollisionSS->Collide( A, B );
}
Opt<CollisionSubSystem> BCollisionSS = GetCollisionSubSystem( BCollisionC->GetId() );
if ( BCollisionSS.IsValid() )
{
BCollisionSS->Collide( B, A );
}
}
mPerfTimer.Log( "post collide" );
for (auto& collAndActor : collisionAndActors)
{
collAndActor.first->Update( *collAndActor.second, DeltaTime );
}
mPerfTimer.Log( "post collSS" );
mUpdateTimer.Log( "end collision" );
}
示例2: Update
void CollisionSystem::Update( double DeltaTime )
{
mCollisionGrid.Clear();
for( ActorList_t::iterator it = mScene.GetActors().begin(), e = mScene.GetActors().end(); it != e; ++it )
{
Actor& actor = **it;
Opt<ICollisionComponent> collisionC = actor.Get<ICollisionComponent>();
if ( collisionC.IsValid() )
{
mCollisionGrid.AddActor( &actor, DeltaTime );
Opt<CollisionSubSystem> collisionSS = GetCollisionSubSystem( collisionC->GetId() );
if ( collisionSS.IsValid() )
{
collisionSS->ClipScene( actor );
}
}
}
PossibleCollisions_t const& PossibleCollisions = mCollisionGrid.GetPossibleCollisions();
for( PossibleCollisions_t::const_iterator i = PossibleCollisions.begin(), e = PossibleCollisions.end(); i != e; ++i )
{
Actor& A = *( i->A1 );
Actor& B = *( i->A2 );
Opt<ICollisionComponent> ACollisionC = A.Get<ICollisionComponent>();
Opt<ICollisionComponent> BCollisionC = B.Get<ICollisionComponent>();
BOOST_ASSERT( ACollisionC.IsValid() && BCollisionC.IsValid() ); //TODO: here this one should be true
CollisionModel const& CollModel = mCollisionStore.GetCollisionModel( ACollisionC->GetCollisionClass(), BCollisionC->GetCollisionClass() );
if( !CollModel.AreActorsColliding( A, B, DeltaTime ) )
{
continue;
}
//TODO: needs optimization, maybe a template parameter for SubSystemHolder to subsystem would do
Opt<CollisionSubSystem> ACollisionSS = GetCollisionSubSystem( ACollisionC->GetId() );
if ( ACollisionSS.IsValid() )
{
ACollisionSS->Collide( A, B );
}
Opt<CollisionSubSystem> BCollisionSS = GetCollisionSubSystem( BCollisionC->GetId() );
if ( BCollisionSS.IsValid() )
{
BCollisionSS->Collide( B, A );
}
}
for( ActorList_t::iterator it = mScene.GetActors().begin(), e = mScene.GetActors().end(); it != e; ++it )
{
Actor& actor = **it;
Opt<ICollisionComponent> collisionC = actor.Get<ICollisionComponent>();
if ( collisionC.IsValid() )
{
Opt<CollisionSubSystem> collisionSS = GetCollisionSubSystem( collisionC->GetId() );
if ( collisionSS.IsValid() )
{
collisionSS->Update( actor, DeltaTime );
}
}
}
}