mirror of
https://github.com/panda3d/panda3d.git
synced 2026-05-12 17:48:49 -05:00
Exposed CCD for PhysX.
This commit is contained in:
@@ -31,6 +31,7 @@ class NxCapsuleForceFieldShape;
|
||||
class NxCapsuleForceFieldShapeDesc;
|
||||
class NxCapsuleShape;
|
||||
class NxCapsuleShapeDesc;
|
||||
class NxCCDSkeleton;
|
||||
class NxConvexMesh;
|
||||
class NxConvexMeshDesc;
|
||||
class NxConvexForceFieldShape;
|
||||
@@ -113,6 +114,7 @@ class NxConstraintDominance;
|
||||
class NxRemoteDebugger;
|
||||
class NxGroupsMask;
|
||||
class NxSceneStats2;
|
||||
class NxSimpleTriangleMesh;
|
||||
|
||||
class NxSoftBody;
|
||||
class NxSoftBodyDesc;
|
||||
|
||||
@@ -46,6 +46,7 @@ class btHingeConstraint;
|
||||
class btHinge2Constraint;
|
||||
class btIDebugDraw;
|
||||
class btKinematicCharacterController;
|
||||
class btManifoldArray;
|
||||
class btManifoldPoint;
|
||||
class btMatrix3x3;
|
||||
class btMotionState;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "physxCapsuleForceFieldShapeDesc.cxx"
|
||||
#include "physxCapsuleShape.cxx"
|
||||
#include "physxCapsuleShapeDesc.cxx"
|
||||
#include "physxCcdSkeleton.cxx"
|
||||
#include "physxCloth.cxx"
|
||||
#include "physxClothDesc.cxx"
|
||||
#include "physxClothMesh.cxx"
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// Filename: physxCcdSkeleton.I
|
||||
// Created by: enn0x (13Oct09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxCcdSkeleton::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PhysxCcdSkeleton::
|
||||
PhysxCcdSkeleton() : PhysxObject() {
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxCcdSkeleton::Destructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PhysxCcdSkeleton::
|
||||
~PhysxCcdSkeleton() {
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxCcdSkeleton::ls
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void PhysxCcdSkeleton::
|
||||
ls() const {
|
||||
|
||||
ls(nout);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxCcdSkeleton::ls
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void PhysxCcdSkeleton::
|
||||
ls(ostream &out, int indent_level) const {
|
||||
|
||||
indent(out, indent_level) << get_type().get_name()
|
||||
<< " (at 0x" << this << ")\n";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// Filename: physxCcdSkeleton.cxx
|
||||
// Created by: enn0x (13Oct09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "physxCcdSkeleton.h"
|
||||
#include "physxMeshPool.h"
|
||||
|
||||
TypeHandle PhysxCcdSkeleton::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxCcdSkeleton::link
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysxCcdSkeleton::
|
||||
link(NxCCDSkeleton *skeletonPtr) {
|
||||
|
||||
// Link self
|
||||
PhysxManager::get_global_ptr()->_ccd_skeletons.add(this);
|
||||
_ptr = skeletonPtr;
|
||||
_error_type = ET_ok;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxCcdSkeleton::unlink
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysxCcdSkeleton::
|
||||
unlink() {
|
||||
|
||||
// Unlink self
|
||||
_error_type = ET_released;
|
||||
PhysxManager::get_global_ptr()->_ccd_skeletons.remove(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxCcdSkeleton::release
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysxCcdSkeleton::
|
||||
release() {
|
||||
|
||||
nassertv(_error_type == ET_ok);
|
||||
|
||||
unlink();
|
||||
NxGetPhysicsSDK()->releaseCCDSkeleton(*_ptr);
|
||||
_ptr = NULL;
|
||||
|
||||
//TODO PhysxMeshPool::release_ccd_skeleton(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxCcdSkeleton::get_reference_count
|
||||
// Access: Published
|
||||
// Description: Returns the reference count for shared meshes.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
unsigned int PhysxCcdSkeleton::
|
||||
get_reference_count() const {
|
||||
|
||||
nassertr(_error_type == ET_ok, 0);
|
||||
|
||||
return _ptr->getReferenceCount();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// Filename: physxCcdSkeleton.h
|
||||
// Created by: enn0x (13Oct09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PHYSXCCDSKELETON_H
|
||||
#define PHYSXCCDSKELETON_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "physxObject.h"
|
||||
#include "physx_includes.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PhysxCcdSkeleton
|
||||
// Description : A Convex Mesh. Internally represented as a list of
|
||||
// convex polygons. The number of polygons is
|
||||
// limited to 256.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDAPHYSX PhysxCcdSkeleton : public PhysxObject {
|
||||
|
||||
PUBLISHED:
|
||||
unsigned int get_reference_count() const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PUBLISHED:
|
||||
void release();
|
||||
|
||||
INLINE void ls() const;
|
||||
INLINE void ls(ostream &out, int indent_level=0) const;
|
||||
|
||||
public:
|
||||
INLINE PhysxCcdSkeleton();
|
||||
INLINE ~PhysxCcdSkeleton();
|
||||
|
||||
INLINE NxCCDSkeleton *ptr() const { return _ptr; };
|
||||
|
||||
void link(NxCCDSkeleton *meshPtr);
|
||||
void unlink();
|
||||
|
||||
private:
|
||||
NxCCDSkeleton *_ptr;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
PhysxObject::init_type();
|
||||
register_type(_type_handle, "PhysxCcdSkeleton",
|
||||
PhysxObject::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {
|
||||
init_type();
|
||||
return get_class_type();
|
||||
}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "physxCcdSkeleton.I"
|
||||
|
||||
#endif // PHYSXCCDSKELETON_H
|
||||
@@ -319,6 +319,52 @@ get_soft_body_mesh(unsigned int idx) {
|
||||
return (PhysxSoftBodyMesh *)_softbody_meshes[idx];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxManager::get_num_ccd_skeletons
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
unsigned int PhysxManager::
|
||||
get_num_ccd_skeletons() {
|
||||
|
||||
return _sdk->getNbCCDSkeletons();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxManager::create_ccd_skeleton
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PhysxCcdSkeleton *PhysxManager::
|
||||
create_ccd_skeleton(PhysxTriangleMeshDesc &desc) {
|
||||
|
||||
nassertr(desc.is_valid(), NULL);
|
||||
nassertr(desc.get_desc().numVertices < 64, NULL);
|
||||
|
||||
PhysxCcdSkeleton *skel = new PhysxCcdSkeleton();
|
||||
nassertr(skel, NULL);
|
||||
|
||||
NxCCDSkeleton *skelPtr = _sdk->createCCDSkeleton(desc.get_desc());
|
||||
nassertr(skelPtr, NULL);
|
||||
|
||||
skel->link(skelPtr);
|
||||
|
||||
return skel;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxManager::get_ccd_skeleton
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PhysxCcdSkeleton *PhysxManager::
|
||||
get_ccd_skeleton(unsigned int idx) {
|
||||
|
||||
nassertr_always(idx < _sdk->getNbCCDSkeletons(), NULL);
|
||||
|
||||
return (PhysxCcdSkeleton *)_ccd_skeletons[idx];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxManager::is_hardware_available
|
||||
// Access: Published
|
||||
|
||||
@@ -32,6 +32,8 @@ class PhysxConvexMesh;
|
||||
class PhysxClothMesh;
|
||||
class PhysxSoftBodyMesh;
|
||||
class PhysxOutputStream;
|
||||
class PhysxCcdSkeleton;
|
||||
class PhysxTriangleMeshDesc;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PhysxManager
|
||||
@@ -84,6 +86,11 @@ PUBLISHED:
|
||||
PhysxSoftBodyMesh *get_soft_body_mesh(unsigned int idx);
|
||||
MAKE_SEQ(get_soft_body_meshes, get_num_soft_body_meshes, get_soft_body_mesh);
|
||||
|
||||
unsigned int get_num_ccd_skeletons();
|
||||
PhysxCcdSkeleton *create_ccd_skeleton(PhysxTriangleMeshDesc &desc);
|
||||
PhysxCcdSkeleton *get_ccd_skeleton(unsigned int idx);
|
||||
MAKE_SEQ(get_ccd_skeletons, get_num_ccd_skeletons, get_ccd_skeleton);
|
||||
|
||||
INLINE void ls() const;
|
||||
INLINE void ls(ostream &out, int indent_level=0) const;
|
||||
|
||||
@@ -96,6 +103,7 @@ public:
|
||||
PhysxObjectCollection<PhysxTriangleMesh> _triangle_meshes;
|
||||
PhysxObjectCollection<PhysxClothMesh> _cloth_meshes;
|
||||
PhysxObjectCollection<PhysxSoftBodyMesh> _softbody_meshes;
|
||||
PhysxObjectCollection<PhysxCcdSkeleton> _ccd_skeletons;
|
||||
|
||||
INLINE static NxVec3 vec3_to_nxVec3(const LVector3f &v);
|
||||
INLINE static LVector3f nxVec3_to_vec3(const NxVec3 &v);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "physxCapsule.h"
|
||||
#include "physxRay.h"
|
||||
#include "physxRaycastHit.h"
|
||||
#include "physxCcdSkeleton.h"
|
||||
|
||||
TypeHandle PhysxShape::_type_handle;
|
||||
|
||||
@@ -461,3 +462,30 @@ raycast(const PhysxRay &worldRay, bool firstHit, bool smoothNormal) const {
|
||||
return PhysxRaycastHit(hit);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxShape::set_ccd_skeleton
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysxShape::
|
||||
set_ccd_skeleton(PhysxCcdSkeleton *skel) {
|
||||
|
||||
nassertv(_error_type == ET_ok);
|
||||
|
||||
ptr()->setCCDSkeleton(skel->ptr());
|
||||
_skel = skel;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxShape::get_ccd_skeleton
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PhysxCcdSkeleton *PhysxShape::
|
||||
get_ccd_skeleton() const {
|
||||
|
||||
nassertr(_error_type == ET_ok, NULL);
|
||||
|
||||
return _skel;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ class PhysxBox;
|
||||
class PhysxCapsule;
|
||||
class PhysxRay;
|
||||
class PhysxRaycastHit;
|
||||
class PhysxCcdSkeleton;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PhysxShape
|
||||
@@ -53,6 +54,7 @@ PUBLISHED:
|
||||
void set_material(const PhysxMaterial &material);
|
||||
void set_material_index(unsigned short idx);
|
||||
void set_groups_mask(const PhysxGroupsMask &mask);
|
||||
void set_ccd_skeleton(PhysxCcdSkeleton *skel);
|
||||
|
||||
const char *get_name() const;
|
||||
bool get_flag(const PhysxShapeFlag flag) const;
|
||||
@@ -63,6 +65,7 @@ PUBLISHED:
|
||||
unsigned short get_material_index() const;
|
||||
PhysxGroupsMask get_groups_mask() const;
|
||||
PhysxBounds3 get_world_bounds() const;
|
||||
PhysxCcdSkeleton *get_ccd_skeleton() const;
|
||||
|
||||
bool check_overlap_aabb(const PhysxBounds3 &world_bounds) const;
|
||||
bool check_overlap_capsule(const PhysxCapsule &world_capsule) const;
|
||||
@@ -86,6 +89,7 @@ protected:
|
||||
|
||||
private:
|
||||
string _name;
|
||||
PT(PhysxCcdSkeleton) _skel;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user