Actor.h
Go to the documentation of this file.
00001 //
00002 // Redistribution and use in source and binary forms, with or without
00003 // modification, are permitted provided that the following conditions
00004 // are met:
00005 //  * Redistributions of source code must retain the above copyright
00006 //    notice, this list of conditions and the following disclaimer.
00007 //  * Redistributions in binary form must reproduce the above copyright
00008 //    notice, this list of conditions and the following disclaimer in the
00009 //    documentation and/or other materials provided with the distribution.
00010 //  * Neither the name of NVIDIA CORPORATION nor the names of its
00011 //    contributors may be used to endorse or promote products derived
00012 //    from this software without specific prior written permission.
00013 //
00014 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
00015 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017 // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00018 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 //
00026 // Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
00027 
00028 
00029 
00030 #ifndef ACTOR_H
00031 #define ACTOR_H
00032 
00038 #include "ApexInterface.h"
00039 
00040 #if PX_PHYSICS_VERSION_MAJOR == 3
00041 #include "PxActor.h"
00042 #include "PxShape.h"
00043 #include "PxFiltering.h"
00044 namespace nvidia { namespace apex
00045 {
00046 
00048 #define APEX_DEFAULT_WAKE_UP_COUNTER 0.4f
00049 
00051 #define APEX_ACTOR_TEMPLATE_PARAM(_type, _name, _valid, _default) \
00052 bool is##_name##Valid(_type x) const { PX_UNUSED(x); return _valid; } \
00053 _type getDefault##_name() const { return _default; } \
00054 virtual _type get##_name() const = 0; \
00055 virtual bool set##_name(_type) = 0
00056 
00062 class PhysX3DescTemplate
00063 {
00064 public:
00065     /*
00066         For each Name below, there are functions: getName(), setName(), isNameValid(), and getDefaultName().  For example:
00067 
00068         PxDominanceGroup    getDominanceGroup() const;
00069         bool                setDominanceGroup(PxDominanceGroup);    // Returns true iff the passed-in value is valid.  (Note, will set the internal values even if they are not valid.)
00070         bool                isDominanceGroupValid() const;
00071         PxDominanceGroup    getDefaultDominanceGroup() const;
00072     */
00073 
00074     /*                           Type                       Name                    Validity Condition      Default Value */
00075     // Actor
00077     APEX_ACTOR_TEMPLATE_PARAM(physx::PxDominanceGroup,  DominanceGroup,     (1),                    0);
00079     APEX_ACTOR_TEMPLATE_PARAM(uint8_t,              ActorFlags,             (1),                    physx::PxActorFlag::eSEND_SLEEP_NOTIFIES);
00081     APEX_ACTOR_TEMPLATE_PARAM(physx::PxClientID,    OwnerClient,            (1),                    0);
00083     APEX_ACTOR_TEMPLATE_PARAM(uint32_t,             ClientBehaviorBits,     (1),                    0);
00085     APEX_ACTOR_TEMPLATE_PARAM(uint16_t,             ContactReportFlags,     (1),                    0);
00087     APEX_ACTOR_TEMPLATE_PARAM(void*,                UserData,               (1),                    NULL);
00089     APEX_ACTOR_TEMPLATE_PARAM(const char*,          Name,                   (1),                    NULL);
00090 
00091     // Body
00093     APEX_ACTOR_TEMPLATE_PARAM(float,                Density,                (x >= 0.0f),            1.0f);
00095     APEX_ACTOR_TEMPLATE_PARAM(uint8_t,              BodyFlags,              (1),                    0);
00097     APEX_ACTOR_TEMPLATE_PARAM(float,                WakeUpCounter,          (x >= 0.0f),            APEX_DEFAULT_WAKE_UP_COUNTER);
00099     APEX_ACTOR_TEMPLATE_PARAM(float,                LinearDamping,          (x >= 0.0f),            0.0f);
00101     APEX_ACTOR_TEMPLATE_PARAM(float,                AngularDamping,         (x >= 0.0f),            0.05f);
00103     APEX_ACTOR_TEMPLATE_PARAM(float,                MaxAngularVelocity,     (1),                    7.0f);
00105     APEX_ACTOR_TEMPLATE_PARAM(float,                SleepLinearVelocity,    (1),                    0.0f);
00107     APEX_ACTOR_TEMPLATE_PARAM(uint32_t,             SolverIterationCount,   (x >= 1 && x <= 255),   4);
00109     APEX_ACTOR_TEMPLATE_PARAM(uint32_t,             VelocityIterationCount, (x >= 1 && x <= 255),   1);
00111     APEX_ACTOR_TEMPLATE_PARAM(float,                ContactReportThreshold, (1),                    PX_MAX_F32);
00113     APEX_ACTOR_TEMPLATE_PARAM(float,                SleepThreshold,         (1),                    0.005f);
00114 
00115     // Shape
00117     APEX_ACTOR_TEMPLATE_PARAM(uint8_t,              ShapeFlags,             (1),                    physx::PxShapeFlag::eSIMULATION_SHAPE | physx::PxShapeFlag::eSCENE_QUERY_SHAPE | physx::PxShapeFlag::eVISUALIZATION);
00119     APEX_ACTOR_TEMPLATE_PARAM(void*,                ShapeUserData,          (1),                    NULL);
00121     APEX_ACTOR_TEMPLATE_PARAM(const char*,          ShapeName,              (1),                    NULL);
00123     APEX_ACTOR_TEMPLATE_PARAM(physx::PxFilterData,  SimulationFilterData,   (1),                    physx::PxFilterData(0, 0, 0, 0));
00125     APEX_ACTOR_TEMPLATE_PARAM(physx::PxFilterData,  QueryFilterData,        (1),                    physx::PxFilterData(0, 0, 0, 0));
00127     APEX_ACTOR_TEMPLATE_PARAM(float,                ContactOffset,          (1),                    -1.0f);
00129     APEX_ACTOR_TEMPLATE_PARAM(float,                RestOffset,             (1),                    PX_MAX_F32);
00130     // Shape materials get explicitly defined API:
00132     virtual physx::PxMaterial** getMaterials(uint32_t& materialCount) const = 0;
00134     virtual bool                setMaterials(physx::PxMaterial** materialArray, uint32_t materialCount) = 0;    // Must have non-zero sized array of materials to be valid.
00135 
00136 
00138     virtual void release() = 0;
00139 
00140 protected:
00141     virtual ~PhysX3DescTemplate() {}
00142 };  // PhysX3DescTemplate
00143 
00144 #undef APEX_ACTOR_TEMPLATE_PARAM
00145 
00146 }}
00147 #endif
00148 
00149 namespace nvidia
00150 {
00151 namespace apex
00152 {
00153 
00154 PX_PUSH_PACK_DEFAULT
00155 
00156 class Asset;
00157 
00161 class Actor : public ApexInterface
00162 {
00163 public:
00167     virtual Asset* getOwner() const = 0;
00168 
00179     virtual void getLodRange(float& min, float& max, bool& intOnly) const = 0;
00180 
00184     virtual float getActiveLod() const = 0;
00185 
00194     virtual void forceLod(float lod) = 0;
00195 
00199     virtual void cacheModuleData() const {}
00200 
00204     virtual void setEnableDebugVisualization(bool state) = 0;
00205     
00206 
00207 protected:
00208     virtual ~Actor() {} // use release() method instead!
00209 };
00210 
00211 #if PX_PHYSICS_VERSION_MAJOR == 3
00212 
00215 class ActorSource
00216 {
00217 public:
00234     virtual void setPhysX3Template(const PhysX3DescTemplate*) = 0;
00235 
00239     virtual bool getPhysX3Template(PhysX3DescTemplate& dest) const = 0;
00240 
00244     virtual PhysX3DescTemplate* createPhysX3DescTemplate() const = 0;
00245 };
00246 
00247 #endif
00248 
00249 PX_POP_PACK
00250 
00251 }
00252 } // end namespace nvidia::apex
00253 
00254 #endif // ACTOR_H

Generated on Sat Dec 1 2018 15:52:05

Copyright © 2012-2018 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved.