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 DESTRUCTIBLE_ACTOR_JOINT_H 00031 #define DESTRUCTIBLE_ACTOR_JOINT_H 00032 00033 #include "ModuleDestructible.h" 00034 00035 #include "extensions/PxJoint.h" 00036 00037 00038 namespace nvidia 00039 { 00040 namespace apex 00041 { 00042 00043 PX_PUSH_PACK_DEFAULT 00044 00048 class DestructibleActorJointDesc : public ApexDesc 00049 { 00050 public: 00051 00055 PX_INLINE DestructibleActorJointDesc(); 00056 00060 PX_INLINE void setToDefault(); 00061 00065 PX_INLINE bool isValid() const; 00066 00070 physx::PxJointConcreteType::Enum type; 00074 PxRigidActor* actor[2]; 00078 PxVec3 localAxis[2]; 00082 PxVec3 localAnchor[2]; 00086 PxVec3 localNormal[2]; 00087 00092 DestructibleActor* destructible[2]; 00093 00101 int32_t attachmentChunkIndex[2]; 00102 00103 00113 PxVec3 globalAnchor[2]; 00114 00118 PxVec3 globalAxis[2]; 00119 00123 PxVec3 globalNormal[2]; 00124 }; 00125 00126 // DestructibleActorJointDesc inline functions 00127 00128 PX_INLINE DestructibleActorJointDesc::DestructibleActorJointDesc() : ApexDesc() 00129 { 00130 setToDefault(); 00131 } 00132 00133 PX_INLINE void DestructibleActorJointDesc::setToDefault() 00134 { 00135 ApexDesc::setToDefault(); 00136 for (int i=0; i<2; i++) 00137 { 00138 actor[i] = 0; 00139 localAxis[i] = PxVec3(0,0,1); 00140 localNormal[i] = PxVec3(1,0,0); 00141 localAnchor[i] = PxVec3(0); 00142 } 00143 for (int i = 0; i < 2; ++i) 00144 { 00145 destructible[i] = NULL; 00146 attachmentChunkIndex[i] = ModuleDestructibleConst::INVALID_CHUNK_INDEX; 00147 globalAnchor[i] = PxVec3(0.0f); 00148 globalAxis[i] = PxVec3(0.0f, 0.0f, 1.0f); 00149 globalNormal[i] = PxVec3(1.0f, 0.0f, 0.0f); 00150 } 00151 } 00152 00153 PX_INLINE bool DestructibleActorJointDesc::isValid() const 00154 { 00155 if (destructible[0] == NULL && destructible[1] == NULL) 00156 { 00157 return false; 00158 } 00159 00160 for (int i = 0; i < 2; ++i) 00161 { 00162 if (PxAbs(globalAxis[i].magnitudeSquared() - 1.0f) > 0.1f) 00163 { 00164 return false; 00165 } 00166 if (PxAbs(globalNormal[i].magnitudeSquared() - 1.0f) > 0.1f) 00167 { 00168 return false; 00169 } 00170 //check orthogonal pairs 00171 if (PxAbs(globalAxis[i].dot(globalNormal[i])) > 0.1f) 00172 { 00173 return false; 00174 } 00175 } 00176 00177 return ApexDesc::isValid(); 00178 } 00179 00180 00185 class DestructibleActorJoint : public ApexInterface 00186 { 00187 public: 00197 virtual PxJoint* joint() = 0; 00198 00199 protected: 00200 virtual ~DestructibleActorJoint() {} 00201 }; 00202 00203 PX_POP_PACK 00204 00205 } 00206 } // end namespace nvidia 00207 00208 #endif // DESTRUCTIBLE_ACTOR_JOINT_H