当前位置: 首页>>代码示例>>C++>>正文


C++ FPhysScene::GetApexScene方法代码示例

本文整理汇总了C++中FPhysScene::GetApexScene方法的典型用法代码示例。如果您正苦于以下问题:C++ FPhysScene::GetApexScene方法的具体用法?C++ FPhysScene::GetApexScene怎么用?C++ FPhysScene::GetApexScene使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FPhysScene的用法示例。


在下文中一共展示了FPhysScene::GetApexScene方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreatePhysicsState


//.........这里部分代码省略.........
    verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.simulationFilterData.word0", PSimFilterData.word0 ) );
    verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.simulationFilterData.word1", PSimFilterData.word1 ) );
    verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.simulationFilterData.word2", PSimFilterData.word2 ) );
    verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.simulationFilterData.word3", PSimFilterData.word3 ) );
    verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.queryFilterData.word0", PQueryFilterData.word0 ) );
    verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.queryFilterData.word1", PQueryFilterData.word1 ) );
    verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.queryFilterData.word2", PQueryFilterData.word2 ) );
    verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.queryFilterData.word3", PQueryFilterData.word3 ) );

    // Set the PhysX material in the shape descriptor
    PxMaterial* PMaterial = PhysMat->GetPhysXMaterial();
    verify( NxParameterized::setParamU64(*ActorParams,"p3ShapeDescTemplate.material", (physx::PxU64)PMaterial) );

    // Set the rest depth to match the skin width in the shape descriptor
    const physx::PxCookingParams& CookingParams = GApexSDK->getCookingInterface()->getParams();
    verify( NxParameterized::setParamF32(*ActorParams,"p3ShapeDescTemplate.restOffset", -CookingParams.skinWidth) );

    // Set the PhysX material in the actor descriptor
    verify( NxParameterized::setParamBool(*ActorParams,"p3ActorDescTemplate.flags.eDISABLE_GRAVITY",false) );
    verify( NxParameterized::setParamBool(*ActorParams,"p3ActorDescTemplate.flags.eVISUALIZATION",true) );

    // Set the PxActor's and PxShape's userData fields to this component's body instance
    verify( NxParameterized::setParamU64(*ActorParams,"p3ActorDescTemplate.userData", 0 ) );

    // All shapes created by this DestructibleActor will have the userdata of the owning component.
    // We need this, as in some cases APEX is moving shapes accross actors ( ex. FormExtended structures )
    verify( NxParameterized::setParamU64(*ActorParams,"p3ShapeDescTemplate.userData", (PxU64)&PhysxUserData ) );

    // Set up the body desc template in the actor descriptor
    verify( NxParameterized::setParamF32(*ActorParams,"p3BodyDescTemplate.angularDamping", BodyInstance.AngularDamping ) );
    verify( NxParameterized::setParamF32(*ActorParams,"p3BodyDescTemplate.linearDamping", BodyInstance.LinearDamping ) );
    const PxTolerancesScale& PScale = GPhysXSDK->getTolerancesScale();
    PxF32 SleepEnergyThreshold = 0.00005f*PScale.speed*PScale.speed;	// 1/1000 Default, since the speed scale is quite high
    if (BodyInstance.SleepFamily == ESleepFamily::Sensitive)
    {
        SleepEnergyThreshold /= 20.0f;
    }
    verify( NxParameterized::setParamF32(*ActorParams,"p3BodyDescTemplate.sleepThreshold", SleepEnergyThreshold) );
//	NxParameterized::setParamF32(*ActorParams,"bodyDescTemplate.sleepDamping", SleepDamping );
    verify( NxParameterized::setParamF32(*ActorParams,"p3BodyDescTemplate.density", 0.001f*PhysMat->Density) );	// Convert from g/cm^3 to kg/cm^3
    // Enable CCD if requested
    verify( NxParameterized::setParamBool(*ActorParams,"p3BodyDescTemplate.flags.eENABLE_CCD", BodyInstance.bUseCCD != 0) );
    // Ask the actor to create chunk events, for more efficient visibility updates
    verify( NxParameterized::setParamBool(*ActorParams,"createChunkEvents", true) );

    // Enable hard sleeping if requested
    verify( NxParameterized::setParamBool(*ActorParams,"useHardSleeping", bEnableHardSleeping) );

    

    // Destructibles are always dynamic or kinematic, and therefore only go into one of the scenes
    const uint32 SceneType = BodyInstance.UseAsyncScene(PhysScene) ? PST_Async : PST_Sync;
    NxApexScene* ApexScene = PhysScene->GetApexScene(SceneType);
    PxScene* PScene = PhysScene->GetPhysXScene(SceneType);

    BodyInstance.SceneIndexSync = SceneType == PST_Sync ? PhysScene->PhysXSceneIndex[PST_Sync] : 0;
    BodyInstance.SceneIndexAsync = SceneType == PST_Async ? PhysScene->PhysXSceneIndex[PST_Async] : 0;
    check(ApexScene);

    ChunkInfos.Reset(ChunkCount);
    ChunkInfos.AddZeroed(ChunkCount);
    PhysxChunkUserData.Reset(ChunkCount);
    PhysxChunkUserData.AddZeroed(ChunkCount);

    // Create an APEX NxDestructibleActor from the Destructible asset and actor descriptor
    ApexDestructibleActor = static_cast<NxDestructibleActor*>(TheDestructibleMesh->ApexDestructibleAsset->createApexActor(*ActorParams, *ApexScene));
    check(ApexDestructibleActor);

    // Make a backpointer to this component
    PhysxUserData = FPhysxUserData(this);
    ApexDestructibleActor->userData = &PhysxUserData;

    // Cache cooked collision data
    // BRGTODO : cook in asset
    ApexDestructibleActor->cacheModuleData();

    // BRGTODO : Per-actor LOD setting
//	ApexDestructibleActor->forcePhysicalLod( DestructibleActor->LOD );

    // Start asleep if requested
    PxRigidDynamic* PRootActor = ApexDestructibleActor->getChunkPhysXActor(0);


    //  Put to sleep or wake up only if the component is physics-simulated
    if (PRootActor != NULL && BodyInstance.bSimulatePhysics)
    {
        SCOPED_SCENE_WRITE_LOCK(PScene);	//Question, since apex is defer adding actors do we need to lock? Locking the async scene is expensive!

        PRootActor->setActorFlag(PxActorFlag::eDISABLE_GRAVITY, !BodyInstance.bEnableGravity);

        // Sleep/wake up as appropriate
        if (!BodyInstance.bStartAwake)
        {
            ApexDestructibleActor->setChunkPhysXActorAwakeState(0, false);
        }
        }

    UpdateBounds();
#endif	// #if WITH_APEX
}
开发者ID:johndpope,项目名称:UE4,代码行数:101,代码来源:DestructibleComponent.cpp


注:本文中的FPhysScene::GetApexScene方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。