Panda3D
physxUtilLib.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file physxUtilLib.h
10  * @author enn0x
11  * @date 2009-11-01
12  */
13 
14 #ifndef PHYSXUTILLIB_H
15 #define PHYSXUTILLIB_H
16 
17 #include "pandabase.h"
18 #include "luse.h"
19 
20 #include "config_physx.h"
21 
22 class PhysxBounds3;
23 class PhysxBox;
24 class PhysxCapsule;
25 class PhysxPlane;
26 class PhysxRay;
27 class PhysxSegment;
28 class PhysxSphere;
29 
30 /**
31  *
32  */
33 class EXPCL_PANDAPHYSX PhysxUtilLib {
34 
35 PUBLISHED:
36  INLINE PhysxUtilLib();
37  INLINE ~PhysxUtilLib();
38 
39  bool box_contains_point(const PhysxBox &box, const LPoint3f &p);
40  PhysxBox create_box(const PhysxBounds3 &aabb, const LMatrix4f &mat);
41  LVector3f compute_box_world_edge_normal(const PhysxBox &box, unsigned int edge_index);
42  PhysxCapsule compute_capsule_around_box(const PhysxBox &box);
43  bool is_box_a_inside_box_b(const PhysxBox &a, const PhysxBox &b);
44  PhysxBox compute_box_around_capsule(const PhysxCapsule &capsule);
45  void set_fpu_exceptions(bool b);
46  void set_fpu_precision24();
47  void set_fpu_precision53();
48  void set_fpu_precision64();
49  void set_fpu_rounding_chop();
50  void set_fpu_rounding_down();
51  void set_fpu_rounding_near();
52  void set_fpu_rounding_up();
53  int int_ceil(const float &f);
54  int int_chop(const float &f);
55  int int_floor(const float &f);
56  float compute_distance_squared(const PhysxRay &ray, const LPoint3f &point);
57  float compute_square_distance(const PhysxSegment &seg, const LPoint3f &point);
58  PhysxSphere merge_spheres(const PhysxSphere &sphere0, const PhysxSphere &sphere1);
59  void normal_to_tangents(const LVector3f &n, LVector3f &t1, LVector3f &t2);
60  LMatrix3f find_rotation_matrix(const LVector3f &x, const LVector3f &b);
61  float compute_sphere_mass(float radius, float density);
62  float compute_sphere_density(float radius, float mass);
63  float compute_box_mass(const LVector3f &extents, float density);
64  float compute_box_density(const LVector3f &extents, float mass);
65  float compute_ellipsoid_mass(const LVector3f &extents, float density);
66  float compute_ellipsoid_density(const LVector3f &extents, float mass);
67  float compute_cylinder_mass(float radius, float length, float density);
68  float compute_cylinder_density(float radius, float length, float mass);
69  float compute_cone_mass(float radius, float length, float density);
70  float compute_cone_density(float radius, float length, float mass);
71  LVector3f compute_box_inertia_tensor(float mass, float xlength, float ylength, float zlength);
72  LVector3f compute_sphere_inertia_tensor(float mass, float radius, bool hollow);
73  bool box_box_intersect(const LVector3f &extents0, const LPoint3f &center0, const LMatrix3f &rotation0, const LVector3f &extents1, const LPoint3f &center1, const LMatrix3f &rotation1, bool full_test);
74  bool tri_box_intersect(const LPoint3f &vertex0, const LPoint3f &vertex1, const LPoint3f &vertex2, const LPoint3f &center, const LVector3f &extents);
75  bool ray_plane_intersect(const PhysxRay &ray, const PhysxPlane &plane, LPoint3f &point_on_plane);
76  bool ray_sphere_intersect(const LPoint3f &origin, const LVector3f &dir, float length, const LPoint3f &center, float radius, LPoint3f &hit_pos);
77  bool segment_box_intersect(const LPoint3f &p1, const LPoint3f &p2, const LPoint3f &bbox_min, const LPoint3f &bbox_max, LPoint3f &intercept);
78  bool ray_aabb_intersect(const LPoint3f &min, const LPoint3f &max, const LPoint3f &origin, const LVector3f &dir, LPoint3f &coord);
79  bool segment_obb_intersect(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f &center, const LVector3f &extents, const LMatrix3f &rot);
80  bool segment_aabb_intersect(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f &min, const LPoint3f &max);
81  bool ray_obb_intersect(const PhysxRay &ray, const LPoint3f &center, const LVector3f &extents, const LMatrix3f &rot);
82  unsigned int ray_capsule_intersect(const LPoint3f &origin, const LVector3f &dir, const PhysxCapsule &capsule);
83  bool swept_spheres_intersect(const PhysxSphere &sphere0, const LVector3f &velocity0, const PhysxSphere &sphere1, const LVector3f &velocity1);
84  bool ray_tri_intersect(const LPoint3f &orig, const LVector3f &dir, const LPoint3f &vert0, const LPoint3f &vert1, const LPoint3f &vert2, LVector3f &hit, bool cull);
85  bool sweep_box_capsule(const PhysxBox &box, const PhysxCapsule &lss, const LVector3f &dir, float length, LVector3f &normal);
86  bool sweep_box_sphere(const PhysxBox &box, const PhysxSphere &sphere, const LVector3f &dir, float length, LVector3f &normal);
87  bool sweep_capsule_capsule(const PhysxCapsule &lss0, const PhysxCapsule &lss1, const LVector3f &dir, float length, LPoint3f &ip, LVector3f &normal);
88  bool sweep_sphere_capsule(const PhysxSphere &sphere, const PhysxCapsule &lss, const LVector3f &dir, float length, LPoint3f &ip, LVector3f &normal);
89  bool sweep_box_box(const PhysxBox &box0, const PhysxBox &box1, const LVector3f &dir, float length, LPoint3f &ip, LVector3f &normal);
90  float point_obb_sqr_dist(const LPoint3f &point, const LPoint3f &center, const LVector3f &extents, const LMatrix3f &rot, LPoint3f &params);
91 
92 public:
93  NxUtilLib *_ptr;
94 };
95 
96 #include "physxUtilLib.I"
97 
98 #endif // PHYSUTILLIB_H
99 
100 /*
101 NOT WRAPPED:
102 bool NxComputeBoxPlanes(const NxBox &box, NxPlane *planes)
103 bool NxComputeBoxPoints(const NxBox &box, NxVec3 *pts)
104 bool NxComputeBoxVertexNormals(const NxBox &box, NxVec3 *pts)
105 const NxU32 *NxGetBoxEdges()
106 const NxI32 *NxGetBoxEdgesAxes()
107 const NxU32 *NxGetBoxTriangles()
108 const NxVec3 *NxGetBoxLocalEdgeNormals()
109 const NxU32 *NxGetBoxQuads()
110 const NxU32 *NxBoxVertexToQuad(NxU32 vertexIndex)
111 NxBSphereMethod NxComputeSphere(NxSphere &sphere, unsigned nb_verts, const NxVec3 *verts)
112 bool NxFastComputeSphere(NxSphere &sphere, unsigned nb_verts, const NxVec3 *verts)
113 bool NxDiagonalizeInertiaTensor(const NxMat33 &denseInertia, NxVec3 &diagonalInertia, NxMat33 &rotation)
114 void NxComputeBounds(NxVec3 &min, NxVec3 &max, NxU32 nbVerts, const NxVec3 *verts)
115 NxU32 NxCrc32(const void *buffer, NxU32 nbBytes)
116 NxSepAxis NxSeparatingAxis(const NxVec3 &extents0, const NxVec3 &center0, const NxMat33 &rotation0, const NxVec3 &extents1, const NxVec3 &center1, const NxMat33 &rotation1, bool fullTest=true)
117 void NxSegmentPlaneIntersect(const NxVec3 &v1, const NxVec3 &v2, const NxPlane &plane, NxReal &dist, NxVec3 &pointOnPlane)
118 NxU32 NxRayAABBIntersect2(const NxVec3 &min, const NxVec3 &max, const NxVec3 &origin, const NxVec3 &dir, NxVec3 &coord, NxReal &t)
119 bool NxBuildSmoothNormals(NxU32 nbTris, NxU32 nbVerts, const NxVec3 *verts, const NxU32 *dFaces, const NxU16 *wFaces, NxVec3 *normals, bool flip=false)
120 bool NxSweepBoxTriangles(NxU32 nb_tris, const NxTriangle *triangles, const NxTriangle *edge_triangles, const NxU32 *edge_flags, const NxBounds3 &box, const NxVec3 &dir, float length, NxVec3 &hit, NxVec3 &normal, float &d, NxU32 &index, NxU32 *cachedIndex=NULL)
121 bool NxSweepCapsuleTriangles(NxU32 up_direction, NxU32 nb_tris, const NxTriangle *triangles, const NxU32 *edge_flags, const NxVec3 &center, const float radius, const float height, const NxVec3 &dir, float length, NxVec3 &hit, NxVec3 &normal, float &d, NxU32 &index, NxU32 *cachedIndex=NULL)
122 float NxSegmentOBBSqrDist(const NxSegment &segment, const NxVec3 &c0, const NxVec3 &e0, const NxMat33 &r0, float *t, NxVec3 *p)
123 */
Represents a sphere defined by its center point and radius.
Definition: physxSphere.h:25
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents an oriented bounding box, as a center point, extents(radii) and a rotation.
Definition: physxBox.h:29
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represention of a axis aligned bounding box.
Definition: physxBounds3.h:29
Represents a line segment.
Definition: physxSegment.h:25
Represents a capsule.
Definition: physxCapsule.h:25
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents an ray as an origin and direction.
Definition: physxRay.h:26