physxUtilLib.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // Filename: physxUtilLib.h
  2. // Created by: pratt (Apr 7, 2006)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef PHYSXUTILLIB_H
  15. #define PHYSXUTILLIB_H
  16. #ifdef HAVE_PHYSX
  17. #include "pandabase.h"
  18. #include "physx_enumerations.h"
  19. #include "physxManager.h"
  20. #include "luse.h"
  21. class PhysxBounds3;
  22. class PhysxBox;
  23. class PhysxCapsule;
  24. class PhysxJointDesc;
  25. class PhysxPlane;
  26. class PhysxRay;
  27. class PhysxSegment;
  28. class PhysxSphere;
  29. #include "NxPhysics.h"
  30. ////////////////////////////////////////////////////////////////////
  31. // Class : PhysxUtilLib
  32. // Description :
  33. ////////////////////////////////////////////////////////////////////
  34. class EXPCL_PANDAPHYSX PhysxUtilLib {
  35. PUBLISHED:
  36. bool physx_box_box_intersect(const LVecBase3f & extents0, const LVecBase3f & center0, const LMatrix3f & rotation0, const LVecBase3f & extents1, const LVecBase3f & center1, const LMatrix3f & rotation1, bool full_test);
  37. bool physx_box_contains_point(const PhysxBox & box, const LVecBase3f & p);
  38. const unsigned int * physx_box_vertex_to_quad(unsigned int vertex_index);
  39. bool physx_build_smooth_normals(unsigned int nb_tris, unsigned int nb_verts, const LVecBase3f * verts, const unsigned int * d_faces, const unsigned short * w_faces, LVecBase3f * normals, bool flip);
  40. void physx_compute_bounds(LVecBase3f & min, LVecBase3f & max, unsigned int nb_verts, const LVecBase3f * verts);
  41. void physx_compute_box_around_capsule(const PhysxCapsule & capsule, PhysxBox & box);
  42. float physx_compute_box_density(const LVecBase3f & extents, float mass);
  43. void physx_compute_box_inertia_tensor(LVecBase3f & diag_inertia, float mass, float xlength, float ylength, float zlength);
  44. float physx_compute_box_mass(const LVecBase3f & extents, float density);
  45. bool physx_compute_box_planes(const PhysxBox & box, PhysxPlane * planes);
  46. bool physx_compute_box_points(const PhysxBox & box, LVecBase3f * pts);
  47. bool physx_compute_box_vertex_normals(const PhysxBox & box, LVecBase3f * pts);
  48. void physx_compute_box_world_edge_normal(const PhysxBox & box, unsigned int edge_index, LVecBase3f & world_normal);
  49. void physx_compute_capsule_around_box(const PhysxBox & box, PhysxCapsule & capsule);
  50. float physx_compute_cone_density(float radius, float length, float mass);
  51. float physx_compute_cone_mass(float radius, float length, float density);
  52. float physx_compute_cylinder_density(float radius, float length, float mass);
  53. float physx_compute_cylinder_mass(float radius, float length, float density);
  54. float physx_compute_distance_squared(const PhysxRay & ray, const LVecBase3f & point, float * t);
  55. float physx_compute_ellipsoid_density(const LVecBase3f & extents, float mass);
  56. float physx_compute_ellipsoid_mass(const LVecBase3f & extents, float density);
  57. float physx_compute_sphere_density(float radius, float mass);
  58. void physx_compute_sphere_inertia_tensor(LVecBase3f & diag_inertia, float mass, float radius, bool hollow);
  59. float physx_compute_sphere_mass(float radius, float density);
  60. float physx_compute_square_distance(const PhysxSegment & seg, const LVecBase3f & point, float * t);
  61. unsigned int physx_crc32(const void * buffer, unsigned int nb_bytes);
  62. void physx_create_box(PhysxBox & box, const PhysxBounds3 & aabb, const LMatrix4f & mat);
  63. bool physx_diagonalize_inertia_tensor(const LMatrix3f & dense_inertia, LVecBase3f & diagonal_inertia, LMatrix3f & rotation);
  64. bool physx_fast_compute_sphere(PhysxSphere & sphere, unsigned nb_verts, const LVecBase3f * verts);
  65. void physx_find_rotation_matrix(const LVecBase3f & x, const LVecBase3f & b, LMatrix3f & m);
  66. const unsigned int * physx_get_box_edges();
  67. const int * physx_get_box_edges_axes();
  68. const LVecBase3f * physx_get_box_local_edge_normals();
  69. const unsigned int * physx_get_box_quads();
  70. const unsigned int * physx_get_box_triangles();
  71. int physx_int_ceil(const float & f);
  72. int physx_int_chop(const float & f);
  73. int physx_int_floor(const float & f);
  74. bool physx_is_box_a_inside_box_b(const PhysxBox & a, const PhysxBox & b);
  75. void physx_joint_desc__set_global_anchor(PhysxJointDesc & dis, const LVecBase3f & ws_anchor);
  76. void physx_joint_desc__set_global_axis(PhysxJointDesc & dis, const LVecBase3f & ws_axis);
  77. void physx_merge_spheres(PhysxSphere & merged, const PhysxSphere & sphere0, const PhysxSphere & sphere1);
  78. void physx_normal_to_tangents(const LVecBase3f & n, LVecBase3f & t1, LVecBase3f & t2);
  79. bool physx_ray_aabb_intersect(const LVecBase3f & min, const LVecBase3f & max, const LVecBase3f & origin, const LVecBase3f & dir, LVecBase3f & coord);
  80. unsigned int physx_ray_aabb_intersect2(const LVecBase3f & min, const LVecBase3f & max, const LVecBase3f & origin, const LVecBase3f & dir, LVecBase3f & coord, float & t);
  81. bool physx_ray_obb_intersect(const PhysxRay & ray, const LVecBase3f & center, const LVecBase3f & extents, const LMatrix3f & rot);
  82. bool physx_ray_plane_intersect(const PhysxRay & ray, const PhysxPlane & plane, float & dist, LVecBase3f & point_on_plane);
  83. bool physx_ray_sphere_intersect(const LVecBase3f & origin, const LVecBase3f & dir, float length, const LVecBase3f & center, float radius, float & hit_time, LVecBase3f & hit_pos);
  84. bool physx_ray_tri_intersect(const LVecBase3f & orig, const LVecBase3f & dir, const LVecBase3f & vert0, const LVecBase3f & vert1, const LVecBase3f & vert2, float & t, float & u, float & v, bool cull);
  85. bool physx_segment_aabb_intersect(const LVecBase3f & p0, const LVecBase3f & p1, const LVecBase3f & min, const LVecBase3f & max);
  86. bool physx_segment_box_intersect(const LVecBase3f & p1, const LVecBase3f & p2, const LVecBase3f & bbox_min, const LVecBase3f & bbox_max, LVecBase3f & intercept);
  87. bool physx_segment_obb_intersect(const LVecBase3f & p0, const LVecBase3f & p1, const LVecBase3f & center, const LVecBase3f & extents, const LMatrix3f & rot);
  88. float physx_segment_obb_sqr_dist(const PhysxSegment & segment, const LVecBase3f & c0, const LVecBase3f & e0, const LMatrix3f & r0, float * t, LVecBase3f * p);
  89. void physx_segment_plane_intersect(const LVecBase3f & v1, const LVecBase3f & v2, const PhysxPlane & plane, float & dist, LVecBase3f & point_on_plane);
  90. PhysxSepAxis physx_separating_axis(const LVecBase3f & extents0, const LVecBase3f & center0, const LMatrix3f & rotation0, const LVecBase3f & extents1, const LVecBase3f & center1, const LMatrix3f & rotation1, bool full_test);
  91. void physx_set_fpu_exceptions(bool b);
  92. void physx_set_fpu_precision24();
  93. void physx_set_fpu_precision53();
  94. void physx_set_fpu_precision64();
  95. void physx_set_fpu_rounding_chop();
  96. void physx_set_fpu_rounding_down();
  97. void physx_set_fpu_rounding_near();
  98. void physx_set_fpu_rounding_up();
  99. bool physx_sweep_box_box(const PhysxBox & box0, const PhysxBox & box1, const LVecBase3f & dir, float length, LVecBase3f & ip, LVecBase3f & normal, float & min_dist);
  100. bool physx_sweep_box_capsule(const PhysxBox & box, const PhysxCapsule & lss, const LVecBase3f & dir, float length, float & min_dist, LVecBase3f & normal);
  101. bool physx_sweep_box_sphere(const PhysxBox & box, const PhysxSphere & sphere, const LVecBase3f & dir, float length, float & min_dist, LVecBase3f & normal);
  102. bool physx_sweep_capsule_capsule(const PhysxCapsule & lss0, const PhysxCapsule & lss1, const LVecBase3f & dir, float length, float & min_dist, LVecBase3f & ip, LVecBase3f & normal);
  103. bool physx_sweep_sphere_capsule(const PhysxSphere & sphere, const PhysxCapsule & lss, const LVecBase3f & dir, float length, float & min_dist, LVecBase3f & ip, LVecBase3f & normal);
  104. bool physx_swept_spheres_intersect(const PhysxSphere & sphere0, const LVecBase3f & velocity0, const PhysxSphere & sphere1, const LVecBase3f & velocity1);
  105. bool physx_tri_box_intersect(const LVecBase3f & vertex0, const LVecBase3f & vertex1, const LVecBase3f & vertex2, const LVecBase3f & center, const LVecBase3f & extents);
  106. public:
  107. NxUtilLib *nUtilLib;
  108. };
  109. #include "physxUtilLib.I"
  110. #endif // HAVE_PHYSX
  111. #endif // PHYSXUTILLIB_H