15 #include "physxShape.h"
16 #include "physxManager.h"
17 #include "physxActor.h"
18 #include "physxBoxShape.h"
19 #include "physxCapsuleShape.h"
20 #include "physxPlaneShape.h"
21 #include "physxSphereShape.h"
22 #include "physxConvexShape.h"
23 #include "physxHeightFieldShape.h"
24 #include "physxTriangleMeshShape.h"
25 #include "physxWheelShape.h"
26 #include "physxGroupsMask.h"
27 #include "physxBounds3.h"
28 #include "physxSphere.h"
30 #include "physxCapsule.h"
32 #include "physxRaycastHit.h"
33 #include "physxCcdSkeleton.h"
45 nassertv(_error_type == ET_ok);
48 ptr()->getActor().releaseShape(*ptr());
57 factory(NxShapeType shapeType) {
70 case NX_SHAPE_CAPSULE:
79 case NX_SHAPE_HEIGHTFIELD:
86 physx_cat.error() <<
"Unknown shape type.\n";
99 nassertr(_error_type == ET_ok, NULL);
100 return (
PhysxActor *)(ptr()->getActor().userData);
114 nassertv(_error_type == ET_ok);
116 _name = name ? name :
"";
117 ptr()->setName(_name.c_str());
128 nassertr(_error_type == ET_ok,
"");
129 return ptr()->getName();
151 nassertv(_error_type == ET_ok);
153 ptr()->setFlag((NxShapeFlag)flag, value);
164 nassertr(_error_type == ET_ok,
false);
166 return (ptr()->getFlag((NxShapeFlag)flag)) ?
true :
false;
178 nassertv(_error_type == ET_ok);
179 nassertv(skinWidth >= 0.0f);
181 ptr()->setSkinWidth(skinWidth);
192 nassertr(_error_type == ET_ok, 0.0f);
194 return ptr()->getSkinWidth();
211 nassertv(_error_type == ET_ok);
212 nassertv(group < 32);
214 ptr()->setGroup(group);
227 nassertr(_error_type == ET_ok, 0);
229 return ptr()->getGroup();
249 nassertv(_error_type == ET_ok);
285 nassertv(_error_type == ET_ok);
313 nassertr(_error_type == ET_ok, 0);
314 NxMaterialIndex index = ptr()->getMaterial();
315 return (
unsigned int)index;
326 nassertv(_error_type == ET_ok);
327 ptr()->setMaterial(material.ptr()->getMaterialIndex());
344 nassertv(_error_type == ET_ok);
345 ptr()->setMaterial((NxMaterialIndex)index);
358 nassertv(_error_type == ET_ok);
359 ptr()->setGroupsMask(mask.get_mask());
371 nassertr(_error_type == ET_ok, mask);
372 mask.set_mask(ptr()->getGroupsMask());
385 nassertr(_error_type == ET_ok, bounds);
386 ptr()->getWorldBounds(bounds._bounds);
399 nassertr(_error_type == ET_ok,
false);
400 return ptr()->checkOverlapAABB(world_bounds._bounds);
412 nassertr(_error_type == ET_ok,
false);
413 return ptr()->checkOverlapCapsule(world_capsule._capsule);
425 nassertr(_error_type == ET_ok,
false);
426 return ptr()->checkOverlapOBB(world_box._box);
438 nassertr(_error_type == ET_ok,
false);
439 return ptr()->checkOverlapSphere(world_sphere._sphere);
448 raycast(
const PhysxRay &worldRay,
bool firstHit,
bool smoothNormal)
const {
451 nassertr(_error_type == ET_ok, hit);
453 NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE;
454 if (smoothNormal ==
true) {
455 hints |= NX_RAYCAST_NORMAL;
458 hints |= NX_RAYCAST_FACE_NORMAL;
461 ptr()->raycast(worldRay._ray, worldRay._length, hints, hit, firstHit);
473 nassertv(_error_type == ET_ok);
475 ptr()->setCCDSkeleton(skel->ptr());
485 get_ccd_skeleton()
const {
487 nassertr(_error_type == ET_ok, NULL);
unsigned short get_material_index() const
Returns the material index currently assigned to the shape.
Represents a sphere defined by its center point and radius.
LMatrix4f get_local_mat() const
Retrieve the transform of the shape in actor space, i.e.
void set_group(unsigned short group)
Sets which collision group this shape is part of.
void set_local_mat(const LMatrix4f &mat)
Set the transform of the shape in actor space, i.e.
Represents an oriented bounding box, as a center point, extents(radii) and a rotation.
bool get_flag(const PhysxShapeFlag flag) const
Returns the specified shape flag.
static const LPoint3f & zero()
Returns a zero-length point.
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Abstract base class for shapes.
This class is a shape instance of a height field object of type PhysxHeightField. ...
Represention of a axis aligned bounding box.
A plane collision detection primitive.
bool check_overlap_capsule(const PhysxCapsule &world_capsule) const
Checks whether the shape overlaps a world-space capsule or not.
A sphere shaped collision detection primitive.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
void set_flag(const PhysxShapeFlag flag, bool value)
Sets the specified shape flag.
bool check_overlap_aabb(const PhysxBounds3 &world_bounds) const
Checks whether the shape overlaps a world-space AABB or not.
A class for describing a shape's surface properties.
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
PhysxActor * get_actor() const
Retrieves the actor which this shape is associated with.
LPoint3f get_local_pos() const
Retrieve the position of the shape in actor space, i.e.
void set_material(const PhysxMaterial &material)
Assigns a material to the shape.
void set_local_pos(const LPoint3f &pos)
Set the position of the shape in actor space, i.e.
This structure captures results for a single raycast query.
void set_skin_width(float skinWidth)
Sets the skin width.
const char * get_name() const
Returns the name string.
PhysxBounds3 get_world_bounds() const
Returns a world space AABB enclosing this shape.
This is a 4-by-4 transform matrix.
A box shaped collision detection primitive.
A special shape used for simulating a car wheel.
Actors are the main simulation objects.
bool check_overlap_obb(const PhysxBox &world_box) const
Checks whether the shape overlaps a world-space OBB or not.
static const LMatrix4f & zeros_mat()
Returns an matrix filled with zeros.
void set_material_index(unsigned short idx)
Assigns a material index to the shape.
A shapes which is used to represent an instance of an convex mesh.
void set_name(const char *name)
Sets a name string for this object.
PhysxGroupsMask get_groups_mask() const
Gets 128-bit mask used for collision filtering.
void set_groups_mask(const PhysxGroupsMask &mask)
Sets 128-bit mask used for collision filtering.
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
float get_skin_width() const
Returns the skin width.
TypeHandle is the identifier used to differentiate C++ class types.
static LMatrix4f nxMat34_to_mat4(const NxMat34 &m)
Converts from NxMat34 to LMatrix4f.
A capsule shaped collision detection primitive, also known as a line swept sphere.
Represents an ray as an origin and direction.
A shapes which is used to represent an instance of an convex mesh.
bool check_overlap_sphere(const PhysxSphere &world_sphere) const
Checks whether the shape overlaps a world-space sphere or not.
unsigned short get_group() const
Retrieves the collision group set for this shape.