APEX Framework: Actor.h Source File

NVIDIA APEX

Actor.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008-2017, NVIDIA CORPORATION.  All rights reserved.
00003  *
00004  * NVIDIA CORPORATION and its licensors retain all intellectual property
00005  * and proprietary rights in and to this software, related documentation
00006  * and any modifications thereto.  Any use, reproduction, disclosure or
00007  * distribution of this software and related documentation without an express
00008  * license agreement from NVIDIA CORPORATION is strictly prohibited.
00009  */
00010 
00011 
00012 #ifndef ACTOR_H
00013 #define ACTOR_H
00014 
00020 #include "ApexInterface.h"
00021 
00022 #if PX_PHYSICS_VERSION_MAJOR == 3
00023 #include "PxActor.h"
00024 #include "PxShape.h"
00025 #include "PxFiltering.h"
00026 namespace nvidia { namespace apex
00027 {
00028 
00030 #define APEX_DEFAULT_WAKE_UP_COUNTER 0.4f
00031 
00033 #define APEX_ACTOR_TEMPLATE_PARAM(_type, _name, _valid, _default) \
00034 bool is##_name##Valid(_type x) const { PX_UNUSED(x); return _valid; } \
00035 _type getDefault##_name() const { return _default; } \
00036 virtual _type get##_name() const = 0; \
00037 virtual bool set##_name(_type) = 0
00038 
00044 class PhysX3DescTemplate
00045 {
00046 public:
00047     /*
00048         For each Name below, there are functions: getName(), setName(), isNameValid(), and getDefaultName().  For example:
00049 
00050         PxDominanceGroup    getDominanceGroup() const;
00051         bool                setDominanceGroup(PxDominanceGroup);    // Returns true iff the passed-in value is valid.  (Note, will set the internal values even if they are not valid.)
00052         bool                isDominanceGroupValid() const;
00053         PxDominanceGroup    getDefaultDominanceGroup() const;
00054     */
00055 
00056     /*                           Type                       Name                    Validity Condition      Default Value */
00057     // Actor
00059     APEX_ACTOR_TEMPLATE_PARAM(physx::PxDominanceGroup,  DominanceGroup,     (1),                    0);
00061     APEX_ACTOR_TEMPLATE_PARAM(uint8_t,              ActorFlags,             (1),                    physx::PxActorFlag::eSEND_SLEEP_NOTIFIES);
00063     APEX_ACTOR_TEMPLATE_PARAM(physx::PxClientID,    OwnerClient,            (1),                    0);
00065     APEX_ACTOR_TEMPLATE_PARAM(uint32_t,             ClientBehaviorBits,     (1),                    0);
00067     APEX_ACTOR_TEMPLATE_PARAM(uint16_t,             ContactReportFlags,     (1),                    0);
00069     APEX_ACTOR_TEMPLATE_PARAM(void*,                UserData,               (1),                    NULL);
00071     APEX_ACTOR_TEMPLATE_PARAM(const char*,          Name,                   (1),                    NULL);
00072 
00073     // Body
00075     APEX_ACTOR_TEMPLATE_PARAM(float,                Density,                (x >= 0.0f),            1.0f);
00077     APEX_ACTOR_TEMPLATE_PARAM(uint8_t,              BodyFlags,              (1),                    0);
00079     APEX_ACTOR_TEMPLATE_PARAM(float,                WakeUpCounter,          (x >= 0.0f),            APEX_DEFAULT_WAKE_UP_COUNTER);
00081     APEX_ACTOR_TEMPLATE_PARAM(float,                LinearDamping,          (x >= 0.0f),            0.0f);
00083     APEX_ACTOR_TEMPLATE_PARAM(float,                AngularDamping,         (x >= 0.0f),            0.05f);
00085     APEX_ACTOR_TEMPLATE_PARAM(float,                MaxAngularVelocity,     (1),                    7.0f);
00087     APEX_ACTOR_TEMPLATE_PARAM(float,                SleepLinearVelocity,    (1),                    0.0f);
00089     APEX_ACTOR_TEMPLATE_PARAM(uint32_t,             SolverIterationCount,   (x >= 1 && x <= 255),   4);
00091     APEX_ACTOR_TEMPLATE_PARAM(uint32_t,             VelocityIterationCount, (x >= 1 && x <= 255),   1);
00093     APEX_ACTOR_TEMPLATE_PARAM(float,                ContactReportThreshold, (1),                    PX_MAX_F32);
00095     APEX_ACTOR_TEMPLATE_PARAM(float,                SleepThreshold,         (1),                    0.005f);
00096 
00097     // Shape
00099     APEX_ACTOR_TEMPLATE_PARAM(uint8_t,              ShapeFlags,             (1),                    physx::PxShapeFlag::eSIMULATION_SHAPE | physx::PxShapeFlag::eSCENE_QUERY_SHAPE | physx::PxShapeFlag::eVISUALIZATION);
00101     APEX_ACTOR_TEMPLATE_PARAM(void*,                ShapeUserData,          (1),                    NULL);
00103     APEX_ACTOR_TEMPLATE_PARAM(const char*,          ShapeName,              (1),                    NULL);
00105     APEX_ACTOR_TEMPLATE_PARAM(physx::PxFilterData,  SimulationFilterData,   (1),                    physx::PxFilterData(0, 0, 0, 0));
00107     APEX_ACTOR_TEMPLATE_PARAM(physx::PxFilterData,  QueryFilterData,        (1),                    physx::PxFilterData(0, 0, 0, 0));
00109     APEX_ACTOR_TEMPLATE_PARAM(float,                ContactOffset,          (1),                    -1.0f);
00111     APEX_ACTOR_TEMPLATE_PARAM(float,                RestOffset,             (1),                    PX_MAX_F32);
00112     // Shape materials get explicitly defined API:
00114     virtual physx::PxMaterial** getMaterials(uint32_t& materialCount) const = 0;
00116     virtual bool                setMaterials(physx::PxMaterial** materialArray, uint32_t materialCount) = 0;    // Must have non-zero sized array of materials to be valid.
00117 
00118 
00120     virtual void release() = 0;
00121 
00122 protected:
00123     virtual ~PhysX3DescTemplate() {}
00124 };  // PhysX3DescTemplate
00125 
00126 #undef APEX_ACTOR_TEMPLATE_PARAM
00127 
00128 }}
00129 #endif
00130 
00131 namespace nvidia
00132 {
00133 namespace apex
00134 {
00135 
00136 PX_PUSH_PACK_DEFAULT
00137 
00138 class Asset;
00139 
00143 class Actor : public ApexInterface
00144 {
00145 public:
00149     virtual Asset* getOwner() const = 0;
00150 
00161     virtual void getLodRange(float& min, float& max, bool& intOnly) const = 0;
00162 
00166     virtual float getActiveLod() const = 0;
00167 
00176     virtual void forceLod(float lod) = 0;
00177 
00181     virtual void cacheModuleData() const {}
00182 
00186     virtual void setEnableDebugVisualization(bool state) = 0;
00187     
00188 
00189 protected:
00190     virtual ~Actor() {} // use release() method instead!
00191 };
00192 
00193 #if PX_PHYSICS_VERSION_MAJOR == 3
00194 
00197 class ActorSource
00198 {
00199 public:
00216     virtual void setPhysX3Template(const PhysX3DescTemplate*) = 0;
00217 
00221     virtual bool getPhysX3Template(PhysX3DescTemplate& dest) const = 0;
00222 
00226     virtual PhysX3DescTemplate* createPhysX3DescTemplate() const = 0;
00227 };
00228 
00229 #endif
00230 
00231 PX_POP_PACK
00232 
00233 }
00234 } // end namespace nvidia::apex
00235 
00236 #endif // ACTOR_H

Generated on Fri Dec 15 2017 13:58:35
Copyright © 2012-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved.