Browse Source

Merging dev_physx_2009 to HEAD.

enn0x 16 years ago
parent
commit
1a7942b40c
100 changed files with 7429 additions and 4174 deletions
  1. 28 0
      dtool/src/parser-inc/NxBoxController.h
  2. 28 0
      dtool/src/parser-inc/NxCapsuleController.h
  3. 0 2
      dtool/src/parser-inc/NxCloth.h
  4. 30 0
      dtool/src/parser-inc/NxController.h
  5. 25 0
      dtool/src/parser-inc/NxControllerManager.h
  6. 25 0
      dtool/src/parser-inc/NxCooking.h
  7. 25 0
      dtool/src/parser-inc/NxExtended.h
  8. 0 2
      dtool/src/parser-inc/NxFluid.h
  9. 125 147
      dtool/src/parser-inc/NxPhysics.h
  10. 25 0
      dtool/src/parser-inc/NxStream.h
  11. 3 1
      dtool/src/parser-inc/Sources.pp
  12. 68 1
      makepanda/makepanda.py
  13. 40 0
      makepanda/makepandacore.py
  14. 19 15
      panda/metalibs/pandaphysx/Sources.pp
  15. 1 6
      panda/metalibs/pandaphysx/pandaphysx.cxx
  16. 1 1
      panda/metalibs/pandaphysx/pandaphysx.h
  17. 1 1
      panda/src/physx/NoMinMax.h
  18. 267 55
      panda/src/physx/Sources.pp
  19. 0 39
      panda/src/physx/SourcesTemplate.pp
  20. 97 18
      panda/src/physx/config_physx.cxx
  21. 10 43
      panda/src/physx/config_physx.h
  22. 0 19
      panda/src/physx/createComposite.py
  23. 0 1021
      panda/src/physx/generateCode.py
  24. 72 0
      panda/src/physx/physxActor.I
  25. 1663 0
      panda/src/physx/physxActor.cxx
  26. 227 0
      panda/src/physx/physxActor.h
  27. 27 43
      panda/src/physx/physxActorDesc.I
  28. 126 37
      panda/src/physx/physxActorDesc.cxx
  29. 24 24
      panda/src/physx/physxActorDesc.h
  30. 0 79
      panda/src/physx/physxActorNode.I
  31. 0 1190
      panda/src/physx/physxActorNode.cxx
  32. 0 178
      panda/src/physx/physxActorNode.h
  33. 22 238
      panda/src/physx/physxBodyDesc.I
  34. 355 51
      panda/src/physx/physxBodyDesc.cxx
  35. 47 45
      panda/src/physx/physxBodyDesc.h
  36. 11 170
      panda/src/physx/physxBounds3.I
  37. 230 43
      panda/src/physx/physxBounds3.cxx
  38. 33 32
      panda/src/physx/physxBounds3.h
  39. 11 26
      panda/src/physx/physxBox.I
  40. 72 59
      panda/src/physx/physxBox.cxx
  41. 21 23
      panda/src/physx/physxBox.h
  42. 16 14
      panda/src/physx/physxBoxController.I
  43. 85 0
      panda/src/physx/physxBoxController.cxx
  44. 72 0
      panda/src/physx/physxBoxController.h
  45. 59 0
      panda/src/physx/physxBoxControllerDesc.I
  46. 43 0
      panda/src/physx/physxBoxControllerDesc.cxx
  47. 49 0
      panda/src/physx/physxBoxControllerDesc.h
  48. 16 28
      panda/src/physx/physxBoxForceFieldShape.I
  49. 96 0
      panda/src/physx/physxBoxForceFieldShape.cxx
  50. 77 0
      panda/src/physx/physxBoxForceFieldShape.h
  51. 59 0
      panda/src/physx/physxBoxForceFieldShapeDesc.I
  52. 44 0
      panda/src/physx/physxBoxForceFieldShapeDesc.cxx
  53. 50 0
      panda/src/physx/physxBoxForceFieldShapeDesc.h
  54. 23 1
      panda/src/physx/physxBoxShape.I
  55. 53 31
      panda/src/physx/physxBoxShape.cxx
  56. 34 19
      panda/src/physx/physxBoxShape.h
  57. 36 11
      panda/src/physx/physxBoxShapeDesc.I
  58. 18 28
      panda/src/physx/physxBoxShapeDesc.cxx
  59. 12 15
      panda/src/physx/physxBoxShapeDesc.h
  60. 23 15
      panda/src/physx/physxCapsule.I
  61. 141 15
      panda/src/physx/physxCapsule.cxx
  62. 22 19
      panda/src/physx/physxCapsule.h
  63. 36 0
      panda/src/physx/physxCapsuleController.I
  64. 108 0
      panda/src/physx/physxCapsuleController.cxx
  65. 90 0
      panda/src/physx/physxCapsuleController.h
  66. 59 0
      panda/src/physx/physxCapsuleControllerDesc.I
  67. 64 0
      panda/src/physx/physxCapsuleControllerDesc.cxx
  68. 50 0
      panda/src/physx/physxCapsuleControllerDesc.h
  69. 36 0
      panda/src/physx/physxCapsuleForceFieldShape.I
  70. 111 0
      panda/src/physx/physxCapsuleForceFieldShape.cxx
  71. 81 0
      panda/src/physx/physxCapsuleForceFieldShape.h
  72. 59 0
      panda/src/physx/physxCapsuleForceFieldShapeDesc.I
  73. 64 0
      panda/src/physx/physxCapsuleForceFieldShapeDesc.cxx
  74. 51 0
      panda/src/physx/physxCapsuleForceFieldShapeDesc.h
  75. 23 1
      panda/src/physx/physxCapsuleShape.I
  76. 54 52
      panda/src/physx/physxCapsuleShape.cxx
  77. 41 21
      panda/src/physx/physxCapsuleShape.h
  78. 25 60
      panda/src/physx/physxCapsuleShapeDesc.I
  79. 41 10
      panda/src/physx/physxCapsuleShapeDesc.cxx
  80. 13 19
      panda/src/physx/physxCapsuleShapeDesc.h
  81. 57 0
      panda/src/physx/physxConstraintDominance.I
  82. 60 0
      panda/src/physx/physxConstraintDominance.cxx
  83. 57 0
      panda/src/physx/physxConstraintDominance.h
  84. 0 129
      panda/src/physx/physxContactHandler.cxx
  85. 0 67
      panda/src/physx/physxContactHandler.h
  86. 36 0
      panda/src/physx/physxContactPair.I
  87. 129 0
      panda/src/physx/physxContactPair.cxx
  88. 79 0
      panda/src/physx/physxContactPair.h
  89. 36 0
      panda/src/physx/physxContactPoint.I
  90. 114 0
      panda/src/physx/physxContactPoint.cxx
  91. 82 0
      panda/src/physx/physxContactPoint.h
  92. 36 0
      panda/src/physx/physxContactReport.I
  93. 101 0
      panda/src/physx/physxContactReport.cxx
  94. 48 0
      panda/src/physx/physxContactReport.h
  95. 79 0
      panda/src/physx/physxController.I
  96. 389 0
      panda/src/physx/physxController.cxx
  97. 120 0
      panda/src/physx/physxController.h
  98. 11 10
      panda/src/physx/physxControllerDesc.I
  99. 148 0
      panda/src/physx/physxControllerDesc.cxx
  100. 54 0
      panda/src/physx/physxControllerDesc.h

+ 28 - 0
dtool/src/parser-inc/NxBoxController.h

@@ -0,0 +1,28 @@
+// Filename: NxBoxController.h
+// Created by:  enn0x (22Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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."
+//
+////////////////////////////////////////////////////////////////////
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef NXBOXCONTROLLER_H
+#define NXBOXCONTROLLER_H
+
+class NxBoxController;
+class NxBoxControllerDesc;
+class NxControllerDesc;
+class NxController;
+
+#endif  // NXBOXCONTROLLER_H

+ 28 - 0
dtool/src/parser-inc/NxCapsuleController.h

@@ -0,0 +1,28 @@
+// Filename: NxCapsuleController.h
+// Created by:  enn0x (22Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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."
+//
+////////////////////////////////////////////////////////////////////
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef NXCAPSULECONTROLLER_H
+#define NXCAPSULECONTROLLER_H
+
+class NxCapsuleController;
+class NxCapsuleControllerDesc;
+class NxControllerDesc;
+class NxController;
+
+#endif  // NXCAPSULECONTROLLER_H

+ 0 - 2
dtool/src/parser-inc/NxCloth.h

@@ -1,2 +0,0 @@
-#undef NX_USE_CLOTH_API
-#define NX_USE_CLOTH_API false

+ 30 - 0
dtool/src/parser-inc/NxController.h

@@ -0,0 +1,30 @@
+// Filename: NxController.h
+// Created by:  enn0x (22Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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."
+//
+////////////////////////////////////////////////////////////////////
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef NXCONTROLLER_H
+#define NXCONTROLLER_H
+
+class NxController;
+class NxControllerDesc;
+class NxUserControllerHitReport;
+class NxControllerShapeHit;
+class NxControllersHit;
+class NxControllerAction;
+
+#endif  // NXCONTROLLER_H

+ 25 - 0
dtool/src/parser-inc/NxControllerManager.h

@@ -0,0 +1,25 @@
+// Filename: NxControllerManager.h
+// Created by:  enn0x (22Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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."
+//
+////////////////////////////////////////////////////////////////////
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef NXCONTROLLERMANAGER_H
+#define NXCONTROLLERMANAGER_H
+
+class NxControllerManager;
+
+#endif  // NXCONTROLLERMANAGER_H

+ 25 - 0
dtool/src/parser-inc/NxCooking.h

@@ -0,0 +1,25 @@
+// Filename: NxCooking.h
+// Created by:  enn0x (12Oct09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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."
+//
+////////////////////////////////////////////////////////////////////
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef NX_COOKING_H
+#define NX_COOKING_H
+
+class NxCookingInterface;
+
+#endif  // NX_COOKING_H

+ 25 - 0
dtool/src/parser-inc/NxExtended.h

@@ -0,0 +1,25 @@
+// Filename: NxExtended.h
+// Created by:  enn0x (02Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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."
+//
+////////////////////////////////////////////////////////////////////
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef NXEXTENDED_H
+#define NXEXTENDED_H
+
+class NxExtendedVec3;
+
+#endif  // NXEXTENDED_H

+ 0 - 2
dtool/src/parser-inc/NxFluid.h

@@ -1,2 +0,0 @@
-#undef NX_USE_FLUID_API
-#define NX_USE_FLUID_API false

+ 125 - 147
dtool/src/parser-inc/NxPhysics.h

@@ -1,5 +1,5 @@
 // Filename: NxPhysics.h
-// Created by:  pratt (Apr 26, 2006)
+// Created by:  enn0x (02Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -20,151 +20,129 @@
 #ifndef NXPHYSICS_H
 #define NXPHYSICS_H
 
-#define NX_CALL_CONV
-
-
-#include "NxFoundation.h"   //include the all of the foundation SDK 
-
-
-//////////////general:
-
-#include "NxScene.h"
-#include "NxSceneDesc.h"
-
-#include "NxActor.h"
-#include "NxActorDesc.h"
-
-#include "NxMaterial.h"
-#include "NxMaterialDesc.h"
-
-#include "NxContactStreamIterator.h"
-
-#include "NxUserContactReport.h"
-#include "NxUserNotify.h"
-#include "NxUserRaycastReport.h"
-#include "NxUserEntityReport.h"
-
-#include "NxBodyDesc.h"
-
-#include "NxEffector.h"
-
-#include "NxSpringAndDamperEffector.h"
-#include "NxSpringAndDamperEffectorDesc.h"
-
-#include "NxScheduler.h"
-
-//#if NX_USE_FLUID_API
-//#include "fluids/NxFluid.h"
-//#include "fluids/NxFluidDesc.h"
-//#include "fluids/NxFluidEmitter.h"
-//#include "fluids/NxFluidEmitterDesc.h"
-//#endif
-//
-//#if NX_USE_CLOTH_API
-//#include "cloth/NxCloth.h"
-//#include "cloth/NxClothDesc.h"
-//#endif
-
-#include "NxCCDSkeleton.h"
-#include "NxTriangle.h"
-#include "NxScheduler.h"
-#include "NxSceneStats.h"
-#include "NxSceneStats2.h"
-/////////////joints:
-
-#include "NxJoint.h"
-
-#include "NxJointLimitDesc.h"
-#include "NxJointLimitPairDesc.h"
-#include "NxMotorDesc.h"
-#include "NxSpringDesc.h"
-
-#include "NxPointInPlaneJoint.h"
-#include "NxPointInPlaneJointDesc.h"
-
-#include "NxPointOnLineJoint.h"
-#include "NxPointOnLineJointDesc.h"
-
-#include "NxRevoluteJoint.h"
-#include "NxRevoluteJointDesc.h"
-
-#include "NxPrismaticJoint.h"
-#include "NxPrismaticJointDesc.h"
-
-#include "NxCylindricalJoint.h"
-#include "NxCylindricalJointDesc.h"
-
-#include "NxSphericalJoint.h"
-#include "NxSphericalJointDesc.h"
-
-#include "NxFixedJoint.h"
-#include "NxFixedJointDesc.h"
-
-#include "NxDistanceJoint.h"
-#include "NxDistanceJointDesc.h"
-
-#include "NxPulleyJoint.h"
-#include "NxPulleyJointDesc.h"
-
-#include "NxD6Joint.h"
-#include "NxD6JointDesc.h"
-
-//////////////shapes:
-
-#include "NxShape.h"
-#include "NxShapeDesc.h"
-
-#include "NxBoxShape.h"
-#include "NxBoxShapeDesc.h"
-
-#include "NxCapsuleShape.h"
-#include "NxCapsuleShapeDesc.h"
-
-#include "NxPlaneShape.h"
-#include "NxPlaneShapeDesc.h"
-
-#include "NxSphereShape.h"
-#include "NxSphereShapeDesc.h"
-
-#include "NxTriangleMesh.h"
-#include "NxTriangleMeshDesc.h"
-
-#include "NxTriangleMeshShape.h"
-#include "NxTriangleMeshShapeDesc.h"
-
-#include "NxConvexMesh.h"
-#include "NxConvexMeshDesc.h"
-
-#include "NxConvexShape.h"
-#include "NxConvexShapeDesc.h"
-
-#include "NxHeightField.h"
-#include "NxHeightFieldDesc.h"
-
-#include "NxHeightFieldShape.h"
-#include "NxHeightFieldShapeDesc.h"
-#include "NxHeightFieldSample.h"
-
-#include "NxWheelShape.h"
-#include "NxWheelShapeDesc.h"
-//////////////utils:
-
-#include "NxInertiaTensor.h"
-#include "NxIntersectionBoxBox.h"
-#include "NxIntersectionPointTriangle.h"
-#include "NxIntersectionRayPlane.h"
-#include "NxIntersectionRaySphere.h"
-#include "NxIntersectionRayTriangle.h"
-#include "NxIntersectionSegmentBox.h"
-#include "NxIntersectionSegmentCapsule.h"
-#include "NxIntersectionSweptSpheres.h"
-#include "NxPMap.h"
-#include "NxSmoothNormals.h"
-#include "NxConvexHull.h"
-#include "NxAllocateable.h"
-#include "NxExportedUtils.h"
-
-#include "PhysXLoader.h"
-
+class NxActor;
+class NxActorDesc;
+class NxBodyDesc;
+class NxBoxForceFieldShape;
+class NxBoxForceFieldShapeDesc;
+class NxBoxShape;
+class NxBoxShapeDesc;
+class NxCapsuleForceFieldShape;
+class NxCapsuleForceFieldShapeDesc;
+class NxCapsuleShape;
+class NxCapsuleShapeDesc;
+class NxConvexMesh;
+class NxConvexMeshDesc;
+class NxConvexForceFieldShape;
+class NxConvexForceFieldShapeDesc;
+class NxConvexShape;
+class NxConvexShapeDesc;
+class NxForceField;
+class NxForceFieldDesc;
+class NxForceFieldLinearKernelDesc;
+class NxForceFieldLinearKernel;
+class NxForceFieldShape;
+class NxForceFieldShapeDesc;
+class NxForceFieldShapeGroup;
+class NxForceFieldShapeGroupDesc;
+class NxHeightFieldShape;
+class NxHeightFieldShapeDesc;
+class NxHeightField;
+class NxHeightFieldDesc;
+class NxHeightFieldSample;
+class NxMaterial;
+class NxMaterialDesc;
+class NxPlaneShape;
+class NxPlaneShapeDesc;
+class NxPhysicsSDK;
+class NxRay;
+class NxRaycastHit;
+class NxScene;
+class NxSceneDesc;
+class NxShape;
+class NxShapeDesc;
+class NxSphereForceFieldShape;
+class NxSphereForceFieldShapeDesc;
+class NxSphereShape;
+class NxSphereShapeDesc;
+class NxTriangleMesh;
+class NxTriangleMeshDesc;
+class NxTriangleMeshShape;
+class NxTriangleMeshShapeDesc;
+class NxJointDesc;
+class NxCylindricalJointDesc;
+class NxD6JointDesc;
+class NxDistanceJointDesc;
+class NxFixedJointDesc;
+class NxPointInPlaneJointDesc;
+class NxPointOnLineJointDesc;
+class NxPrismaticJointDesc;
+class NxPulleyJointDesc;
+class NxRevoluteJointDesc;
+class NxSphericalJointDesc;
+class NxJoint;
+class NxCylindricalJoint;
+class NxD6Joint;
+class NxDistanceJoint;
+class NxFixedJoint;
+class NxPointInPlaneJoint;
+class NxPointOnLineJoint;
+class NxPrismaticJoint;
+class NxPulleyJoint;
+class NxRevoluteJoint;
+class NxSphericalJoint;
+class NxMotorDesc;
+class NxSpringDesc;
+class NxJointLimitDesc;
+class NxJointLimitPairDesc;
+class NxJointLimitSoftDesc;
+class NxJointLimitSoftPairDesc;
+class NxJointDriveDesc;
+class NxUserRaycastReport;
+class NxBounds3;
+class NxWheelShape;
+class NxWheelShapeDesc;
+class NxContactPair;
+class NxUserContactReport;
+class NxCloth;
+class NxClothDesc;
+class NxClothMesh;
+class NxClothMeshDesc;
+class NxMeshData;
+class NxConstraintDominance;
+class NxRemoteDebugger;
+class NxGroupsMask;
+class NxSceneStats2;
+
+class NxSoftBody;
+class NxSoftBodyDesc;
+class NxSoftBodyMesh;
+class NxSoftBodyMeshDesc;
+
+enum NxSDKCreateError;
+enum NxAssertResponse;
+enum NxErrorCode;
+enum NxTriggerFlag;
+enum NxHeightFieldAxis;
+
+template<class T> class NxUserEntityReport;
+
+class NxU8;
+class NxU16;
+class NxU32;
+class NxI32;
+class NxReal;
+class NxF32;
+class NxVec3;
+class NxMat33;
+class NxMat34;
+class NxQuat;
+
+class NxBox;
+class NxSphere;
+class NxSegment;
+class NxCapsule;
+class NxPlane;
+class NxUtilLib;
 
 #endif  // NXPHYSICS_H

+ 25 - 0
dtool/src/parser-inc/NxStream.h

@@ -0,0 +1,25 @@
+// Filename: NxStream.h
+// Created by:  enn0x (11Oct09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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."
+//
+////////////////////////////////////////////////////////////////////
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef NX_STREAM_H
+#define NX_STREAM_H
+
+class NxStream;
+
+#endif  // NX_STREAM_H

+ 3 - 1
dtool/src/parser-inc/Sources.pp

@@ -14,7 +14,9 @@
     intfloat_readwrite.h mathematics.h rational.h rtp.h \
     rtsp.h rtspcodes.h setjmp.h tinyxml.h winsock2.h \
     ode/ode.h collision_trimesh.h artools.h \
-    NxPhysics.h cloth/NxCloth.h fluids/NxFluid.h \
+    NxBoxController.h NxCapsuleController.h NxController.h \
+    NxControllerManager.h NxCooking.h NxExtended.h \
+    NxPhysics.h NxStream.h \
     netinet/tcp.h netinet/ip.h sys/socket.h \
     rfftw.h libtar.h malloc.h ucontext.h ctype.h \
     libavutil/avutil.h libavformat/avformat.h \

+ 68 - 1
makepanda/makepanda.py

@@ -54,7 +54,7 @@ PkgListSet(MAYAVERSIONS + MAXVERSIONS + DXVERSIONS + [
   "FMODEX","OPENAL","NVIDIACG","OPENSSL","FREETYPE","WX",
   "FFTW","ARTOOLKIT","SQUISH","ODE","DIRECTCAM","NPAPI",
   "OPENCV","FFMPEG","SWSCALE","FCOLLADA","GTK2","PANDATOOL",
-  "OPENGL","X11","XF86DGA",
+  "OPENGL","X11","XF86DGA","PHYSX",
 ])
 
 CheckPandaSourceTree()
@@ -262,10 +262,12 @@ SdkLocateMacOSX(OSXTARGET)
 SdkLocatePython(RTDIST)
 SdkLocateVisualStudio()
 SdkLocateMSPlatform()
+SdkLocatePhysX()
 
 SdkAutoDisableDirectX()
 SdkAutoDisableMaya()
 SdkAutoDisableMax()
+SdkAutoDisablePhysX()
 
 if (RTDIST and SDK["PYTHONVERSION"] != "python2.6" and DISTRIBUTOR == "cmu"):
     exit("The CMU rtdist distribution must be built against Python 2.6!")
@@ -406,6 +408,19 @@ if (COMPILER=="MSVC"):
             LibName(pkg, SDK[pkg] +  '/lib/mesh.lib')
             LibName(pkg, SDK[pkg] +  '/lib/maxutil.lib')
             LibName(pkg, SDK[pkg] +  '/lib/paramblk2.lib')
+    if (PkgSkip("PHYSX")==0):
+        DefSymbol("PHYSX", SDK["PHYSXVERSION"], "1")
+        DefSymbol("PHYSX", "NX32", "1")
+        LibName("PHYSX",      SDK["PHYSX"] + "/lib/Win32/PhysXLoader.lib")
+        LibName("PHYSX",      SDK["PHYSX"] + "/lib/Win32/NxCharacter.lib")
+        IncDirectory("PHYSX", SDK["PHYSX"] + "/Physics/include")
+        IncDirectory("PHYSX", SDK["PHYSX"] + "/PhysXLoader/include")
+        IncDirectory("PHYSX", SDK["PHYSX"] + "/NxCharacter/include")
+        IncDirectory("PHYSX", SDK["PHYSX"] + "/NxExtensions/include")
+        IncDirectory("PHYSX", SDK["PHYSX"] + "/Foundation/include")
+        IncDirectory("PHYSX", SDK["PHYSX"] + "/Cooking/include")
+        # We need to be able to find NxCharacter.dll when importing code library libpandaphysx
+        AddToPathEnv("PATH", SDK["PHYSX"]+"/../Bin/win32/")
 
 if (COMPILER=="LINUX"):
     if (PkgSkip("PYTHON")==0):
@@ -528,6 +543,21 @@ if (COMPILER=="LINUX"):
             LibName(pkg, "-lIMFbase")
             if (sys.platform == "darwin"):
                 LibName(pkg, "-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib")
+    if (PkgSkip("PHYSX")==0):
+        DefSymbol("PHYSX", SDK["PHYSXVERSION"], "1")
+        DefSymbol("PHYSX", "LINUX", "1")
+        DefSymbol("PHYSX", "CORELIB", "1")
+        DefSymbol("PHYSX", "NX_DISABLE_FLUIDS", "1")
+        DefSymbol("PHYSX", "NX32", "1")
+        IncDirectory("PHYSX", SDK["PHYSX"] + "/Physics/include")
+        IncDirectory("PHYSX", SDK["PHYSX"] + "/PhysXLoader/include")
+        IncDirectory("PHYSX", SDK["PHYSX"] + "/NxCharacter/include")
+        IncDirectory("PHYSX", SDK["PHYSX"] + "/NxExtensions/include")
+        IncDirectory("PHYSX", SDK["PHYSX"] + "/Foundation/include")
+        IncDirectory("PHYSX", SDK["PHYSX"] + "/Cooking/include")
+        LibDirectory("PHYSX", SDK["PHYSXLIBS"])
+        LibName("PHYSX", "-lPhysXLoader")
+        LibName("PHYSX", "-lNxCharacter")
 
 DefSymbol("ALWAYS", "MAKEPANDA", "")
 DefSymbol("WITHINPANDA", "WITHIN_PANDA", "1")
@@ -1872,6 +1902,10 @@ if (PkgSkip("PANDATOOL")==0):
     CopyAllHeaders('pandatool/src/win-stats')
     CopyAllHeaders('pandatool/src/xfileprogs')
 
+if (PkgSkip("PHYSX")==0):
+    CopyAllHeaders('panda/src/physx')
+    CopyAllHeaders('panda/metalibs/pandaphysx')
+
 ########################################################################
 # 
 # These definitions are syntactic shorthand.  They make it easy
@@ -3095,6 +3129,37 @@ if (PkgSkip("ODE")==0 and not RUNTIME):
   TargetAdd('libpandaode.dll', input=COMMON_PANDA_LIBS)
   TargetAdd('libpandaode.dll', opts=['WINUSER', 'ODE'])
 
+#
+# DIRECTORY: panda/src/physx/
+#
+
+if (PkgSkip("PHYSX")==0):
+  OPTS=['DIR:panda/src/physx', 'BUILDING:PANDAPHYSX', 'PHYSX']
+  TargetAdd('physx_composite.obj', opts=OPTS, input='physx_composite.cxx')
+  IGATEFILES=GetDirectoryContents('panda/src/physx', ["*.h", "*_composite.cxx"])
+  TargetAdd('libpandaphysx.in', opts=OPTS, input=IGATEFILES)
+  TargetAdd('libpandaphysx.in', opts=['IMOD:pandaphysx', 'ILIB:libpandaphysx', 'SRCDIR:panda/src/physx'])
+  TargetAdd('libpandaphysx_igate.obj', input='libpandaphysx.in', opts=["DEPENDENCYONLY"])
+
+#
+# DIRECTORY: panda/metalibs/pandaphysx/
+#
+
+if (PkgSkip("PHYSX")==0):
+  OPTS=['DIR:panda/metalibs/pandaphysx', 'BUILDING:PANDAPHYSX', 'PHYSX']
+  TargetAdd('pandaphysx_pandaphysx.obj', opts=OPTS, input='pandaphysx.cxx')
+  
+  TargetAdd('libpandaphysx_module.obj', input='libpandaphysx.in')
+  TargetAdd('libpandaphysx_module.obj', opts=OPTS)
+  TargetAdd('libpandaphysx_module.obj', opts=['IMOD:pandaphysx', 'ILIB:libpandaphysx'])
+  
+  TargetAdd('libpandaphysx.dll', input='pandaphysx_pandaphysx.obj')
+  TargetAdd('libpandaphysx.dll', input='libpandaphysx_module.obj')
+  TargetAdd('libpandaphysx.dll', input='physx_composite.obj')
+  TargetAdd('libpandaphysx.dll', input='libpandaphysx_igate.obj')
+  TargetAdd('libpandaphysx.dll', input=COMMON_PANDA_LIBS)
+  TargetAdd('libpandaphysx.dll', opts=['WINUSER', 'PHYSX'])
+
 #
 # DIRECTORY: panda/src/physics/
 #
@@ -4382,6 +4447,8 @@ if (PkgSkip("PYTHON")==0):
   TargetAdd('PandaModules.py', input='libpandaegg.dll')
   if (PkgSkip("ODE")==0):
     TargetAdd('PandaModules.py', input='libpandaode.dll')
+  if (PkgSkip("PHYSX")==0):
+    TargetAdd('PandaModules.py', input='libpandaphysx.dll')
 
 #
 # Generate the models directory and samples directory

+ 40 - 0
makepanda/makepandacore.py

@@ -574,6 +574,19 @@ def ListRegistryKeys(path):
         _winreg.CloseKey(key)
     return result
 
+def ListRegistryValues(path):
+    result = []
+    index = 0
+    key = TryRegistryKey(path)
+    if (key != 0):
+        try:
+            while (1):
+                result.append(_winreg.EnumValue(key, index)[0])
+                index = index + 1
+        except: pass
+        _winreg.CloseKey(key)
+    return result
+
 def GetRegistryKey(path, subkey):
     if (platform.architecture()[0]=="64bit"):
         path = path.replace("SOFTWARE\\", "SOFTWARE\\Wow6432Node\\")
@@ -1399,6 +1412,27 @@ def SdkLocateMacOSX(osxtarget=None):
     else:
         SDK["MACOSX"] = ""
 
+PHYSXVERSIONINFO=[
+    ("PHYSX281","v2.8.1"),
+    ("PHYSX283","v2.8.3"),
+]
+
+def SdkLocatePhysX():
+    for (ver,key) in PHYSXVERSIONINFO:
+        if (sys.platform == "win32"):
+            folders = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\Folders"
+            for folder in ListRegistryValues(folders):
+                if folder.endswith("NVIDIA PhysX SDK\\%s\\SDKs\\" % key):
+                    SDK["PHYSX"] = folder
+                    SDK["PHYSXVERSION"] = ver
+        elif (sys.platform.startswith("linux")):
+            incpath = "/usr/include/PhysX/%s/SDKs" % key
+            libpath = "/usr/lib/PhysX/%s" % key
+            if (os.path.isdir(incpath) and os.path.isdir(libpath)):
+                SDK["PHYSX"] = incpath
+                SDK["PHYSXVERSION"] = ver
+                SDK["PHYSXLIBS"] = libpath
+
 ########################################################################
 ##
 ## SDK Auto-Disables
@@ -1439,6 +1473,12 @@ def SdkAutoDisableMax():
                 WARNINGS.append("I have automatically added this command-line option: --no-"+version.lower())
             PkgDisable(version)
 
+def SdkAutoDisablePhysX():
+    if ("PHYSX" not in SDK) and (PkgSkip("PHYSX")==0):
+        PkgDisable("PHYSX")
+        WARNINGS.append("I cannot locate SDK for PhysX")
+        WARNINGS.append("I have automatically added this command-line option: --no-physx")
+
 ########################################################################
 ##
 ## Visual Studio comes with a script called VSVARS32.BAT, which 

+ 19 - 15
panda/metalibs/pandaphysx/Sources.pp

@@ -5,24 +5,28 @@
 // under Windows).
 
 #define DIR_TYPE metalib
-#define BUILDING_DLL BUILDING_PANDAPHYSX
 #define BUILD_DIRECTORY $[HAVE_PHYSX]
+#define BUILDING_DLL BUILDING_PANDAPHYSX
 
-#if $[eq $[LINK_IN_PHYSX],]
-  // We don't have any components if we're linking the Physics library
-  // directly into Panda.
-  #define COMPONENT_LIBS \
-      physx
-#endif
+#define COMPONENT_LIBS \
+    physx
 
-#define LOCAL_LIBS linmath putil express
-#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
-    dtoolbase:c dtoolutil:c dtool:m prc:c
+#define LOCAL_LIBS \
+    linmath \
+    putil \
+    express
 
-#begin metalib_target
-  #define TARGET pandaphysx
-
-  #define SOURCES pandaphysx.cxx pandaphysx.h
-  #define INSTALL_HEADERS pandaphysx.h
+#define OTHER_LIBS \
+    interrogatedb:c \
+    dconfig:c \
+    dtoolconfig:m \
+    dtoolbase:c \
+    dtoolutil:c \
+    dtool:m \
+    prc:c
 
+#begin metalib_target
+    #define TARGET pandaphysx
+    #define SOURCES pandaphysx.cxx pandaphysx.h
+    #define INSTALL_HEADERS pandaphysx.h
 #end metalib_target

+ 1 - 6
panda/metalibs/pandaphysx/pandaphysx.cxx

@@ -1,13 +1,10 @@
 // Filename: pandaphysx.cxx
-// Created by:  pratt (Apr 20, 2006)
+// Created by:  pratt (20Apr2006)
 // 
 ////////////////////////////////////////////////////////////////////
 
 #include "pandaphysx.h"
-
-#ifndef LINK_IN_PHYSX
 #include "config_physx.h"
-#endif
 
 // By including checkPandaVersion.h, we guarantee that runtime
 // attempts to load libpandaphysx.so/.dll will fail if they
@@ -25,7 +22,5 @@
 ////////////////////////////////////////////////////////////////////
 void
 init_libpandaphysx() {
-#ifndef LINK_IN_PHYSX
   init_libphysx();
-#endif
 }

+ 1 - 1
panda/metalibs/pandaphysx/pandaphysx.h

@@ -1,5 +1,5 @@
 // Filename: pandaphysx.h
-// Created by:  pratt (Apr 20, 2006)
+// Created by:  pratt (20Apr2006)
 // 
 ////////////////////////////////////////////////////////////////////
 

+ 1 - 1
panda/src/physx/NoMinMax.h

@@ -1,5 +1,5 @@
 // Filename: NoMinMax.h
-// Created by:  pratt (Apr 26, 2006)
+// Created by:  pratt (26Apr2006)
 //
 ////////////////////////////////////////////////////////////////////
 //

+ 267 - 55
panda/src/physx/Sources.pp

@@ -9,130 +9,342 @@
   #define USE_PACKAGES physx
   #define LOCAL_LIBS pgraph linmath
   #define COMBINED_SOURCES $[TARGET]_composite.cxx
-    #define INTERROGATE_OPTIONS $[INTERROGATE_OPTIONS] -DHAVE_PHYSX
+  #define INTERROGATE_OPTIONS $[INTERROGATE_OPTIONS]
 
   #define SOURCES \
     NoMinMax.h \
-        config_physx.h \
-    physxManager.I physxManager.h \
-    physxContactHandler.I physxContactHandler.h \
-    physxTriggerHandler.I physxTriggerHandler.h \
-    physxJointHandler.I physxJointHandler.h \
-    physxActorNode.I physxActorNode.h \
+    config_physx.h \
+    physxActor.I physxActor.h \
     physxActorDesc.I physxActorDesc.h \
     physxBodyDesc.I physxBodyDesc.h \
     physxBounds3.I physxBounds3.h \
     physxBox.I physxBox.h \
-    physxJoint.I physxJoint.h \
+    physxBoxController.I physxBoxController.h \
+    physxBoxControllerDesc.I physxBoxControllerDesc.h \
+    physxBoxForceFieldShape.I physxBoxForceFieldShape.h \
+    physxBoxForceFieldShapeDesc.I physxBoxForceFieldShapeDesc.h \
+    physxBoxShape.I physxBoxShape.h \
+    physxBoxShapeDesc.I physxBoxShapeDesc.h \
+    physxCapsule.I physxCapsule.h \
+    physxCapsuleController.I physxCapsuleController.h \
+    physxCapsuleControllerDesc.I physxCapsuleControllerDesc.h \
+    physxCapsuleForceFieldShape.I physxCapsuleForceFieldShape.h \
+    physxCapsuleForceFieldShapeDesc.I physxCapsuleForceFieldShapeDesc.h \
+    physxCapsuleShape.I physxCapsuleShape.h \
+    physxCapsuleShapeDesc.I physxCapsuleShapeDesc.h \
+    physxConstraintDominance.I physxConstraintDominance.h \
+    physxContactPair.I physxContactPair.h \
+    physxContactPoint.I physxContactPoint.h \
+    physxContactReport.I physxContactReport.h \
+    physxController.I physxController.h \
+    physxControllerDesc.I physxControllerDesc.h \
+    physxControllerReport.I physxControllerReport.h \
+    physxConvexForceFieldShape.I physxConvexForceFieldShape.h \
+    physxConvexForceFieldShapeDesc.I physxConvexForceFieldShapeDesc.h \
+    physxConvexMesh.I physxConvexMesh.h \
+    physxConvexMeshDesc.I physxConvexMeshDesc.h \
+    physxConvexShape.I physxConvexShape.h \
+    physxConvexShapeDesc.I physxConvexShapeDesc.h \
+    physxCylindricalJoint.I physxCylindricalJoint.h \
+    physxCylindricalJointDesc.I physxCylindricalJointDesc.h \
     physxD6Joint.I physxD6Joint.h \
-    physxJointDesc.I physxJointDesc.h \
     physxD6JointDesc.I physxD6JointDesc.h \
+    physxDebugGeomNode.I physxDebugGeomNode.h \
+    physxDistanceJoint.I physxDistanceJoint.h \
+    physxDistanceJointDesc.I physxDistanceJointDesc.h \
+    physxEnums.I physxEnums.h \
+    physxFileStream.I physxFileStream.h \
+    physxFixedJoint.I physxFixedJoint.h \
+    physxFixedJointDesc.I physxFixedJointDesc.h \
+    physxForceField.I physxForceField.h \
+    physxForceFieldDesc.I physxForceFieldDesc.h \
+    physxForceFieldShape.I physxForceFieldShape.h \
+    physxForceFieldShapeDesc.I physxForceFieldShapeDesc.h \
+    physxForceFieldShapeGroup.I physxForceFieldShapeGroup.h \
+    physxForceFieldShapeGroupDesc.I physxForceFieldShapeGroupDesc.h \
+    physxGroupsMask.I physxGroupsMask.h \
+    physxHeightField.I physxHeightField.h \
+    physxHeightFieldDesc.I physxHeightFieldDesc.h \
+    physxHeightFieldShape.I physxHeightFieldShape.h \
+    physxHeightFieldShapeDesc.I physxHeightFieldShapeDesc.h \
+    physxJoint.I physxJoint.h \
+    physxJointDesc.I physxJointDesc.h \
     physxJointDriveDesc.I physxJointDriveDesc.h \
+    physxJointLimitDesc.I physxJointLimitDesc.h \
     physxJointLimitSoftDesc.I physxJointLimitSoftDesc.h \
-    physxJointLimitSoftPairDesc.I physxJointLimitSoftPairDesc.h \
+    physxKitchen.I physxKitchen.h \
+    physxManager.I physxManager.h \
+    physxMask.I physxMask.h \
     physxMaterial.I physxMaterial.h \
     physxMaterialDesc.I physxMaterialDesc.h \
+    physxMemoryReadBuffer.I physxMemoryReadBuffer.h \
+    physxMemoryWriteBuffer.I physxMemoryWriteBuffer.h \
+    physxMeshPool.I physxMeshPool.h \
+    physxMotorDesc.I physxMotorDesc.h \
+    physxObject.I physxObject.h \
+    physxObjectCollection.I physxObjectCollection.h \
+    physxOverlapReport.I physxOverlapReport.h \
     physxPlane.I physxPlane.h \
+    physxPlaneShape.I physxPlaneShape.h \
+    physxPlaneShapeDesc.I physxPlaneShapeDesc.h \
+    physxPointInPlaneJoint.I physxPointInPlaneJoint.h \
+    physxPointInPlaneJointDesc.I physxPointInPlaneJointDesc.h \
+    physxPointOnLineJoint.I physxPointOnLineJoint.h \
+    physxPointOnLineJointDesc.I physxPointOnLineJointDesc.h \
+    physxPrismaticJoint.I physxPrismaticJoint.h \
+    physxPrismaticJointDesc.I physxPrismaticJointDesc.h \
+    physxPulleyJoint.I physxPulleyJoint.h \
+    physxPulleyJointDesc.I physxPulleyJointDesc.h \
     physxRay.I physxRay.h \
+    physxRaycastHit.I physxRaycastHit.h \
+    physxRaycastReport.I physxRaycastReport.h \
+    physxRevoluteJoint.I physxRevoluteJoint.h \
+    physxRevoluteJointDesc.I physxRevoluteJointDesc.h \
     physxScene.I physxScene.h \
     physxSceneDesc.I physxSceneDesc.h \
     physxSceneStats2.I physxSceneStats2.h \
     physxSegment.I physxSegment.h \
-    physxCapsule.I physxCapsule.h \
     physxShape.I physxShape.h \
-    physxBoxShape.I physxBoxShape.h \
-    physxCapsuleShape.I physxCapsuleShape.h \
-    physxPlaneShape.I physxPlaneShape.h \
-    physxSphereShape.I physxSphereShape.h \
     physxShapeDesc.I physxShapeDesc.h \
-    physxBoxShapeDesc.I physxBoxShapeDesc.h \
-    physxCapsuleShapeDesc.I physxCapsuleShapeDesc.h \
-    physxPlaneShapeDesc.I physxPlaneShapeDesc.h \
-    physxSphereShapeDesc.I physxSphereShapeDesc.h \
     physxSphere.I physxSphere.h \
+    physxSphereForceFieldShape.I physxSphereForceFieldShape.h \
+    physxSphereForceFieldShapeDesc.I physxSphereForceFieldShapeDesc.h \
+    physxSphereShape.I physxSphereShape.h \
+    physxSphereShapeDesc.I physxSphereShapeDesc.h \
+    physxSphericalJoint.I physxSphericalJoint.h \
+    physxSphericalJointDesc.I physxSphericalJointDesc.h \
+    physxSpringDesc.I physxSpringDesc.h \
+    physxTriangleMesh.I physxTriangleMesh.h \
+    physxTriangleMeshDesc.I physxTriangleMeshDesc.h \
+    physxTriangleMeshShape.I physxTriangleMeshShape.h \
+    physxTriangleMeshShapeDesc.I physxTriangleMeshShapeDesc.h \
+    physxTriggerReport.I physxTriggerReport.h \
     physxUtilLib.I physxUtilLib.h \
+    physxWheelShape.I physxWheelShape.h \
+    physxWheelShapeDesc.I physxWheelShapeDesc.h \
 
   #define INCLUDED_SOURCES \
-    physxManager.cxx \
-    physxContactHandler.cxx \
-    physxTriggerHandler.cxx \
-    physxJointHandler.cxx \
-    physxActorNode.cxx \
+    physxActor.cxx \
     physxActorDesc.cxx \
     physxBodyDesc.cxx \
     physxBounds3.cxx \
     physxBox.cxx \
-    physxJoint.cxx \
+    physxBoxController.cxx \
+    physxBoxControllerDesc.cxx \
+    physxBoxForceFieldShape.cxx \
+    physxBoxForceFieldShapeDesc.cxx \
+    physxBoxShape.cxx \
+    physxBoxShapeDesc.cxx \
+    physxCapsule.cxx \
+    physxCapsuleController.cxx \
+    physxCapsuleControllerDesc.cxx \
+    physxCapsuleForceFieldShape.cxx \
+    physxCapsuleForceFieldShapeDesc.cxx \
+    physxCapsuleShape.cxx \
+    physxCapsuleShapeDesc.cxx \
+    physxConstraintDominance.cxx \
+    physxContactPair.cxx \
+    physxContactPoint.cxx \
+    physxContactReport.cxx \
+    physxController.cxx \
+    physxControllerDesc.cxx \
+    physxControllerReport.cxx \
+    physxConvexForceFieldShape.cxx \
+    physxConvexForceFieldShapeDesc.cxx \
+    physxConvexMesh.cxx \
+    physxConvexMeshDesc.cxx \
+    physxConvexShape.cxx \
+    physxConvexShapeDesc.cxx \
+    physxCylindricalJoint.cxx \
+    physxCylindricalJointDesc.cxx \
     physxD6Joint.cxx \
-    physxJointDesc.cxx \
     physxD6JointDesc.cxx \
+    physxDebugGeomNode.cxx \
+    physxDistanceJoint.cxx \
+    physxDistanceJointDesc.cxx \
+    physxEnums.cxx \
+    physxFileStream.cxx \
+    physxFixedJoint.cxx \
+    physxFixedJointDesc.cxx \
+    physxForceField.cxx \
+    physxForceFieldDesc.cxx \
+    physxForceFieldShape.cxx \
+    physxForceFieldShapeDesc.cxx \
+    physxForceFieldShapeGroup.cxx \
+    physxForceFieldShapeGroupDesc.cxx \
+    physxGroupsMask.cxx \
+    physxHeightField.cxx \
+    physxHeightFieldDesc.cxx \
+    physxHeightFieldShape.cxx \
+    physxHeightFieldShapeDesc.cxx \
+    physxJoint.cxx \
+    physxJointDesc.cxx \
     physxJointDriveDesc.cxx \
+    physxJointLimitDesc.cxx \
     physxJointLimitSoftDesc.cxx \
-    physxJointLimitSoftPairDesc.cxx \
+    physxKitchen.cxx \
+    physxManager.cxx \
+    physxMask.cxx \
     physxMaterial.cxx \
     physxMaterialDesc.cxx \
+    physxMemoryReadBuffer.cxx \
+    physxMemoryWriteBuffer.cxx \
+    physxMeshPool.cxx \
+    physxMotorDesc.cxx \
+    physxObject.cxx \
+    physxObjectCollection.cxx \
+    physxOverlapReport.cxx \
     physxPlane.cxx \
+    physxPlaneShape.cxx \
+    physxPlaneShapeDesc.cxx \
+    physxPointInPlaneJoint.cxx \
+    physxPointInPlaneJointDesc.cxx \
+    physxPointOnLineJoint.cxx \
+    physxPointOnLineJointDesc.cxx \
+    physxPrismaticJoint.cxx \
+    physxPrismaticJointDesc.cxx \
+    physxPulleyJoint.cxx \
+    physxPulleyJointDesc.cxx \
     physxRay.cxx \
+    physxRaycastHit.cxx \
+    physxRaycastReport.cxx \
+    physxRevoluteJoint.cxx \
+    physxRevoluteJointDesc.cxx \
     physxScene.cxx \
     physxSceneDesc.cxx \
     physxSceneStats2.cxx \
     physxSegment.cxx \
-    physxCapsule.cxx \
     physxShape.cxx \
-    physxBoxShape.cxx \
-    physxCapsuleShape.cxx \
-    physxPlaneShape.cxx \
-    physxSphereShape.cxx \
     physxShapeDesc.cxx \
-    physxBoxShapeDesc.cxx \
-    physxCapsuleShapeDesc.cxx \
-    physxPlaneShapeDesc.cxx \
-    physxSphereShapeDesc.cxx \
     physxSphere.cxx \
+    physxSphereForceFieldShape.cxx \
+    physxSphereForceFieldShapeDesc.cxx \
+    physxSphereShape.cxx \
+    physxSphereShapeDesc.cxx \
+    physxSphericalJoint.cxx \
+    physxSphericalJointDesc.cxx \
+    physxSpringDesc.cxx \
+    physxTriangleMesh.cxx \
+    physxTriangleMeshDesc.cxx \
+    physxTriangleMeshShape.cxx \
+    physxTriangleMeshShapeDesc.cxx \
+    physxTriggerReport.cxx \
     physxUtilLib.cxx \
+    physxWheelShape.cxx \
+    physxWheelShapeDesc.cxx \
 
   #define INSTALL_HEADERS \
     NoMinMax.h \
-        config_physx.h \
-    physxManager.I physxManager.h \
-    physxContactHandler.I physxContactHandler.h \
-    physxTriggerHandler.I physxTriggerHandler.h \
-    physxJointHandler.I physxJointHandler.h \
-    physxActorNode.I physxActorNode.h \
+    config_physx.h \
+    physxActor.I physxActor.h \
     physxActorDesc.I physxActorDesc.h \
     physxBodyDesc.I physxBodyDesc.h \
     physxBounds3.I physxBounds3.h \
     physxBox.I physxBox.h \
-    physxJoint.I physxJoint.h \
+    physxBoxController.I physxBoxController.h \
+    physxBoxControllerDesc.I physxBoxControllerDesc.h \
+    physxBoxForceFieldShape.I physxBoxForceFieldShape.h \
+    physxBoxForceFieldShapeDesc.I physxBoxForceFieldShapeDesc.h \
+    physxBoxShape.I physxBoxShape.h \
+    physxBoxShapeDesc.I physxBoxShapeDesc.h \
+    physxCapsule.I physxCapsule.h \
+    physxCapsuleController.I physxCapsuleController.h \
+    physxCapsuleControllerDesc.I physxCapsuleControllerDesc.h \
+    physxCapsuleForceFieldShape.I physxCapsuleForceFieldShape.h \
+    physxCapsuleForceFieldShapeDesc.I physxCapsuleForceFieldShapeDesc.h \
+    physxCapsuleShape.I physxCapsuleShape.h \
+    physxCapsuleShapeDesc.I physxCapsuleShapeDesc.h \
+    physxConstraintDominance.I physxConstraintDominance.h \
+    physxContactPair.I physxContactPair.h \
+    physxContactPoint.I physxContactPoint.h \
+    physxContactReport.I physxContactReport.h \
+    physxController.I physxController.h \
+    physxControllerDesc.I physxControllerDesc.h \
+    physxControllerReport.I physxControllerReport.h \
+    physxConvexForceFieldShape.I physxConvexForceFieldShape.h \
+    physxConvexForceFieldShapeDesc.I physxConvexForceFieldShapeDesc.h \
+    physxConvexMesh.I physxConvexMesh.h \
+    physxConvexMeshDesc.I physxConvexMeshDesc.h \
+    physxConvexShape.I physxConvexShape.h \
+    physxConvexShapeDesc.I physxConvexShapeDesc.h \
+    physxCylindricalJoint.I physxCylindricalJoint.h \
+    physxCylindricalJointDesc.I physxCylindricalJointDesc.h \
     physxD6Joint.I physxD6Joint.h \
-    physxJointDesc.I physxJointDesc.h \
     physxD6JointDesc.I physxD6JointDesc.h \
+    physxDebugGeomNode.I physxDebugGeomNode.h \
+    physxDistanceJoint.I physxDistanceJoint.h \
+    physxDistanceJointDesc.I physxDistanceJointDesc.h \
+    physxEnums.I physxEnums.h \
+    physxFileStream.I physxFileStream.h \
+    physxFixedJoint.I physxFixedJoint.h \
+    physxFixedJointDesc.I physxFixedJointDesc.h \
+    physxForceField.I physxForceField.h \
+    physxForceFieldDesc.I physxForceFieldDesc.h \
+    physxForceFieldShape.I physxForceFieldShape.h \
+    physxForceFieldShapeDesc.I physxForceFieldShapeDesc.h \
+    physxForceFieldShapeGroup.I physxForceFieldShapeGroup.h \
+    physxForceFieldShapeGroupDesc.I physxForceFieldShapeGroupDesc.h \
+    physxGroupsMask.I physxGroupsMask.h \
+    physxHeightField.I physxHeightField.h \
+    physxHeightFieldDesc.I physxHeightFieldDesc.h \
+    physxHeightFieldShape.I physxHeightFieldShape.h \
+    physxHeightFieldShapeDesc.I physxHeightFieldShapeDesc.h \
+    physxJoint.I physxJoint.h \
+    physxJointDesc.I physxJointDesc.h \
     physxJointDriveDesc.I physxJointDriveDesc.h \
+    physxJointLimitDesc.I physxJointLimitDesc.h \
     physxJointLimitSoftDesc.I physxJointLimitSoftDesc.h \
-    physxJointLimitSoftPairDesc.I physxJointLimitSoftPairDesc.h \
+    physxKitchen.I physxKitchen.h \
+    physxManager.I physxManager.h \
+    physxMask.I physxMask.h \
     physxMaterial.I physxMaterial.h \
     physxMaterialDesc.I physxMaterialDesc.h \
+    physxMemoryReadBuffer.I physxMemoryReadBuffer.h \
+    physxMemoryWriteBuffer.I physxMemoryWriteBuffer.h \
+    physxMeshPool.I physxMeshPool.h \
+    physxMotorDesc.I physxMotorDesc.h \
+    physxObject.I physxObject.h \
+    physxObjectCollection.I physxObjectCollection.h \
+    physxOverlapReport.I physxOverlapReport.h \
     physxPlane.I physxPlane.h \
+    physxPlaneShape.I physxPlaneShape.h \
+    physxPlaneShapeDesc.I physxPlaneShapeDesc.h \
+    physxPointInPlaneJoint.I physxPointInPlaneJoint.h \
+    physxPointInPlaneJointDesc.I physxPointInPlaneJointDesc.h \
+    physxPointOnLineJoint.I physxPointOnLineJoint.h \
+    physxPointOnLineJointDesc.I physxPointOnLineJointDesc.h \
+    physxPrismaticJoint.I physxPrismaticJoint.h \
+    physxPrismaticJointDesc.I physxPrismaticJointDesc.h \
+    physxPulleyJoint.I physxPulleyJoint.h \
+    physxPulleyJointDesc.I physxPulleyJointDesc.h \
     physxRay.I physxRay.h \
+    physxRaycastHit.I physxRaycastHit.h \
+    physxRaycastReport.I physxRaycastReport.h \
+    physxRevoluteJoint.I physxRevoluteJoint.h \
+    physxRevoluteJointDesc.I physxRevoluteJointDesc.h \
     physxScene.I physxScene.h \
     physxSceneDesc.I physxSceneDesc.h \
     physxSceneStats2.I physxSceneStats2.h \
     physxSegment.I physxSegment.h \
-    physxCapsule.I physxCapsule.h \
     physxShape.I physxShape.h \
-    physxBoxShape.I physxBoxShape.h \
-    physxCapsuleShape.I physxCapsuleShape.h \
-    physxPlaneShape.I physxPlaneShape.h \
-    physxSphereShape.I physxSphereShape.h \
     physxShapeDesc.I physxShapeDesc.h \
-    physxBoxShapeDesc.I physxBoxShapeDesc.h \
-    physxCapsuleShapeDesc.I physxCapsuleShapeDesc.h \
-    physxPlaneShapeDesc.I physxPlaneShapeDesc.h \
-    physxSphereShapeDesc.I physxSphereShapeDesc.h \
     physxSphere.I physxSphere.h \
+    physxSphereForceFieldShape.I physxSphereForceFieldShape.h \
+    physxSphereForceFieldShapeDesc.I physxSphereForceFieldShapeDesc.h \
+    physxSphereShape.I physxSphereShape.h \
+    physxSphereShapeDesc.I physxSphereShapeDesc.h \
+    physxSphericalJoint.I physxSphericalJoint.h \
+    physxSphericalJointDesc.I physxSphericalJointDesc.h \
+    physxSpringDesc.I physxSpringDesc.h \
+    physxTriangleMesh.I physxTriangleMesh.h \
+    physxTriangleMeshDesc.I physxTriangleMeshDesc.h \
+    physxTriangleMeshShape.I physxTriangleMeshShape.h \
+    physxTriangleMeshShapeDesc.I physxTriangleMeshShapeDesc.h \
+    physxTriggerReport.I physxTriggerReport.h \
     physxUtilLib.I physxUtilLib.h \
+    physxWheelShape.I physxWheelShape.h \
+    physxWheelShapeDesc.I physxWheelShapeDesc.h \
 
   #define IGATESCAN all
 
 #end lib_target
-

+ 0 - 39
panda/src/physx/SourcesTemplate.pp

@@ -1,39 +0,0 @@
-#define BUILD_DIRECTORY $[HAVE_PHYSX]
-
-#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
-                   dtoolutil:c dtoolbase:c dtool:m prc:c
-
-#begin lib_target
-  #define TARGET physx
-  #define BUILD_TARGET $[HAVE_PHYSX]
-  #define USE_PACKAGES physx
-  #define LOCAL_LIBS pgraph linmath
-  #define COMBINED_SOURCES $[TARGET]_composite.cxx
-    #define INTERROGATE_OPTIONS $[INTERROGATE_OPTIONS] -DHAVE_PHYSX
-
-  #define SOURCES \
-    NoMinMax.h \
-        config_physx.h \
-    physxManager.I physxManager.h \
-    physxContactHandler.I physxContactHandler.h \
-    physxTriggerHandler.I physxTriggerHandler.h \
-    physxJointHandler.I physxJointHandler.h \
-//headers
-  #define INCLUDED_SOURCES \
-    physxManager.cxx \
-    physxContactHandler.cxx \
-    physxTriggerHandler.cxx \
-    physxJointHandler.cxx \
-//cxx
-  #define INSTALL_HEADERS \
-    NoMinMax.h \
-        config_physx.h \
-    physxManager.I physxManager.h \
-    physxContactHandler.I physxContactHandler.h \
-    physxTriggerHandler.I physxTriggerHandler.h \
-    physxJointHandler.I physxJointHandler.h \
-//headers
-  #define IGATESCAN all
-
-#end lib_target
-

+ 97 - 18
panda/src/physx/config_physx.cxx

@@ -1,5 +1,5 @@
-// Filename: config_physics.cxx
-// Created by:  pratt (Apr 18, 2006)
+// Filename: config_physx.cxx
+// Created by:  enn0x (01Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -13,17 +13,48 @@
 ////////////////////////////////////////////////////////////////////
 
 #include "config_physx.h"
+#include "pandaSystem.h"
 
-#include "dconfig.h"
-
-#include "physxActorNode.h"
-#include "physxJoint.h"
-#include "physxD6Joint.h"
-#include "physxShape.h"
+#include "physxActor.h"
+#include "physxBoxController.h"
+#include "physxBoxForceFieldShape.h"
 #include "physxBoxShape.h"
+#include "physxCapsuleController.h"
+#include "physxCapsuleForceFieldShape.h"
 #include "physxCapsuleShape.h"
+#include "physxContactPair.h"
+#include "physxContactPoint.h"
+#include "physxController.h"
+#include "physxConvexMesh.h"
+#include "physxConvexForceFieldShape.h"
+#include "physxConvexShape.h"
+#include "physxCylindricalJoint.h"
+#include "physxD6Joint.h"
+#include "physxDebugGeomNode.h"
+#include "physxDistanceJoint.h"
+#include "physxFixedJoint.h"
+#include "physxForceField.h"
+#include "physxForceFieldShape.h"
+#include "physxForceFieldShapeGroup.h"
+#include "physxHeightField.h"
+#include "physxHeightFieldShape.h"
+#include "physxJoint.h"
+#include "physxMaterial.h"
+#include "physxObject.h"
 #include "physxPlaneShape.h"
+#include "physxPointInPlaneJoint.h"
+#include "physxPointOnLineJoint.h"
+#include "physxPrismaticJoint.h"
+#include "physxPulleyJoint.h"
+#include "physxRevoluteJoint.h"
+#include "physxScene.h"
+#include "physxShape.h"
+#include "physxSphereForceFieldShape.h"
 #include "physxSphereShape.h"
+#include "physxSphericalJoint.h"
+#include "physxTriangleMesh.h"
+#include "physxTriangleMeshShape.h"
+#include "physxWheelShape.h"
 
 ConfigureDef(config_physx);
 NotifyCategoryDef(physx, "");
@@ -32,15 +63,27 @@ ConfigureFn(config_physx) {
   init_libphysx();
 }
 
-ConfigVariableBool physx_want_visual_debugger
-("physx-want-visual-debugger", false);
+ConfigVariableBool physx_want_vrd
+("physx-want-vrd", false,
+PRC_DESC("Specified wether the manager should try to connect to the NVIDIA "
+         "PhysX visual debugger or not. Connection is established when "
+         "the first instance of PhysxManager is created."));
 
-ConfigVariableString physx_visual_debugger_host
-("physx-visual-debugger-host", "localhost");
+ConfigVariableString physx_vrd_host
+("physx-vrd-host", "localhost",
+PRC_DESC("Specified the host where the NVIDIA PhysX visual debugger is running"
+         "on. Only used if the config-varibale 'physx-want-visual-debugger' "
+         "is set to 'true'."));
 
-ConfigVariableInt physx_visual_debugger_port
-("physx-visual-debugger-port", 5425);
+ConfigVariableInt physx_vrd_port
+("physx-visual-debugger-port", 5425,
+PRC_DESC("Specified the port where the NVIDIA PhysX visual debugger is running"
+         "on. Only used if the config-varibale 'physx-want-visual-debugger' "
+         "is set to 'true'."));
 
+ConfigVariableEnum<PhysxEnums::PhysxUpAxis> physx_up_axis
+("physx-up-axis", PhysxEnums::Z_up,
+PRC_DESC("Set the up direction for controllers and heightfields."));
 
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libphysx
@@ -58,12 +101,48 @@ init_libphysx() {
   }
   initialized = true;
 
-  PhysxActorNode::init_type();
-  PhysxJoint::init_type();
-  PhysxD6Joint::init_type();
-  PhysxShape::init_type();
+  PhysxActor::init_type();
+  PhysxBoxController::init_type();
+  PhysxBoxForceFieldShape::init_type();
   PhysxBoxShape::init_type();
+  PhysxCapsuleController::init_type();
+  PhysxCapsuleForceFieldShape::init_type();
   PhysxCapsuleShape::init_type();
+  PhysxContactPair::init_type();
+  PhysxContactPoint::init_type();
+  PhysxController::init_type();
+  PhysxConvexMesh::init_type();
+  PhysxConvexForceFieldShape::init_type();
+  PhysxConvexShape::init_type();
+  PhysxCylindricalJoint::init_type();
+  PhysxD6Joint::init_type();
+  PhysxDebugGeomNode::init_type();
+  PhysxDistanceJoint::init_type();
+  PhysxFixedJoint::init_type();
+  PhysxForceField::init_type();
+  PhysxForceFieldShape::init_type();
+  PhysxForceFieldShapeGroup::init_type();
+  PhysxHeightField::init_type();
+  PhysxHeightFieldShape::init_type();
+  PhysxJoint::init_type();
+  PhysxMaterial::init_type();
+  PhysxObject::init_type();
   PhysxPlaneShape::init_type();
+  PhysxPointInPlaneJoint::init_type();
+  PhysxPointOnLineJoint::init_type();
+  PhysxPrismaticJoint::init_type();
+  PhysxPulleyJoint::init_type();
+  PhysxRevoluteJoint::init_type();
+  PhysxScene::init_type();
+  PhysxShape::init_type();
+  PhysxSphereForceFieldShape::init_type();
   PhysxSphereShape::init_type();
+  PhysxSphericalJoint::init_type();
+  PhysxTriangleMesh::init_type();
+  PhysxTriangleMeshShape::init_type();
+  PhysxWheelShape::init_type();
+
+  PandaSystem *ps = PandaSystem::get_global_ptr();
+  ps->add_system("PhysX");
 }
+

+ 10 - 43
panda/src/physx/config_physx.h

@@ -1,5 +1,5 @@
 // Filename: config_physx.h
-// Created by: pratt (Apr 18, 2006)
+// Created by:  enn0x (01Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -17,54 +17,21 @@
 
 #include "pandabase.h"
 #include "notifyCategoryProxy.h"
+#include "configVariableBool.h"
+#include "configVariableEnum.h"
+#include "configVariableInt.h"
 #include "dconfig.h"
 
+#include "physxEnums.h"
+
 ConfigureDecl(config_physx, EXPCL_PANDAPHYSX, EXPTP_PANDAPHYSX);
 NotifyCategoryDecl(physx, EXPCL_PANDAPHYSX, EXPTP_PANDAPHYSX);
 
-extern EXPCL_PANDA ConfigVariableBool physx_want_visual_debugger;
-extern EXPCL_PANDA ConfigVariableString physx_visual_debugger_host;
-extern EXPCL_PANDA ConfigVariableInt physx_visual_debugger_port;
+extern EXPCL_PANDAPHYSX ConfigVariableBool physx_want_vrd;
+extern EXPCL_PANDAPHYSX ConfigVariableString physx_vrd_host;
+extern EXPCL_PANDAPHYSX ConfigVariableInt physx_vrd_port;
+extern EXPCL_PANDAPHYSX ConfigVariableEnum<PhysxEnums::PhysxUpAxis> physx_up_axis;
 
 extern EXPCL_PANDAPHYSX void init_libphysx();
 
-// These macros get stripped out in a non-debug build (like asserts).
-// Use them like cout but with paranthesis aroud the cout input.
-// e.g. foo_debug("The value of bar is " << bar);
-#ifndef NDEBUG //[
-  // Non-release build:
-  #define PHYSX_DEBUG
-
-  #define physx_spam(msg) \
-  if (physx_cat.is_spam()) { \
-    physx_cat->spam() << msg << endl; \
-  } else {}
-
-  #define physx_debug(msg) \
-  if (physx_cat.is_debug()) { \
-    physx_cat->debug() << msg << endl; \
-  } else {}
-
-  #define physx_info(msg) \
-    physx_cat->info() << msg << endl
-
-  #define physx_warning(msg) \
-    physx_cat->warning() << msg << endl
-
-  // defining NX_USER_DEBUG_MODE causes the PhysX SDK to output extra
-  // information to NxUserOutputStream.
-  #define NX_USER_DEBUG_MODE
-#else //][
-  // Release build:
-  #undef PHYSX_DEBUG
-
-  #define physx_spam(msg) ((void)0)
-  #define physx_debug(msg) ((void)0)
-  #define physx_info(msg) ((void)0)
-  #define physx_warning(msg) ((void)0)
-#endif //]
-
-#define physx_error(msg) \
-  physx_cat->error() << msg << endl
-
 #endif // CONFIG_PHYSX_H

+ 0 - 19
panda/src/physx/createComposite.py

@@ -1,19 +0,0 @@
-
-import os
-import os.path
-
-def createComposite():
-    filesToOmit = (
-        "physx_composite.cxx",
-        "physxTemplate.cxx",
-    )
-
-    compositeFile = file( "physx_composite.cxx", "w" )
-    compositeFile.write( "\n" )
-
-    for filename in os.listdir( os.getcwd() ):
-        if filename.endswith( ".cxx" ) and (filename not in filesToOmit):
-            compositeFile.write( '#include "%s"\n' % filename )
-
-if __name__ == "__main__":
-    createComposite()

+ 0 - 1021
panda/src/physx/generateCode.py

@@ -1,1021 +0,0 @@
-
-import os.path
-import re
-import xmltramp
-
-docDir = "C:\\pratt\\schellGames\\physxDoxy\\2.7.3\\doc\\xml"
-
-membersToOmit = (
-    "user_data",
-    "get_type",
-    "get_internal",
-    "load",
-    "create_fluid_hardware_triangle_mesh",
-    "get_center",
-    "get_extents",
-    "get_rot",
-    "physx_ray_capsule_intersect",
-    "is_point_in_plane_joint",
-    "is_point_on_line_joint",
-    "get_actors",
-    "get_actor_group_pair_array",
-    "get_filter_ops",
-    "get_island_array_from_actor",
-    "get_material_array",
-    "physx_compute_sphere",
-    "l_vec_base3f_obb_sqr_dist",
-)
-
-stringConversions = [
-    ("NX_INLINE", "INLINE"),
-    ("NX_BOOL", "bool"),
-    ("NxI64", "PN_int64"),
-    ("NxI32", "int"),
-    ("NxI16", "short"),
-    ("NxI8", "char"),
-    ("NxU64", "PN_uint64"),
-    ("NxU32", "unsigned int"),
-    ("NxU16", "unsigned short"),
-    ("NxU8", "unsigned char"),
-    ("NxF32", "float"),
-    ("NxF64", "double"),
-    ("NxReal", "float"),
-    ("NxActorGroup", "unsigned short"),
-    ("NxCollisionGroup", "unsigned short"),
-    ("NxMaterialIndex", "unsigned short"),
-    ("NxSubmeshIndex", "unsigned int"),
-    ("NxTriangleID", "unsigned int"),
-    ("NxVec3", "LVecBase3f"),
-    ("NxPoint", "LVecBase3f"),
-    ("NxMat33", "LMatrix3f"),
-    ("NxMat34", "LMatrix4f"),
-    ("NxQuat", "LQuaternionf"),
-    ("Nx", "Physx"),
-]
-reConversions = []
-for pair in stringConversions:
-    reConversions.append( (re.compile( pair[0] ), pair[1]) )
-
-convertFromFunctions = {
-    "LVecBase3f" : "PhysxManager::lVecBase3_to_nxVec3",
-    "LMatrix3f" : "PhysxManager::lMatrix3_to_nxMat33",
-    "LMatrix4f" : "PhysxManager::lMatrix4_to_nxMat34",
-    "LQuaternionf" : "PhysxManager::lQuaternion_to_nxQuat",
-}
-
-convertToFunctions = {
-    "LVecBase3f" : "PhysxManager::nxVec3_to_lVecBase3",
-    "LMatrix3f" : "PhysxManager::nxMat33_to_lMatrix3",
-    "LMatrix4f" : "PhysxManager::nxMat34_to_lMatrix4",
-    "LQuaternionf" : "PhysxManager::nxQuat_to_lQuaternion",
-}
-
-builtinTypes = (
-    "void",
-    "bool",
-    "int",
-    "float",
-    "double",
-    "char",
-    "unsigned char",
-    "signed char",
-    "unsigned int",
-    "signed int",
-    "short int",
-    "unsigned short int",
-    "signed short int",
-    "long int",
-    "signed long int",
-    "unsigned long int",
-    "long double",
-)
-
-#subClasses = {
-#   "PhysxBoxShape" : "PhysxShape",
-#   "PhysxCapsuleShape" : "PhysxShape",
-#   "PhysxPlaneShape" : "PhysxShape",
-#   "PhysxSphereShape" : "PhysxShape",
-#   "PhysxD6Joint" : "PhysxJoint",
-#   "PhysxD6JointDesc" : "PhysxJointDesc",
-#   "PhysxActorNode" : "PandaNode",
-#}
-
-typedWritableReferenceCountClasses = (
-    "BoxShape",
-    "CapsuleShape",
-    "D6Joint",
-    "Joint",
-    "PlaneShape",
-    "Shape",
-    "SphereShape",
-)
-
-classNameConversions = {
-    "Actor" : "ActorNode",
-}
-
-def generateClassCode( name, isStruct=False ):
-    underscoredName = getUnderscoredFromMixedCase( name )
-    if isStruct:
-        xmlfile = file( os.path.join( docDir, "struct_nx_%s.xml" % underscoredName ) )
-    else:
-        xmlfile = file( os.path.join( docDir, "class_nx_%s.xml" % underscoredName ) )
-    doc = xmltramp.seed( xmlfile )
-    xmlfile.close()
-
-    if hasattr( doc[0], "basecompoundref" ):
-        className = str( doc[0].basecompoundref ).replace( "Nx", "Physx" )
-        prot = doc[0].basecompoundref( "prot" )
-        virt = doc[0].basecompoundref( "virt" )
-        if virt == "virtual":
-            baseClassRef = "%s virtual %s" % (prot, className)
-        else:
-            baseClassRef = "%s %s" % (prot, className)
-    else:
-        baseClassRef = None
-
-    structors = {}
-    methods = {}
-    attributes = {}
-    for section in doc[0]["sectiondef":]:
-        if (section( "kind" ) == "public-func") or (section( "kind" ) == "user-defined"):
-            for member in section["memberdef":]:
-                memberName = str( member.name )
-                method = {}
-                method["type"] = str( member.type )
-                method["argsstring"] = str( member.argsstring )
-                method["const"] = member( "const" ) == "yes"
-                method["params"] = []
-                for param in member["param":]:
-                    if hasattr( param, "type" ) and hasattr( param, "declname" ):
-                        method["params"].append( [str( param.type ), str( param.declname )] )
-                if (memberName == "Nx" + name) or (memberName == "~Nx" + name):
-                    structors[memberName] = method
-                else:
-                    methods[memberName] = method
-        elif section( "kind" ) == "public-attrib":
-            for member in section["memberdef":]:
-                memberName = str( member.name )
-                variable = {}
-                variable["type"] = "INLINE " + str( member.type )
-                attributes[memberName] = variable
-
-    convertNames( structors, underscoreNames=False )
-    convertNames( methods )
-    convertNames( attributes )
-
-    filterMembers( structors )
-    filterMembers( methods )
-    filterMembers( attributes )
-
-    createHeader( name, structors, methods, attributes, baseClassRef )
-    createCxx( name, structors, methods, attributes )
-    createInline( name, structors, methods, attributes )
-
-def convertNames( memberDict, underscoreNames=True ):
-    for memberName in memberDict.keys():
-        info = memberDict[memberName]
-        for key in info.keys():
-            if key == "type":
-                info[key] = convertString( info[key] )
-                rawType = getRawType( info[key] )
-                if (rawType not in builtinTypes) and ("INLINE" in info[key]):
-                    info[key] = info[key].replace( "INLINE", "" ).strip()
-                if rawType.startswith( "Physx" ) and (rawType[5:] in classNameConversions):
-                    info[key] = info[key].replace( "Physx" + rawType[5:], "Physx" + classNameConversions[rawType[5:]] ).strip()
-            elif key == "argsstring":
-                info[key] = convertString( info[key] )
-            elif key == "params":
-                for param in info[key]:
-                    param[0] = convertString( param[0] )
-                    param[1] = getUnderscoredFromMixedCase( convertString( param[1] ) )
-                    rawType = getRawType( param[0] )
-                    if (rawType not in builtinTypes) and ("INLINE" in info["type"]):
-                        param[0] = param[0].replace( "INLINE", "" ).strip()
-                    if rawType.startswith( "Physx" ) and (rawType[5:] in classNameConversions):
-                        param[0] = param[0].replace( "Physx" + rawType[5:], "Physx" + classNameConversions[rawType[5:]] ).strip()
-            elif key == "const":
-                pass
-            else:
-                raise
-
-        memberDict[memberName]["originalName"] = memberName
-        if underscoreNames:
-            newMemberName = getUnderscoredFromMixedCase( convertString( memberName ) )
-        else:
-            newMemberName = convertString( memberName )
-
-        if newMemberName != memberName:
-            del memberDict[memberName]
-            memberDict[newMemberName] = info
-
-def filterMembers( memberDict ):
-    for memberName in memberDict.keys():
-        info = memberDict[memberName]
-        rawType = getRawType( info["type"] )
-        if memberName in membersToOmit:
-            del memberDict[memberName]
-        elif rawType.startswith( "Physx" ) and (not isNameKnown( rawType[5:] )):
-            del memberDict[memberName]
-        elif info["type"].count( "*" ) > 1:
-            del memberDict[memberName]
-        elif memberDict[memberName].has_key( "params" ):
-            for param in memberDict[memberName]["params"]:
-                rawType = getRawType( param[0] )
-                if rawType.startswith( "Physx" ) and (not isNameKnown( rawType[5:] )):
-                    del memberDict[memberName]
-                    break
-
-def convertString( s ):
-    for pattern, replacement in reConversions:
-        s = pattern.sub( replacement, s )
-    return s
-
-def createHeader( name, structors, methods, attributes, baseClassRef ):
-    templateFile = file( "physxTemplate.h" )
-    templateString = templateFile.read()
-    templateFile.close()
-
-    lowerPattern = re.compile( "template" )
-    upperPattern = re.compile( "TEMPLATE" )
-    capsPattern = re.compile( "Template" )
-    typeHeaderPattern = re.compile( "//typedWritableReferenceCountHeader" )
-    superHeaderPattern = re.compile( "//superHeader\n" )
-    forwardsPattern = re.compile( "//forwardDeclarations\n" )
-    baseClassRefPattern = re.compile( "/\*baseclassref\*/" )
-    structorsPattern = re.compile( "//publicstructors" )
-    methodsPattern = re.compile( "//publicmethods" )
-    attributesPattern = re.compile( "//publicattributes" )
-    nxReferencePattern = re.compile( "//nxreference" )
-    typeInfoPattern = re.compile( "//typeinfo\n" )
-
-    nName = name
-    if name in classNameConversions:
-        name = classNameConversions[name]
-
-    if name in typedWritableReferenceCountClasses:
-        if baseClassRef is None:
-            baseClassRef = "public TypedWritableReferenceCount"
-        templateString = typeInfoPattern.sub( getTypeInfo( name, baseClassRef ), templateString )
-    else:
-        templateString = typeInfoPattern.sub( "", templateString )
-
-    if baseClassRef is not None:
-        templateString = superHeaderPattern.sub( '#include "%s.h"\n\n' % lowerFirst( baseClassRef.split()[1] ), templateString )
-        templateString = baseClassRefPattern.sub( ": %s " % baseClassRef, templateString )
-    else:
-        templateString = superHeaderPattern.sub( "", templateString )
-        templateString = baseClassRefPattern.sub( "", templateString )
-
-    templateString = lowerPattern.sub( lowerFirst( name ), templateString )
-    templateString = upperPattern.sub( name.upper(), templateString )
-    templateString = capsPattern.sub( name, templateString )
-    templateString = forwardsPattern.sub( getForwardDeclarations( name, structors, methods, attributes, baseClassRef ), templateString )
-    templateString = structorsPattern.sub( getMethodHeaders( structors ), templateString )
-    templateString = methodsPattern.sub( getMethodHeaders( methods ), templateString )
-    templateString = attributesPattern.sub( getAttributeHeaders( attributes ), templateString )
-
-    if name in avoidPointerNames:
-        templateString = nxReferencePattern.sub( "  Nx%s %s;" % (nName, "n" + nName), templateString )
-    else:
-        templateString = nxReferencePattern.sub( "  Nx%s *%s;" % (nName, "n" + nName), templateString )
-
-    outputFile = file( "generated/physx" + name + ".h", "w" )
-    outputFile.write( templateString )
-    outputFile.close()
-
-def getIncludes( name, structors, methods, attributes, baseClassRef=None ):
-    rawTypes = []
-    for method in structors.values() + methods.values():
-        for param in method["params"]:
-            rawTypes.append( getRawType( param[0] ) )
-    for member in methods.values() + attributes.values():
-        rawTypes.append( getRawType( member["type"] ) )
-    if baseClassRef is not None:
-        for part in baseClassRef.split():
-            rawTypes.append( part )
-
-    includeDict = {}
-    for rawType in rawTypes:
-        if rawType.startswith( "Physx" ) and isBuiltName( rawType[5:] ) and (rawType[5:] != name):
-            includeDict['#include "%s.h"\n' % (rawType[0].lower() + rawType[1:])] = True
-        elif rawType.startswith( "L" ):
-            includeDict['#include "luse.h"\n'] = True
-
-    includes = includeDict.keys()
-    includes.sort()
-    return "".join( includes )
-
-def getForwardDeclarations( name, structors, methods, attributes, baseClassRef=None ):
-    rawTypes = []
-    for method in structors.values() + methods.values():
-        for param in method["params"]:
-            rawTypes.append( getRawType( param[0] ) )
-    for member in methods.values() + attributes.values():
-        rawTypes.append( getRawType( member["type"] ) )
-
-    if baseClassRef is not None:
-        baseClass = baseClassRef.split()[1]
-    else:
-        baseClass = None
-    forwardDict = {}  # use a dictionary to avoid duplicates
-    for rawType in rawTypes:
-        if rawType.startswith( "Physx" ) and isBuiltName( rawType[5:] ) and (rawType[5:] != name) and (rawType != baseClass):
-            forwardDict["class %s;\n" % rawType] = True
-
-    forwards = forwardDict.keys()
-    forwards.sort()
-
-    if len( forwards ) > 0:
-        return "".join( forwards ) + "\n"
-    else:
-        return ""
-
-def getMethodHeaders( methodDict ):
-    s = ""
-    names = methodDict.keys()
-    names.sort()
-    for name in names:
-        method = methodDict[name]
-        s += "  "
-        if method["type"] != "":
-            s += "%s " % method["type"]
-        s += "%s(%s)" % (name, getParamString( method["params"] ))
-        if method["const"]:
-            s += " const"
-        s += ";\n"
-
-    return s
-
-def getAttributeHeaders( attributeDict ):
-    getters = ""
-    setters = ""
-    names = attributeDict.keys()
-    names.sort()
-    for name in names:
-        attribute = attributeDict[name]
-        type = attribute["type"]
-        rawType = getRawType( type )
-        if (rawType not in builtinTypes) and (not type.endswith( "*" )) and (not convertFromFunctions.has_key( rawType )) and (rawType not in enumerations.keys()):
-            type += " &"
-        getters += "  %s get_%s() const;\n" % (type, name)
-        if "INLINE" in type:
-            setters += "  INLINE void set_%s(%s value);\n" % (name, type.replace( "INLINE", "" ).strip())
-        else:
-            setters += "  void set_%s(%s value);\n" % (name, type.replace( "INLINE", "" ).strip())
-    if getters != "":
-        return "%s\n%s" % (getters, setters)
-    else:
-        return ""
-
-def getTypeInfo( className, baseClassRef ):
-    typeInfoString = """
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    %(superName)s::init_type();
-    register_type(_type_handle, "Physx%(className)s",
-                  %(superName)s::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;
-"""
-    content = {}
-    content["className"] = className
-    content["superName"] = baseClassRef.split()[1]
-    return typeInfoString % content
-
-def createCxx( name, structors, methods, attributes ):
-    templateFile = file( "physxTemplate.cxx" )
-    templateString = templateFile.read()
-    templateFile.close()
-
-    lowerPattern = re.compile( "template" )
-    upperPattern = re.compile( "TEMPLATE" )
-    capsPattern = re.compile( "Template" )
-    includesPattern = re.compile( "//includes" )
-    typeHandlePattern = re.compile( "//typehandle" )
-    structorsPattern = re.compile( "//publicstructors\n" )
-    methodsPattern = re.compile( "//publicmethods\n" )
-    attributesPattern = re.compile( "//publicattributes\n" )
-
-    pName = name
-    if name in classNameConversions:
-        pName = classNameConversions[name]
-
-    if pName in typedWritableReferenceCountClasses:
-        templateString = typeHandlePattern.sub( "TypeHandle Physx%s::_type_handle;\n" % pName, templateString )
-    else:
-        templateString = typeHandlePattern.sub( "", templateString )
-
-    templateString = lowerPattern.sub( lowerFirst( pName ), templateString )
-    templateString = upperPattern.sub( pName.upper(), templateString )
-    templateString = capsPattern.sub( pName, templateString )
-    templateString = includesPattern.sub( getIncludes( name, structors, methods, attributes ), templateString )
-    templateString = structorsPattern.sub( getMethodSource( name, structors, doInline=False, doCode=False ), templateString )
-    templateString = methodsPattern.sub( getMethodSource( name, methods, doInline=False, doCode=True ), templateString )
-    templateString = attributesPattern.sub( getAttributeSource( name, attributes, doInline=False ), templateString )
-
-    outputFile = file( "generated/physx" + pName + ".cxx", "w" )
-    outputFile.write( templateString )
-    outputFile.close()
-
-def createInline( name, structors, methods, attributes ):
-    templateFile = file( "physxTemplate.I" )
-    templateString = templateFile.read()
-    templateFile.close()
-
-    lowerPattern = re.compile( "template" )
-    upperPattern = re.compile( "TEMPLATE" )
-    capsPattern = re.compile( "Template" )
-    structorsPattern = re.compile( "//publicstructors\n" )
-    methodsPattern = re.compile( "//publicmethods\n" )
-    attributesPattern = re.compile( "//publicattributes\n" )
-
-    pName = name
-    if name in classNameConversions:
-        pName = classNameConversions[name]
-
-    templateString = lowerPattern.sub( lowerFirst( pName ), templateString )
-    templateString = upperPattern.sub( pName.upper(), templateString )
-    templateString = capsPattern.sub( pName, templateString )
-    templateString = structorsPattern.sub( getMethodSource( name, structors, doInline=True, doCode=False ), templateString )
-    templateString = methodsPattern.sub( getMethodSource( name, methods, doInline=True, doCode=True ), templateString )
-    templateString = attributesPattern.sub( getAttributeSource( name, attributes, doInline=True ), templateString )
-
-    outputFile = file( "generated/physx" + pName + ".I", "w" )
-    outputFile.write( templateString )
-    outputFile.close()
-
-def getMethodSource( className, methodDict, doInline=False, doCode=True ):
-    if className in avoidPointerNames:
-        attribOperator = "."
-    else:
-        attribOperator = "->"
-
-    pClassName = className
-    if className in classNameConversions:
-        pClassName = classNameConversions[className]
-
-    result = ""
-
-    methodString = """////////////////////////////////////////////////////////////////////
-//     Function : %(name)s
-//       Access : Published
-//  Description : 
-////////////////////////////////////////////////////////////////////
-%(type)s%(class)s::
-%(name)s%(params)s%(const)s {
-%(code)s
-}
-
-"""
-    names = methodDict.keys()
-    names.sort()
-    for name in names:
-        method = methodDict[name]
-        if (("INLINE" in method["type"]) and doInline) or (("INLINE" not in method["type"]) and (not doInline)):
-            content = {}
-            content["name"] = name
-            if method["type"] != "":
-                content["type"] = "%s " % method["type"]
-            else:
-                content["type"] = ""
-            content["class"] = "Physx" + pClassName
-            content["params"] = "(%s)" % getParamString( method["params"] )
-            if method["const"]:
-                content["const"] = " const"
-            else:
-                content["const"] = ""
-
-            nxObject = "n" + className
-            nxMethodName = method["originalName"]
-            callerParamString = getCallerParamString( method["params"] )
-
-            if name.startswith( "create" ):
-                content["code"] = '  throw "Not Implemented";'
-            elif doCode:
-                if method.has_key( "code" ):
-                    content["code"] = method["code"] % nxObject
-                elif ("void" in method["type"]) and ("*" not in method["type"]):
-                    content["code"] = "  %s%s%s(%s);" % (nxObject, attribOperator, nxMethodName, callerParamString)
-                else:
-                    inner = "%s%s%s(%s)" % (nxObject, attribOperator, nxMethodName, callerParamString)
-                    content["code"] = "  return %s;" % wrapValue( method["type"], inner, isReturnValue=True )
-
-                if className not in avoidPointerNames:
-                    if ("void" in method["type"]) and ("*" not in method["type"]):
-                        content["code"] = ("  nassertv(%s != NULL);\n\n" % nxObject) + content["code"]
-                    elif ("bool" in method["type"]) and ("*" not in method["type"]):
-                        content["code"] = ("  nassertr(%s != NULL, false);\n\n" % nxObject) + content["code"]
-                    elif ("float" in method["type"]) and ("*" not in method["type"]):
-                        content["code"] = ("  nassertr(%s != NULL, -1.0f);\n\n" % nxObject) + content["code"]
-                    elif ("unsigned int" in method["type"]) and ("*" not in method["type"]):
-                        content["code"] = ("  nassertr(%s != NULL, -1);\n\n" % nxObject) + content["code"]
-                    elif ("unsigned short" in method["type"]) and ("*" not in method["type"]):
-                        content["code"] = ("  nassertr(%s != NULL, -1);\n\n" % nxObject) + content["code"]
-                    elif ("LVecBase3f" in method["type"]) and ("*" not in method["type"]):
-                        content["code"] = ("  nassertr(%s != NULL, *((LVecBase3f *)NULL));\n\n" % nxObject) + content["code"]
-                    elif ("LMatrix3f" in method["type"]) and ("*" not in method["type"]):
-                        content["code"] = ("  nassertr(%s != NULL, *((LMatrix3f *)NULL));\n\n" % nxObject) + content["code"]
-                    elif ("LMatrix4f" in method["type"]) and ("*" not in method["type"]):
-                        content["code"] = ("  nassertr(%s != NULL, *((LMatrix4f *)NULL));\n\n" % nxObject) + content["code"]
-                    elif ("LQuaternionf" in method["type"]) and ("*" not in method["type"]):
-                        content["code"] = ("  nassertr(%s != NULL, *((LQuaternionf *)NULL));\n\n" % nxObject) + content["code"]
-                    elif ("PhysxScene" in method["type"]) and ("*" not in method["type"]):
-                        content["code"] = ("  nassertr(%s != NULL, *((PhysxScene *)NULL));\n\n" % nxObject) + content["code"]
-                    elif ("PhysxJointState" in method["type"]) and ("*" not in method["type"]):
-                        content["code"] = ("  nassertr(%s != NULL, physx_js_unbound);\n\n" % nxObject) + content["code"]
-                    elif "*" in method["type"]:
-                        content["code"] = ("  nassertr(%s != NULL, NULL);\n\n" % nxObject) + content["code"]
-
-            else:
-                content["code"] = ""
-
-            result += methodString % content
-
-    return result
-
-def getAttributeSource( className, attributeDict, doInline=False ):
-    if className in avoidPointerNames:
-        attribOperator = "."
-    else:
-        attribOperator = "->"
-
-    methodDict = {}
-
-    for name in attributeDict.keys():
-        type = attributeDict[name]["type"]
-        rawType = getRawType( type )
-        if (rawType not in builtinTypes) and (not type.endswith( "*" )) and (not convertFromFunctions.has_key( rawType )) and (rawType not in enumerations.keys()):
-            type += " &"
-        setterValue = wrapValue( type, "value", isReturnValue=False )
-        getter = {
-            "type" : type,
-            "const" : True,
-            "params" : [],
-            "code" : "  return %%s%s%s;" % (attribOperator, attributeDict[name]["originalName"]),
-            "originalName" : getMixedCaseFromUnderscored( "get_" + name ),
-        }
-        setter = {
-            "type" : "void",
-            "const" : False,
-            "params" : [[type.replace( "INLINE", "" ).strip(), "value"]],
-            "code" : "  %%s%s%s = %s;" % (attribOperator, attributeDict[name]["originalName"], setterValue),
-            "originalName" : getMixedCaseFromUnderscored( "set_" + name ),
-        }
-        methodDict["get_" + name] = getter
-        methodDict["set_" + name] = setter
-
-        if "INLINE" in type:
-            setter["type"] = "INLINE void"
-
-        if convertFromFunctions.has_key( rawType ):
-            valueString = "%%s%s%s" % (attribOperator, attributeDict[name]["originalName"])
-            getter["code"] = "  return %s;" % getConvertedValue( type, valueString, False )
-            getter["type"] = type
-        elif rawType in enumerations.keys():
-            valueString = "%%s%s%s" % (attribOperator, attributeDict[name]["originalName"])
-            getter["code"] = "  return %s;" % wrapValue( rawType, valueString, isReturnValue=True )
-        elif rawType.startswith( "Physx" ) and isBuiltName( rawType[5:] ):
-            getter["code"] = '  throw "Not Implemented"; // return %%s%s%s;' % (attribOperator, attributeDict[name]["originalName"])
-
-    return getMethodSource( className, methodDict, doInline=doInline, doCode=True )
-
-def getParamString( params ):
-    items = ["%s %s" % (param[0], param[1]) for param in params]
-    return ", ".join( items )
-
-def getCallerParamString( params ):
-    items = []
-    for param in params:
-        items.append( wrapValue( param[0], param[1] ) )
-    return ", ".join( items )
-
-def wrapValue( type, valueString, isReturnValue=False ):
-    rawType = getRawType( type )
-    if rawType in builtinTypes:
-        return valueString
-    elif (not isReturnValue) and convertFromFunctions.has_key( rawType ):
-        return getConvertedValue( type, valueString, not isReturnValue )
-    elif isReturnValue and convertToFunctions.has_key( rawType ):
-        return getConvertedValue( type, valueString, not isReturnValue )
-    elif rawType.startswith( "Physx" ) and isBuiltName( rawType[5:] ):
-        if isReturnValue:
-            if "*" in type:
-                return "(%s *)(%s->userData)" % (rawType, valueString)
-            else:
-                return "*((%s *)(%s.userData))" % (rawType, valueString)
-        else:
-            if "*" in type:
-                if rawType[5:] in avoidPointerNames:
-                    return "&(%s->%s)" % (valueString, "n" + rawType[5:])
-                else:
-                    return "%s->%s" % (valueString, "n" + rawType[5:])
-            else:
-                if rawType[5:] in avoidPointerNames:
-                    return "%s.%s" % (valueString, "n" + rawType[5:])
-                else:
-                    return "*(%s.%s)" % (valueString, "n" + rawType[5:])
-    elif rawType in enumerations.keys():
-        if isReturnValue:
-            return "(%s)%s" % (rawType, valueString)
-        else:
-            return "(%s)%s" % ("Nx" + rawType[5:], valueString)
-    else:
-        return valueString
-
-def isNameKnown( name ):
-    if name in allBuiltNames:
-        return True
-    elif name in classNameConversions.values():
-        return True
-    elif enumerations.has_key( "Physx" + name ):
-        return True
-    else:
-        return False
-
-def isBuiltName( name ):
-    return (name in allBuiltNames) or (name in classNameConversions.values())
-
-def getUnderscoredFromMixedCase( name ):
-    return re.sub( r"(?<=[a-z])[A-Z]|(?<!^)[A-Z](?=[a-z])", r"_\g<0>", name ).lower()
-
-def getMixedCaseFromUnderscored( name ):
-    return re.sub( r"_([a-z])", lambda m: (m.group( 1 ).upper()), name )
-
-def lowerFirst( name ):
-    return name[0].lower() + name[1:]
-
-def getRawType( type ):
-    rawType = type.replace( "const", "" )
-    rawType = rawType.replace( "INLINE", "" )
-    rawType = rawType.strip( " *&" )
-    return rawType
-
-def getConvertedValue( type, valueString, convertFrom=True ):
-    rawType = getRawType( type )
-    if convertFrom:
-        func = convertFromFunctions[rawType]
-    else:
-        func = convertToFunctions[rawType]
-    if "*" in type:
-        return "&%s(*%s)" % (func, valueString)
-    else:
-        return "%s(%s)" % (func, valueString)
-
-def generateEnumerationFile():
-    global enumerations
-    enumerations = {}
-    locations = {}
-    for group in ("cloth", "fluids", "foundation", "physics", "softbody"):
-        getEnumerations( group, enumerations, locations )
-
-    enumerationContent = []
-    enumerationContentForInterrogate = []
-    names = enumerations.keys()
-    names.sort()
-    for name in names:
-        if name not in ["PhysxMemoryType"]:
-            enumerationContent.append( "enum %s {\n" % name )
-            enumerationContentForInterrogate.append( "enum %s {\n" % name )
-            nonInitializedItems, namesToInitializers = enumerations[name]
-            for nxValue in nonInitializedItems:
-                parts = nxValue.split( "_" )[1:]
-                parts = ["physx"] + [part.lower() for part in parts]
-                physxValue = "_".join( parts )
-                enumerationContent.append( "  %s = %s,\n" % (physxValue, nxValue) )
-                enumerationContentForInterrogate.append( "  %s,\n" % physxValue )
-            for nxValue in namesToInitializers.keys():
-                parts = nxValue.split( "_" )[1:]
-                parts = ["physx"] + [part.lower() for part in parts]
-                physxValue = "_".join( parts )
-                enumerationContent.append( "  %s = %s,\n" % (physxValue, nxValue) )
-
-                initializer = namesToInitializers[nxValue]
-                enumerationContentForInterrogate.append( "  %s = %s,\n" % (physxValue, initializer) )
-
-            enumerationContent.append( "};\n\n" )
-            enumerationContentForInterrogate.append( "};\n\n" )
-
-    enumerationTemplate = """// Filename: physx_enumerations.h
-// Created by: pratt (Apr 20, 2006)
-//
-////////////////////////////////////////////////////////////////////
-//
-// 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 PHYSX_ENUMERATIONS_H
-#define PHYSX_ENUMERATIONS_H
-
-#ifdef HAVE_PHYSX
-
-#include "NoMinMax.h"
-#include "NxPhysics.h"
-
-%s
-
-#endif // HAVE_PHYSX
-
-#endif // PHYSX_ENUMERATIONS_H
-"""
-
-    outputFile = file( "generated/physx_enumerations.h", "w" )
-    outputFile.write( enumerationTemplate % "".join( enumerationContent ) )
-    outputFile.close()
-
-    outputFile = file( "generated/physx_enumerations_for_interrogate.h", "w" )
-    outputFile.write( enumerationTemplate % "".join( enumerationContentForInterrogate ) )
-    outputFile.close()
-
-def getEnumerations( group, enumerations, locations ):
-    xmlfile = file( os.path.join( docDir, "group__%s.xml" % group ) )
-    doc = xmltramp.seed( xmlfile )
-    xmlfile.close()
-
-    for section in doc.compounddef["sectiondef":]:
-        if section( "kind" ) == "enum":
-            for enumeration in section["memberdef":]:
-                name = str( enumeration.name ).replace( "Nx", "Physx" )
-                nonInitializedItems = []
-                namesToInitializers = {}
-                for value in enumeration["enumvalue":]:
-                    try:
-                        initializer = str( value.initializer )
-                        try:
-                            eval( initializer )
-                            namesToInitializers[str( value.name )] = initializer
-                        except:
-                            # Avoid creating enum values that we know will
-                            # not work, i.e. bitwise ORs of previous values.
-                            pass
-                    except:
-                        nonInitializedItems.append( str( value.name ) )
-                enumerations[name] = (nonInitializedItems, namesToInitializers)
-                location = os.path.basename( str( enumeration["location"]( "file" ) ) )
-                if group == "cloth":
-                    location = "cloth/" + location
-                elif group == "fluids":
-                    location = "fluids/" + location
-                elif group == "softbody":
-                    location = "softbody/" + location
-                locations[location] = True
-
-def generateSourcesPP( names ):
-    templateFile = file( "SourcesTemplate.pp" )
-    templateString = templateFile.read()
-    templateFile.close()
-
-    headerLines = []
-    sourceLines = []
-
-    for name in names:
-        if name == "Actor":
-            name = "ActorNode"
-        headerLines.append( "    physx%s.I physx%s.h \\\n" % (name, name) )
-        sourceLines.append( "    physx%s.cxx \\\n" % name )
-
-    headersPattern = re.compile( "//headers" )
-    cxxPattern = re.compile( "//cxx" )
-
-    templateString = headersPattern.sub( "".join( headerLines ), templateString )
-    templateString = cxxPattern.sub( "".join( sourceLines ), templateString )
-
-    outputFile = file( "generated/Sources.pp", "w" )
-    outputFile.write( templateString )
-    outputFile.close()
-
-buildNowNames = [
-    "Actor",
-    "ActorDesc",
-    "BodyDesc",
-    "Bounds3",
-    "Box",
-    "Joint",
-    "D6Joint",
-    "JointDesc",
-    "D6JointDesc",
-    "JointDriveDesc",
-    "JointLimitSoftDesc",
-    "JointLimitSoftPairDesc",
-    "Material",
-    "MaterialDesc",
-    "Plane",
-    "Ray",
-    "Scene",
-    "SceneDesc",
-    "SceneStats2",
-    "Segment",
-    "Capsule",
-    "Shape",
-    "BoxShape",
-    "CapsuleShape",
-    "PlaneShape",
-    "SphereShape",
-    "ShapeDesc",
-    "BoxShapeDesc",
-    "CapsuleShapeDesc",
-    "PlaneShapeDesc",
-    "SphereShapeDesc",
-    "Sphere",
-    "UtilLib",
-]
-buildNowStructs = [
-]
-
-allBuiltNames = [
-    "Actor",
-    "ActorDesc",
-    "BodyDesc",
-    "Bounds3",
-    "Box",
-    "Joint",
-    "D6Joint",
-    "JointDesc",
-    "D6JointDesc",
-    "JointDriveDesc",
-    "JointLimitSoftDesc",
-    "JointLimitSoftPairDesc",
-    "Material",
-    "MaterialDesc",
-    "Plane",
-    "Ray",
-    "Scene",
-    "SceneDesc",
-    "SceneStats2",
-    "Segment",
-    "Capsule",
-    "Shape",
-    "BoxShape",
-    "CapsuleShape",
-    "PlaneShape",
-    "SphereShape",
-    "ShapeDesc",
-    "BoxShapeDesc",
-    "CapsuleShapeDesc",
-    "PlaneShapeDesc",
-    "SphereShapeDesc",
-    "Sphere",
-    "UtilLib",
-]
-
-expectedNames = [
-    "Actor",
-    "ActorDesc",
-    "BodyDesc",
-    "Bounds3",
-    "Box",
-    "Cloth",
-    "ClothDesc",
-    "ClothMesh",
-    "ContactPair",
-    "ContactStreamIterator",
-    "ConvexMesh",
-    "ConvexMeshDesc",
-    "Effector",
-    "SpringAndDamperEffector",
-    "Fluid",
-    "FluidDesc",
-    "FluidEmitter",
-    "FluidEmitterDesc",
-    "GroupsMask",
-    "HeightField",
-    "HeightFieldDesc",
-    "Joint",
-    "CylindricalJoint",
-    "D6Joint",
-    "DistanceJoint",
-    "FixedJoint",
-    "PointInPlaneJoint",
-    "PointOnLineJoint",
-    "PrismaticJoint",
-    "PulleyJoint",
-    "RevoluteJoint",
-    "SphericalJoint",
-    "JointDesc",
-    "CylindricalJointDesc",
-    "D6JointDesc",
-    "DistanceJointDesc",
-    "FixedJointDesc",
-    "PointInPlaneJointDesc",
-    "PointOnLineJointDesc",
-    "PrismaticJointDesc",
-    "PulleyJointDesc",
-    "RevoluteJointDesc",
-    "SphericalJointDesc",
-    "JointDriveDesc",
-    "JointLimitDesc",
-    "JointLimitPairDesc",
-    "JointLimitSoftDesc",
-    "JointLimitSoftPairDesc",
-    "Material",
-    "MaterialDesc",
-    "MeshData",
-    "MotorDesc",
-    "PairFlag",
-    "ParticleData",
-    "Plane",
-    "PMap",
-    "Ray",
-    "Scene",
-    "SceneDesc",
-    "SceneStats2",
-    "Segment",
-    "Capsule",
-    "Shape",
-    "BoxShape",
-    "CapsuleShape",
-    "ConvexShape",
-    "PlaneShape",
-    "SphereShape",
-    "TriangleMeshShape",
-    "WheelShape",
-    "ShapeDesc",
-    "BoxShapeDesc",
-    "CapsuleShapeDesc",
-    "ConvexShapeDesc",
-    "PlaneShapeDesc",
-    "SphereShapeDesc",
-    "TriangleMeshShapeDesc",
-    "WheelShapeDesc",
-    "SimpleTriangleMesh",
-    "ClothMeshDesc",
-    "TriangleMeshDesc",
-    "Sphere",
-    "SpringAndDamperEffectorDesc",
-    "SpringDesc",
-    "TireFunctionDesc",
-    "UtilLib",
-    "WheelContactData",
-]
-
-avoidPointerNames = [
-    "ActorDesc",
-    "ActorDescBase",
-    "BodyDesc",
-    "ClothDesc",
-    "ConvexMeshDesc",
-    "FluidDesc",
-    "FluidEmitterDesc",
-    "HeightFieldDesc",
-    "CylindricalJointDesc",
-    "D6JointDesc",
-    "DistanceJointDesc",
-    "FixedJointDesc",
-    "PointInPlaneJointDesc",
-    "PointOnLineJointDesc",
-    "PrismaticJointDesc",
-    "PulleyJointDesc",
-    "RevoluteJointDesc",
-    "SphericalJointDesc",
-    "JointDriveDesc",
-    "JointLimitDesc",
-    "JointLimitPairDesc",
-    "JointLimitSoftDesc",
-    "JointLimitSoftPairDesc",
-    "MaterialDesc",
-    "MotorDesc",
-    "SceneDesc",
-    "ShapeDesc",
-    "BoxShapeDesc",
-    "CapsuleShapeDesc",
-    "ConvexShapeDesc",
-    "PlaneShapeDesc",
-    "SphereShapeDesc",
-    "TriangleMeshShapeDesc",
-    "WheelShapeDesc",
-    "ClothMeshDesc",
-    "TriangleMeshDesc",
-    "SpringAndDamperEffectorDesc",
-    "SpringDesc",
-    "TireFunctionDesc",
-]
-
-if __name__ == "__main__":
-    if not os.path.exists( "generated" ):
-        os.mkdir( "generated" )
-    generateEnumerationFile()
-    generateSourcesPP( allBuiltNames )
-    for name in buildNowNames:
-        print name
-        generateClassCode( name )
-    for name in buildNowStructs:
-        print name
-        generateClassCode( name, isStruct=True )
-

+ 72 - 0
panda/src/physx/physxActor.I

@@ -0,0 +1,72 @@
+// Filename: physxActor.I
+// Created by:  enn0x (14Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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: PhysxActor::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxActor::
+PhysxActor() : PhysxObject() {
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxActor::
+~PhysxActor() {
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::ls
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+INLINE void PhysxActor::
+ls() const {
+
+  ls(nout);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::ls
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+INLINE void PhysxActor::
+ls(ostream &out, int indent_level) const {
+
+  indent(out, indent_level) << get_type().get_name()
+                            << " " << get_name( )
+                            << " (at 0x" << this << ")";
+
+  if (!_np.is_empty()) {
+    out << " NP:" << _np;
+  }
+
+  if (_controller) {
+    out << " C:0x" << _controller;
+  }
+
+  out << "\n";
+
+  _shapes.ls(out, indent_level);
+}
+

+ 1663 - 0
panda/src/physx/physxActor.cxx

@@ -0,0 +1,1663 @@
+// Filename: physxActor.cxx
+// Created by:  enn0x (14Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxActor.h"
+#include "physxActorDesc.h"
+#include "physxBodyDesc.h"
+#include "physxShapeDesc.h"
+#include "physxManager.h"
+
+TypeHandle PhysxActor::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::link
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+link(NxActor *actorPtr) {
+
+  // Link self
+  _ptr = actorPtr;
+  _ptr->userData = this;
+  _error_type = ET_ok;
+
+  PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
+  scene->_actors.add(this);
+
+  // Link shapes
+  NxShape * const *shapes = _ptr->getShapes();
+  NxU32 nShapes = _ptr->getNbShapes();
+
+  for (NxU32 i=0; i < nShapes; i++) {
+    if (shapes[i]->getName() == NULL) shapes[i]->setName("");
+
+    PT(PhysxShape) shape = PhysxShape::factory(shapes[i]->getType());
+    shape->link(shapes[i]);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::unlink
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+unlink() {
+
+  // Unlink shapes
+  NxShape * const *shapes = _ptr->getShapes();
+  NxU32 nShapes = _ptr->getNbShapes();
+
+  for (NxU32 i=0; i < nShapes; i++) {
+    PT(PhysxShape) shape = (PhysxShape *)shapes[i]->userData;
+    shape->unlink();
+  }
+
+  // Unlink self
+  _ptr->userData = NULL;
+  _error_type = ET_released;
+
+  PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
+  scene->_actors.remove(this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::release
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+release() {
+
+  nassertv(_error_type == ET_ok);
+
+  unlink();
+  _ptr->getScene().releaseActor(*_ptr);
+  _ptr = NULL;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::link_controller
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+link_controller(PT(PhysxController) controller) {
+
+  _controller = controller;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::save_body_to_desc
+//       Access: Published
+//  Description: Saves the body information of a dynamic actor to 
+//               the passed body descriptor.
+////////////////////////////////////////////////////////////////////
+bool PhysxActor::
+save_body_to_desc(PhysxBodyDesc &bodyDesc) const {
+
+  nassertr(_error_type == ET_ok, false);
+  return _ptr->saveBodyToDesc(bodyDesc._desc);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::save_to_desc
+//       Access: Published
+//  Description: Saves the state of the actor to the passed 
+//               descriptor.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+save_to_desc(PhysxActorDesc &actorDesc) const {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->saveToDesc(actorDesc._desc);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_name
+//       Access: Published
+//  Description: Sets a name string for the object that can be
+//               retrieved with get_name(). 
+//               This is for debugging and is not used by the
+//               engine.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_name(const char *name) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setName(name);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_name
+//       Access: Published
+//  Description: Retrieves the name string.
+////////////////////////////////////////////////////////////////////
+const char *PhysxActor::
+get_name() const {
+
+  nassertr(_error_type == ET_ok, "");
+  return _ptr->getName();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::update_transform
+//       Access: Public
+//  Description: Updates the transform of an assigned NodePath. If
+//               the actor has been created by a PhysxController
+//               then this method will update the NodePath's
+//               transform from the controller's transform.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+update_transform(const LMatrix4f m) {
+
+  // Active transforms are update AFTER scene.fetchResults() has
+  // been called, and thus can contain removed objects. So either
+  // update transforms after scene.fetchResults() - which means
+  // poor performance - or check if an actor has been removed here
+  // in this method.
+  if (_error_type != ET_ok) return;
+
+  if (_np.is_empty()) return;
+
+  if (_controller) {
+    LVector3f hpr(_controller->get_h(), 0.0f, 0.0f);
+    LPoint3f pos = _controller->get_pos();
+    _np.set_transform(_np.get_top(), TransformState::make_pos_hpr(pos, hpr));
+  }
+  else {
+    _np.set_transform(_np.get_top(), TransformState::make_mat(m));
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_global_pos
+//       Access: Published
+//  Description: Retrieves the actors world space position.
+////////////////////////////////////////////////////////////////////
+LPoint3f PhysxActor::
+get_global_pos() const {
+
+  nassertr(_error_type == ET_ok, LPoint3f::zero());
+  return PhysxManager::nxVec3_to_point3(_ptr->getGlobalPosition());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_global_mat
+//       Access: Published
+//  Description: Retrieves the actors world space transform.
+////////////////////////////////////////////////////////////////////
+LMatrix4f PhysxActor::
+get_global_mat() const {
+
+  nassertr(_error_type == ET_ok, LMatrix4f::zeros_mat());
+  return PhysxManager::nxMat34_to_mat4(_ptr->getGlobalPose());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_global_quat
+//       Access: Published
+//  Description: Retrieves the actors world space orientation.
+////////////////////////////////////////////////////////////////////
+LQuaternionf PhysxActor::
+get_global_quat() const {
+
+  nassertr(_error_type == ET_ok, LQuaternionf::zero());
+  return PhysxManager::nxQuat_to_quat(_ptr->getGlobalOrientation());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_global_pos
+//       Access: Published
+//  Description: Method for setting a dynamic actor's position in
+//               the world. Please see set_global_mat for some
+//               caveats.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_global_pos(const LPoint3f &pos) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!pos.is_nan());
+
+  _ptr->setGlobalPosition(PhysxManager::point3_to_nxVec3(pos));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_global_mat
+//       Access: Published
+//  Description: Method for setting a dynamic actor's transform
+//               matrix in the world. 
+//
+//               This method instantaneously changes the actor space
+//               to world space transformation.
+//
+//               One should exercise restraint in making use of
+//               these methods.
+//
+//               Static actors should not be moved at all. There are
+//               various internal data structures for static actors
+//               which may need to be recomputed when one moves.
+//               Also, moving static actors will not interact
+//               correctly with dynamic actors or joints. If you
+//               would like to directly control an actor's position
+//               and would like to have it correctly interact with
+//               dynamic bodies and joints, you should create a
+//               dynamic body with the BF_kinematic flag, and then
+//               use the move_lobal_*() commands to move it along
+//               a path!
+//
+//               When briefly moving dynamic actors, one should not:
+//               - Move actors into other actors, thus causing
+//                 interpenetration (an invalid physical state).
+//               - Move an actor that is connected by a joint to
+//                 another away from the other (thus causing joint
+//                 error).
+//               - When moving jointed actors the joints' cached
+//                 transform information is destroyed and recreated
+//                 next frame; thus this call is expensive for
+//                 jointed actors. 
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_global_mat(const LMatrix4f &mat) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!mat.is_nan());
+
+  _ptr->setGlobalPose(PhysxManager::mat4_to_nxMat34(mat));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_global_hpr
+//       Access: Published
+//  Description: Method for setting a dynamic actor's orientation in
+//               the world. Please see set_global_mat for some
+//               caveats.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_global_hpr(float h, float p, float r) {
+
+  nassertv(_error_type == ET_ok);
+
+  LQuaternionf q;
+  q.set_hpr(LVector3f(h, p, r));
+  _ptr->setGlobalOrientationQuat(PhysxManager::quat_to_nxQuat(q));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::attach_node_path
+//       Access: Published
+//  Description: Attaches a node path to this actor. The node
+//               path's transform will be updated automatically if
+//               the actor's transform changes (and only then).
+//
+//               Note: any non-uniform scale or shear set on the
+//               NodePath's transform will be overwritten at the
+//               time of the first update.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+attach_node_path(const NodePath &np) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!np.is_empty());
+
+  _np = NodePath(np);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::detach_node_path
+//       Access: Published
+//  Description: Detaches a previously assigned NodePath from this
+//               actor. The NodePath's transform will no longer
+//               be updated from the actor's transform.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+detach_node_path() {
+
+  nassertv(_error_type == ET_ok);
+
+  _np = NodePath();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_node_path
+//       Access: Published
+//  Description: Retrieves a previously attached NodePath. An empty
+//               NodePath will be returned if no NodePath has been
+//               attached to this actor.
+////////////////////////////////////////////////////////////////////
+NodePath PhysxActor::
+get_node_path() const {
+
+  nassertr(_error_type == ET_ok, NodePath::fail());
+
+  return _np;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_scene
+//       Access: Published
+//  Description: Retrieves the scene which this actor belongs to.
+////////////////////////////////////////////////////////////////////
+PT(PhysxScene) PhysxActor::
+get_scene() const {
+
+  nassertr(_error_type == ET_ok, NULL);
+
+  NxScene *scenePtr = &(_ptr->getScene());
+  PhysxScene *scene = (PhysxScene *)(scenePtr->userData);
+
+  return scene;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_num_shapes
+//       Access: Published
+//  Description: Returns the number of shapes assigned to the
+//               actor.
+////////////////////////////////////////////////////////////////////
+unsigned int PhysxActor::
+get_num_shapes() const {
+
+  nassertr(_error_type == ET_ok, -1);
+
+  return _ptr->getNbShapes();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::create_shape
+//       Access: Published
+//  Description: Creates a new shape and adds it to the list of
+//               shapes of this actor. 
+//
+//               Mass properties of dynamic actors will not
+//               automatically be recomputed to reflect the new mass
+//               distribution implied by the shape. Follow this call
+//               with a call to update_mass_from_shapes() to do
+//               that.
+////////////////////////////////////////////////////////////////////
+PT(PhysxShape) PhysxActor::
+create_shape(PhysxShapeDesc &desc) {
+
+  nassertr(_error_type == ET_ok, NULL);
+  nassertr(desc.is_valid(),NULL);
+
+  PT(PhysxShape) shape = PhysxShape::factory(desc.ptr()->getType());
+  nassertr(shape, NULL);
+
+  NxShape *shapePtr = _ptr->createShape(*desc.ptr());
+  nassertr(shapePtr, NULL);
+
+  shape->link(shapePtr);
+
+  return shape;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_shape
+//       Access: Published
+//  Description: Retrieves an individual shape from the actor's
+//               array of shapes. Index must be in the range from
+//               zero to (number-of-shapes minus 1).
+////////////////////////////////////////////////////////////////////
+PT(PhysxShape) PhysxActor::
+get_shape(unsigned int idx) const {
+
+  nassertr(_error_type == ET_ok, NULL);
+  nassertr_always(idx < _ptr->getNbShapes(), NULL);
+
+  NxShape * const *shapes = _ptr->getShapes();
+  NxShape *shapePtr = shapes[idx];
+  PhysxShape *shape = (PhysxShape *)(shapePtr->userData);
+
+  return shape;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_shape_by_name
+//       Access: Published
+//  Description: Retrieves an individual shape from the actor's
+//               array of shapes. The first shape for which the
+//               shape's name matches the specified name is
+//               returned, or NULL if no shape has a matching name.
+////////////////////////////////////////////////////////////////////
+PT(PhysxShape) PhysxActor::
+get_shape_by_name(const char *name) const {
+
+  nassertr(_error_type == ET_ok, NULL);
+
+  NxShape * const *shapes = _ptr->getShapes();
+  NxShape *shapePtr = NULL;
+  NxU32 nShapes = _ptr->getNbShapes();
+
+  for (NxU32 i=0; i < nShapes; i++) {
+    shapePtr = shapes[i];
+
+    if (strcmp(shapePtr->getName(), name) == 0) {
+      return (PhysxShape *) shapePtr->userData;
+    }
+  }
+
+  return NULL;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::add_force
+//       Access: Published
+//  Description: Applies a force (or impulse) defined in the global
+//               coordinate frame to the actor.
+//
+//               This will not induce a torque.
+//
+//               Mode determines if the torque is to be conventional
+//               or impulsive.
+//
+//               The actor must be dynamic.
+//               This call wakes the actor if it is sleeping and the
+//               wakeup parameter is true (default).
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+add_force(const LVector3f force, PhysxForceMode mode, bool wakeup) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!force.is_nan());
+
+  _ptr->addForce(PhysxManager::vec3_to_nxVec3(force), (NxForceMode)mode, wakeup);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::add_force_at_pos
+//       Access: Published
+//  Description: Applies a force (or impulse) defined in the global
+//               coordinate frame, acting at a particular point in
+//               global coordinates, to the actor. 
+//
+//               Note that if the force does not act along the
+//               center of mass of the actor, this will also add the
+//               corresponding torque. Because forces are reset at
+//               the end of every timestep, you can maintain a total
+//               external force on an object by calling this once
+//               every frame.
+//
+//               Mode determines if the torque is to be conventional
+//               or impulsive.
+//
+//               The actor must be dynamic.
+//               This call wakes the actor if it is sleeping and the
+//               wakeup parameter is true (default).
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+add_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!force.is_nan());
+  nassertv_always(!pos.is_nan());
+
+  _ptr->addForceAtPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::add_force_at_local_pos
+//       Access: Published
+//  Description: Applies a force (or impulse) defined in the global
+//               coordinate frame, acting at a particular point in
+//               local coordinates, to the actor. 
+//
+//               Note that if the force does not act along the
+//               center of mass of the actor, this will also add
+//               the corresponding torque. Because forces are reset
+//               at the end of every timestep, you can maintain a
+//               total external force on an object by calling this
+//               once every frame.
+//
+//               Mode determines if the torque is to be conventional
+//               or impulsive.
+//
+//               The actor must be dynamic.
+//               This call wakes the actor if it is sleeping and the
+//               wakeup parameter is true (default).
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+add_force_at_local_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!force.is_nan());
+  nassertv_always(!pos.is_nan());
+
+  _ptr->addForceAtLocalPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::add_torque
+//       Access: Published
+//  Description: Applies an impulsive torque defined in the global
+//               coordinate frame to the actor. 
+//
+//               Mode determines if the torque is to be conventional
+//               or impulsive.
+//
+//               The actor must be dynamic.
+//               This call wakes the actor if it is sleeping and the
+//               wakeup parameter is true (default).
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+add_torque(const LVector3f torque, PhysxForceMode mode, bool wakeup) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!torque.is_nan());
+
+  _ptr->addTorque(PhysxManager::vec3_to_nxVec3(torque), (NxForceMode)mode, wakeup);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::add_local_force
+//       Access: Published
+//  Description: Applies a force (or impulse) defined in the actor
+//               local coordinate frame to the actor. 
+//               This will not induce a torque.
+//
+//               Mode determines if the torque is to be conventional
+//               or impulsive.
+//
+//               The actor must be dynamic.
+//               This call wakes the actor if it is sleeping and the
+//               wakeup parameter is true (default).
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+add_local_force(const LVector3f force, PhysxForceMode mode, bool wakeup) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!force.is_nan());
+
+  _ptr->addLocalForce(PhysxManager::vec3_to_nxVec3(force), (NxForceMode)mode, wakeup);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::add_local_force_at_pos
+//       Access: Published
+//  Description: Applies a force (or impulse) defined in the actor
+//               local coordinate frame, acting at a particular
+//               point in global coordinates, to the actor. 
+//
+//               Note that if the force does not act along the
+//               center of mass of the actor, this will also add
+//               the corresponding torque. Because forces are reset
+//               at the end of every timestep, you can maintain a
+//               total external force on an object by calling this
+//               once every frame.
+//
+//               Mode determines if the torque is to be conventional
+//               or impulsive.
+//
+//               The actor must be dynamic.
+//               This call wakes the actor if it is sleeping and the
+//               wakeup parameter is true (default).
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+add_local_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!force.is_nan());
+  nassertv_always(!pos.is_nan());
+
+  _ptr->addLocalForceAtPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::add_local_force_at_local_pos
+//       Access: Published
+//  Description: Applies a force (or impulse) defined in the actor
+//               local coordinate frame, acting at a particular
+//               point in local coordinates, to the actor. 
+//
+//               Note that if the force does not act along the
+//               center of mass of the actor, this will also add the
+//               corresponding torque. Because forces are reset at
+//               the end of every timestep, you can maintain a total
+//               external force on an object by calling this once
+//               every frame.
+//
+//               Mode determines if the torque is to be conventional
+//               or impulsive.
+//
+//               The actor must be dynamic.
+//               This call wakes the actor if it is sleeping and the
+//               wakeup parameter is true (default).
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+add_local_force_at_local_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!force.is_nan());
+  nassertv_always(!pos.is_nan());
+
+  _ptr->addLocalForceAtLocalPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::add_local_torque
+//       Access: Published
+//  Description: Applies an impulsive torque defined in the actor
+//               local coordinate frame to the actor.
+//
+//               Mode determines if the torque is to be conventional
+//               or impulsive.
+//
+//               The actor must be dynamic.
+//               This call wakes the actor if it is sleeping and the
+//               wakeup parameter is true (default).
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+add_local_torque(const LVector3f torque, PhysxForceMode mode, bool wakeup) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!torque.is_nan());
+
+  _ptr->addLocalTorque(PhysxManager::vec3_to_nxVec3(torque), (NxForceMode)mode, wakeup);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::update_mass_from_shapes
+//       Access: Published
+//  Description: Recomputes a dynamic actor's mass properties from
+//               its shapes. 
+//
+//               Given a constant density or total mass, the actors
+//               mass properties can be recomputed using the shapes
+//               attached to the actor. If the actor has no shapes,
+//               then only the totalMass parameter can be used. If
+//               all shapes in the actor are trigger shapes
+//               (non-physical), the call will fail.
+//
+//               The mass of each shape is either the shape's local
+//               density (as specified in the PhysxShapeDesc;
+//               default 1.0) multiplied by the shape's volume or a
+//               directly specified shape mass.
+//
+//               The inertia tensor, mass frame and center of mass
+//               will always be recomputed. If there are no shapes
+//               in the actor, the mass will be totalMass, and the
+//               mass frame will be set to the center of the actor.
+//
+//               If you supply a non-zero total mass, the actor's
+//               mass and inertia will first be computed as above
+//               and then scaled to fit this total mass.
+//
+//               If you supply a non-zero density, the actor's mass
+//               and inertia will first be computed as above and
+//               then scaled by this factor.
+//
+//               Either totalMass or density must be non-zero.
+//
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+bool PhysxActor::
+update_mass_from_shapes(float density, float totalMass) {
+
+  nassertr(_error_type == ET_ok, false);
+  return _ptr->updateMassFromShapes(density, totalMass);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::compute_kinetic_energy
+//       Access: Published
+//  Description: Computes the total kinetic (rotational and
+//               translational) energy of the object.
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+float PhysxActor::
+compute_kinetic_energy() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->computeKineticEnergy();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::is_dynamic
+//       Access: Published
+//  Description: Returns true if the actor is dynamic.
+////////////////////////////////////////////////////////////////////
+bool PhysxActor::
+is_dynamic() const {
+
+  nassertr(_error_type == ET_ok, false);
+  return _ptr->isDynamic();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_shape_group
+//       Access: Published
+//  Description: Sets the collision group for all shapes of this
+//               actor. See PhysxShape.setGroup().
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_shape_group(unsigned int group) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv(group >= 0 && group < 32);
+
+  NxShape * const *shapes = _ptr->getShapes();
+  NxU32 nShapes = _ptr->getNbShapes();
+
+  for (NxU32 i=0; i < nShapes; i++) {
+    shapes[i]->setGroup( group );
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_body_flag
+//       Access: Published
+//  Description: Raise or lower individual BodyFlag flags. 
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_body_flag(PhysxBodyFlag flag, bool value) {
+
+  if (value == true) {
+    _ptr->raiseBodyFlag((NxBodyFlag)flag);
+  }
+  else {
+    _ptr->clearBodyFlag((NxBodyFlag)flag);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_body_flag
+//       Access: Published
+//  Description: Return the specified BodyFlag flag.
+////////////////////////////////////////////////////////////////////
+bool PhysxActor::
+get_body_flag(PhysxBodyFlag flag) const {
+
+  nassertr(_error_type == ET_ok, false);
+  return ptr()->readBodyFlag((NxBodyFlag)flag);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_actor_flag
+//       Access: Published
+//  Description: Raise or lower individual ActorFlag flags. 
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_actor_flag(PhysxActorFlag flag, bool value) {
+
+  if (value == true) {
+    _ptr->raiseActorFlag((NxActorFlag)flag);
+  }
+  else {
+    _ptr->clearActorFlag((NxActorFlag)flag);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_actor_flag
+//       Access: Published
+//  Description: Return the specified ActorFlag flag.
+////////////////////////////////////////////////////////////////////
+bool PhysxActor::
+get_actor_flag(PhysxActorFlag flag) const {
+
+  nassertr(_error_type == ET_ok, false);
+  return ptr()->readActorFlag((NxActorFlag)flag);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_contact_report_flag
+//       Access: Published
+//  Description: Sets the actor's contact report flags.
+// 
+//               These flags are used to determine the kind of
+//               report that is generated for interactions with
+//               other actors.
+//
+//               Please note: If the actor is part of an interacting
+//               pair for which the contact report generation is
+//               controlled already through any other mechanism
+//               (for example by use of
+//               PhysxScene::set_actor_pair_flags)
+//               then the union of all the specified contact report
+//               flags will be used to generate the report.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_contact_report_flag(PhysxContactPairFlag flag, bool value) {
+
+  nassertv(_error_type == ET_ok);
+
+  NxU32 flags = _ptr->getContactReportFlags(); 
+
+  if (value == true) {
+    flags |= flag;
+  }
+  else {
+    flags &= ~(flag);
+  }
+
+  _ptr->setContactReportFlags(flags);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_contact_report_threshold
+//       Access: Published
+//  Description: Sets the force threshold for contact reports.
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_contact_report_threshold(float threshold) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv(threshold >= 0.0f);
+
+  _ptr->setContactReportThreshold(threshold);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_group
+//       Access: Published
+//  Description: Assigns the actor to a user defined group of
+//               actors. The actor group must be an integer in
+//               between 0 and 0x7fff (32767).
+//
+//               This is similar to NxShape groups, except those are
+//               only five bits and serve a different purpose.
+//
+//               The PhysxScene::set_actor_group_pair_flags() lets
+//               you set certain behaviors for pairs of actor
+//               groups.
+//
+//               By default every actor is created in group 0.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_group(unsigned int group) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv(group >= 0 && group < 0x8000);
+
+  ptr()->setGroup(group);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_group
+//       Access: Published
+//  Description: Retrieves the actor group this actor is assigned
+//               to.
+////////////////////////////////////////////////////////////////////
+unsigned int PhysxActor::
+get_group() const {
+
+  nassertr(_error_type == ET_ok, 0);
+
+  return ptr()->getGroup();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_dominance_group
+//       Access: Published
+//  Description: Assigns dynamic actors a dominance group
+//               identifier. Dominance groups are integere in the
+//               range from 0 to 31.
+//
+//               This is similar to shape groups, except those serve
+//               a different purpose.
+//
+//               The PhysxScene::set_dominance_group_pair() lets you
+//               set certain behaviors for pairs of dominance
+//               groups.
+//
+//               By default every actor is created in group 0.
+//               Static actors must stay in group 0; thus you can
+//               only call this on dynamic actors.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_dominance_group(unsigned int group) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv(group >= 0 && group < 32);
+  nassertv(is_dynamic() == true);
+
+  _ptr->setDominanceGroup(group);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_dominance_group
+//       Access: Published
+//  Description: Retrieves the dominance group of this actor.
+////////////////////////////////////////////////////////////////////
+unsigned int PhysxActor::
+get_dominance_group() const {
+
+  nassertr(_error_type == ET_ok, 0);
+
+  return ptr()->getDominanceGroup();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_angular_damping
+//       Access: Published
+//  Description: Sets the angular damping coefficient. Zero
+//               represents no damping. The angular damping
+//               coefficient must be nonnegative. The actor must be
+//               dynamic.
+//               Default: 0.05
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_angular_damping(float angDamp) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv(angDamp >= 0.0f);
+
+  _ptr->setAngularDamping(angDamp);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_angular_damping
+//       Access: Published
+//  Description: Returns the angular damping coefficient. 
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+float PhysxActor::
+get_angular_damping() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getAngularDamping();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_linear_damping
+//       Access: Published
+//  Description: Sets the linear damping coefficient. Zero
+//               represents no damping. The damping coefficient must
+//               be nonnegative. The actor must be dynamic.
+//               Default: 0
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_linear_damping(float linDamp) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv(linDamp >= 0.0f);
+
+  _ptr->setLinearDamping(linDamp);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_linear_damping
+//       Access: Published
+//  Description: Retrieves the linear damping coefficient. 
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+float PhysxActor::
+get_linear_damping() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getLinearDamping();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_linear_velocity
+//       Access: Published
+//  Description: Sets the linear velocity of the actor. 
+//
+//               Note that if you continuously set the velocity of
+//               an actor yourself, forces such as gravity or
+//               friction will not be able to manifest themselves,
+//               because forces directly influence only the
+//               velocity/momentum of an actor.
+//
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_linear_velocity(const LVector3f &linVel) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv(_ptr->isDynamic());
+
+  _ptr->setLinearVelocity(PhysxManager::vec3_to_nxVec3(linVel));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_angular_velocity
+//       Access: Published
+//  Description: Sets the angular velocity of the actor. 
+//
+//               Note that if you continuously set the angular
+//               velocity of an actor yourself, forces such as
+//               friction will not be able to rotate the actor,
+//               because forces directly influence only the
+//               velocity/momentum.
+//
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_angular_velocity(const LVector3f &angVel) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv(_ptr->isDynamic());
+
+  _ptr->setAngularVelocity(PhysxManager::vec3_to_nxVec3(angVel));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_max_angular_velocity
+//       Access: Published
+//  Description: Lets you set the maximum angular velocity permitted
+//               for this actor. 
+//
+//               Because for various internal computations, very
+//               quickly rotating actors introduce error into the
+//               simulation, which leads to undesired results.
+//
+//               With PhysxManager::set_parameter(PP_max_angular_velocity)
+//               you can set the default maximum velocity for actors
+//               created after the call. Bodies' high angular
+//               velocities are clamped to this value.
+//
+//               However, because some actors, such as car wheels,
+//               should be able to rotate quickly, you can override
+//               the default setting on a per-actor basis with the
+//               below call. Note that objects such as wheels which
+//               are approximated with spherical or other smooth
+//               collision primitives can be simulated with
+//               stability at a much higher angular velocity than,
+//               say, a box that has corners.
+//
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_max_angular_velocity(float maxAngVel) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv(_ptr->isDynamic());
+
+  _ptr->setMaxAngularVelocity(maxAngVel);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_linear_velocity
+//       Access: Published
+//  Description: Returns the linear velocity of an actor.
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxActor::
+get_linear_velocity() const {
+
+  nassertr(_error_type == ET_ok, LVector3f::zero());
+  return PhysxManager::nxVec3_to_vec3(_ptr->getLinearVelocity());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_angular_velocity
+//       Access: Published
+//  Description: Returns the angular velocity of the actor.
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxActor::
+get_angular_velocity() const {
+
+  nassertr(_error_type == ET_ok, LVector3f::zero());
+  return PhysxManager::nxVec3_to_vec3(_ptr->getAngularVelocity());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_max_angular_velocity
+//       Access: Published
+//  Description: Returns the maximum angular velocity permitted
+//               for this actor.
+////////////////////////////////////////////////////////////////////
+float PhysxActor::
+get_max_angular_velocity() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getMaxAngularVelocity();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_point_velocity
+//       Access: Published
+//  Description: Computes the velocity of a point given in world
+//               coordinates if it were attached to the actor and
+//               moving with it.
+//
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxActor::
+get_point_velocity(const LPoint3f &point) const {
+
+  nassertr(_error_type == ET_ok, LVector3f::zero());
+  nassertr_always(!point.is_nan(), LVector3f::zero());
+
+  NxVec3 nPoint = PhysxManager::point3_to_nxVec3(point);
+  return PhysxManager::nxVec3_to_vec3(_ptr->getPointVelocity(nPoint));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_local_point_velocity
+//       Access: Published
+//  Description: Computes the velocity of a point given in body
+//               local coordinates as if it were attached to the
+//               actor and moving with it. 
+//
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxActor::
+get_local_point_velocity(const LPoint3f &point) const {
+
+  nassertr(_error_type == ET_ok, LVector3f::zero());
+  nassertr_always(!point.is_nan(), LVector3f::zero());
+
+  NxVec3 nPoint = PhysxManager::point3_to_nxVec3(point);
+  return PhysxManager::nxVec3_to_vec3(_ptr->getLocalPointVelocity(nPoint));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_linear_momentum
+//       Access: Published
+//  Description: Sets the linear momentum of the actor. 
+//               Note that if you continuously set the linear
+//               momentum of an actor yourself, forces such as
+//               gravity or friction will not be able to manifest
+//               themselves, because forces directly influence only
+//               the velocity/momentum of a actor.
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_linear_momentum(const LVector3f &momentum) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setLinearMomentum(PhysxManager::vec3_to_nxVec3(momentum));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_angular_momentum
+//       Access: Published
+//  Description: Sets the angular momentum of the actor. 
+//               Note that if you continuously set the angular
+//               velocity of an actor yourself, forces such as
+//               friction will not be able to rotate the actor,
+//               because forces directly influence only the velocity
+//               of actor.
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_angular_momentum(const LVector3f &momentum) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setAngularMomentum(PhysxManager::vec3_to_nxVec3(momentum));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_linear_momentum
+//       Access: Published
+//  Description: Retrieves the linear momentum of an actor. 
+//               The momentum is equal to the velocity times the
+//               mass.
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxActor::
+get_linear_momentum() const {
+
+  nassertr(_error_type == ET_ok, LVector3f::zero());
+  return PhysxManager::nxVec3_to_vec3(_ptr->getLinearMomentum());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_angular_momentum
+//       Access: Published
+//  Description: Retrieves the angular momentum of an actor. 
+//               The angular momentum is equal to the angular
+//               velocity times the global space inertia tensor.
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxActor::
+get_angular_momentum() const {
+
+  nassertr(_error_type == ET_ok, LVector3f::zero());
+  return PhysxManager::nxVec3_to_vec3(_ptr->getAngularMomentum());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_sleep_linear_velocity
+//       Access: Published
+//  Description: Sets the linear velocity below which an actor may
+//               go to sleep. Actors whose linear velocity is above
+//               this threshold will not be put to sleep.
+//
+//               Setting the sleep angular/linear velocity only
+//               makes sense when the BF_energy_sleep_test is not
+//               set.
+//
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_sleep_linear_velocity(float threshold) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setSleepLinearVelocity(threshold);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_sleep_angular_velocity
+//       Access: Published
+//  Description: Sets the angular velocity below which an actor may
+//               go to sleep.  Actors whose angular velocity is
+//               above this threshold will not be put to sleep.
+//
+//               Setting the sleep angular/linear velocity only
+//               makes sense when the BF_energy_sleep_test is not
+//               set.
+//
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_sleep_angular_velocity(float threshold) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setSleepAngularVelocity(threshold);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_sleep_energy_threshold
+//       Access: Published
+//  Description: Sets the energy threshold below which an actor may
+//               go to sleep. Actors whose kinematic energy is above
+//               this threshold will not be put to sleep.
+//
+//               Setting the sleep energy threshold only makes sense
+//               when the BF_energy_sleep_test is set. There are
+//               also other types of sleeping that uses the linear
+//               and angular velocities directly instead of the
+//               energy.
+//
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_sleep_energy_threshold(float threshold) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setSleepEnergyThreshold(threshold);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_sleep_linear_velocity
+//       Access: Published
+//  Description: Returns the linear velocity below which an actor
+//               may go to sleep. Actors whose linear velocity is
+//               above this threshold will not be put to sleep.
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+float PhysxActor::
+get_sleep_linear_velocity() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getSleepLinearVelocity();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_sleep_angular_velocity
+//       Access: Published
+//  Description: Returns the angular velocity below which an actor
+//               may go to sleep. Actors whose angular velocity is
+//               above this threshold will not be put to sleep.
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+float PhysxActor::
+get_sleep_angular_velocity() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getSleepAngularVelocity();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_sleep_energy_threshold
+//       Access: Published
+//  Description: Returns the energy below which an actor may go to
+//               sleep. Actors whose energy is above this threshold
+//               will not be put to sleep. The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+float PhysxActor::
+get_sleep_energy_threshold() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getSleepEnergyThreshold();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::is_sleeping
+//       Access: Published
+//  Description: Returns true if this body is sleeping. 
+//
+//               When an actor does not move for a period of time,
+//               it is no longer simulated in order to save time.
+//               This state is called sleeping. However, because the
+//               object automatically wakes up when it is either
+//               touched by an awake object, or one of its
+//               properties is changed by the user, the entire sleep
+//               mechanism should be transparent to the user.
+//
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+bool PhysxActor::
+is_sleeping() const {
+
+  nassertr(_error_type == ET_ok, false);
+  return _ptr->isSleeping();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::wake_up
+//       Access: Published
+//  Description: Wakes up the actor if it is sleeping. 
+//
+//               The wakeCounterValue determines how long until the
+//               body is put to sleep, a value of zero means that
+//               the body is sleeping. wake_up(0) is equivalent to
+//               PhysxActor::put_to_sleep().
+//
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+wake_up(float wakeCounterValue) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->wakeUp(wakeCounterValue);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::put_to_sleep
+//       Access: Published
+//  Description: Forces the actor to sleep. 
+//
+//               The actor will stay asleep until the next call to
+//               simulate, and will not wake up until then even when
+//               otherwise it would (for example a force is applied
+//               to it). It can however wake up during the next
+//               do_physics call.
+//
+//               The actor must be dynamic.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+put_to_sleep() {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->putToSleep();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_mass
+//       Access: Published
+//  Description: Sets the mass of a dynamic actor.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_mass(float mass) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setMass(mass);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_mass
+//       Access: Published
+//  Description: Returns the mass of the actor.
+////////////////////////////////////////////////////////////////////
+float PhysxActor::
+get_mass() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getMass();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_c_mass_offset_local_mat
+//       Access: Published
+//  Description: Sets the matrix of the center of mass relative
+//               to the actor.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_c_mass_offset_local_mat(const LMatrix4f &mat) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setCMassOffsetLocalPose(PhysxManager::mat4_to_nxMat34(mat));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_c_mass_offset_local_pos
+//       Access: Published
+//  Description: Sets the position of the center of mass relative
+//               to the actor.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_c_mass_offset_local_pos(const LPoint3f &pos) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setCMassOffsetLocalPosition(PhysxManager::point3_to_nxVec3(pos));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_c_mass_offset_local_orientation
+//       Access: Published
+//  Description: Sets the orientation of the center of mass relative
+//               to the actor.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_c_mass_offset_local_orientation(const LMatrix3f &mat) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setCMassOffsetLocalOrientation(PhysxManager::mat3_to_nxMat33(mat));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_c_mass_offset_global_mat
+//       Access: Published
+//  Description: Sets the matrix of the center of mass relative
+//               to world space.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_c_mass_offset_global_mat(const LMatrix4f &mat) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setCMassOffsetGlobalPose(PhysxManager::mat4_to_nxMat34(mat));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_c_mass_offset_global_pos
+//       Access: Published
+//  Description: Sets the position of the center of mass relative
+//               to world space.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_c_mass_offset_global_pos(const LPoint3f &pos) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setCMassOffsetGlobalPosition(PhysxManager::point3_to_nxVec3(pos));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_c_mass_offset_global_orientation
+//       Access: Published
+//  Description: Sets the orientation of the center of mass relative
+//               to world space.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_c_mass_offset_global_orientation(const LMatrix3f &mat) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setCMassOffsetGlobalOrientation(PhysxManager::mat3_to_nxMat33(mat));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_c_mass_global_mat
+//       Access: Published
+//  Description: Moves the actor by setting the transform of the
+//               center of mass.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_c_mass_global_mat(const LMatrix4f &mat) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setCMassGlobalPose(PhysxManager::mat4_to_nxMat34(mat));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_c_mass_global_pos
+//       Access: Published
+//  Description: Moves the actor by setting the position of the
+//               center of mass.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_c_mass_global_pos(const LPoint3f &pos) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setCMassGlobalPosition(PhysxManager::point3_to_nxVec3(pos));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_c_mass_global_orientation
+//       Access: Published
+//  Description: Moves the actor by setting the orientation of the
+//               center of mass.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_c_mass_global_orientation(const LMatrix3f &mat) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setCMassGlobalOrientation(PhysxManager::mat3_to_nxMat33(mat));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::set_mass_space_inertia_tensor
+//       Access: Published
+//  Description: Sets the inertia tensor, using a parameter
+//               specified in mass space coordinates.
+////////////////////////////////////////////////////////////////////
+void PhysxActor::
+set_mass_space_inertia_tensor(const LVector3f &m) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setMassSpaceInertiaTensor(PhysxManager::vec3_to_nxVec3(m));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_c_mass_global_mat
+//       Access: Published
+//  Description: Returns the center of mass transform in world
+//               space.
+////////////////////////////////////////////////////////////////////
+LMatrix4f PhysxActor::
+get_c_mass_global_mat() const {
+
+  nassertr(_error_type == ET_ok, LMatrix4f::zeros_mat());
+  return PhysxManager::nxMat34_to_mat4(_ptr->getCMassGlobalPose());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_c_mass_global_pos
+//       Access: Published
+//  Description: Returns the center of mass position in world
+//               space.
+////////////////////////////////////////////////////////////////////
+LPoint3f PhysxActor::
+get_c_mass_global_pos() const {
+
+  nassertr(_error_type == ET_ok, LPoint3f::zero());
+  return PhysxManager::nxVec3_to_point3(_ptr->getCMassGlobalPosition());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_c_mass_global_orientation
+//       Access: Published
+//  Description: Returns the center of mass orientation in world
+//               space.
+////////////////////////////////////////////////////////////////////
+LMatrix3f PhysxActor::
+get_c_mass_global_orientation() const {
+
+  nassertr(_error_type == ET_ok, LMatrix3f::ident_mat());
+  return PhysxManager::nxMat33_to_mat3(_ptr->getCMassGlobalOrientation());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_c_mass_local_mat
+//       Access: Published
+//  Description: Returns the center of mass transform relative
+//               to the actor.
+////////////////////////////////////////////////////////////////////
+LMatrix4f PhysxActor::
+get_c_mass_local_mat() const {
+
+  nassertr(_error_type == ET_ok, LMatrix4f::zeros_mat());
+  return PhysxManager::nxMat34_to_mat4(_ptr->getCMassLocalPose());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_c_mass_local_pos
+//       Access: Published
+//  Description: Returns the center of mass position relative to
+//               the actor.
+////////////////////////////////////////////////////////////////////
+LPoint3f PhysxActor::
+get_c_mass_local_pos() const {
+
+  nassertr(_error_type == ET_ok, LPoint3f::zero());
+  return PhysxManager::nxVec3_to_point3(_ptr->getCMassLocalPosition());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_c_mass_local_orientation
+//       Access: Published
+//  Description: Returns the center of mass orientation relative to
+//               the actor.
+////////////////////////////////////////////////////////////////////
+LMatrix3f PhysxActor::
+get_c_mass_local_orientation() const {
+
+  nassertr(_error_type == ET_ok, LMatrix3f::ident_mat());
+  return PhysxManager::nxMat33_to_mat3(_ptr->getCMassLocalOrientation());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_mass_space_inertia_tensor
+//       Access: Published
+//  Description: Returns the diagonal inertia tensor of the actor
+//               relative to the mass coordinate frame.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxActor::
+get_mass_space_inertia_tensor() const {
+
+  nassertr(_error_type == ET_ok, LVector3f::zero());
+  return PhysxManager::nxVec3_to_vec3(_ptr->getMassSpaceInertiaTensor());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_global_inertia_tensor
+//       Access: Published
+//  Description: Returns the inertia tensor of the actor relative
+//               to the world coordinate frame.
+////////////////////////////////////////////////////////////////////
+LMatrix3f PhysxActor::
+get_global_inertia_tensor() const {
+
+  nassertr(_error_type == ET_ok, LMatrix3f::ident_mat());
+  return PhysxManager::nxMat33_to_mat3(_ptr->getGlobalInertiaTensor());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActor::get_global_inertia_tensor_inverse
+//       Access: Published
+//  Description: Returns the inverse of the inertia tensor of the
+//               actor relative to the world coordinate frame.
+////////////////////////////////////////////////////////////////////
+LMatrix3f PhysxActor::
+get_global_inertia_tensor_inverse() const {
+
+  nassertr(_error_type == ET_ok, LMatrix3f::ident_mat());
+  return PhysxManager::nxMat33_to_mat3(_ptr->getGlobalInertiaTensorInverse());
+}
+

+ 227 - 0
panda/src/physx/physxActor.h

@@ -0,0 +1,227 @@
+// Filename: physxActor.h
+// Created by:  enn0x (14Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXACTOR_H
+#define PHYSXACTOR_H
+
+#include "pandabase.h"
+#include "nodePath.h"
+#include "lmatrix.h"
+#include "lvector3.h"
+#include "lpoint3.h"
+#include "lquaternion.h"
+
+#include "physxObject.h"
+#include "physxObjectCollection.h"
+#include "physxEnums.h"
+
+#include "NoMinMax.h"
+#include "NxPhysics.h"
+
+class PhysxController;
+class PhysxScene;
+class PhysxShape;
+class PhysxShapeDesc;
+class PhysxActorDesc;
+class PhysxBodyDesc;
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxActor
+// Description : Actors are the main simulation objects. Actors
+//               are owned by a scene (PhysxScene).
+//
+//               An actor may optionally encapsulate a dynamic rigid
+//               body by setting the body member of the actor's
+//               descriptor when it is created. Otherwise the actor
+//               will be static (fixed in the world).
+//
+//               Instances of PhysxActor are created by calling
+//               PhysxScene::create_actor() and destroyed by calling
+//               PhysxActor::release().
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxActor : public PhysxObject, public PhysxEnums {
+
+PUBLISHED:
+  INLINE PhysxActor();
+  INLINE ~PhysxActor();
+
+  bool save_body_to_desc(PhysxBodyDesc &bodyDesc) const;
+  void save_to_desc(PhysxActorDesc &actorDesc) const;
+
+  void set_name(const char *name);
+  void set_global_pos(const LPoint3f &pos);
+  void set_global_mat(const LMatrix4f &mat);
+  void set_global_hpr(float h, float p, float r);
+  void set_body_flag(PhysxBodyFlag flag, bool value);
+  void set_actor_flag(PhysxActorFlag flag, bool value);
+  void set_contact_report_flag(PhysxContactPairFlag flag, bool value);
+  void set_contact_report_threshold(float threshold);
+  void set_group(unsigned int group);
+  void set_dominance_group(unsigned int group);
+  void set_shape_group( unsigned int group );
+
+  const char *get_name() const;
+  LPoint3f get_global_pos() const;
+  LMatrix4f get_global_mat() const;
+  LQuaternionf get_global_quat() const;
+  bool get_body_flag(PhysxBodyFlag flag) const;
+  bool get_actor_flag(PhysxActorFlag flag) const;
+  unsigned int get_group() const;
+  unsigned int get_dominance_group() const;
+
+  bool is_dynamic() const;
+  float compute_kinetic_energy() const;
+  bool update_mass_from_shapes(float density, float totalMass);
+
+  PT(PhysxScene) get_scene() const;
+
+  // NodePath
+  void attach_node_path(const NodePath &np);
+  void detach_node_path();
+  NodePath get_node_path() const;
+
+  // Shapes
+  unsigned int get_num_shapes() const;
+  PT(PhysxShape) create_shape(PhysxShapeDesc &desc);
+  PT(PhysxShape) get_shape(unsigned int idx) const;
+  PT(PhysxShape) get_shape_by_name(const char *name) const;
+  MAKE_SEQ(get_shapes, get_num_shapes, get_shape);
+
+  // Forces
+  void add_force(const LVector3f force, 
+     PhysxForceMode mode=FM_force, bool wakeup=true);
+  void add_force_at_pos(const LVector3f force, const LPoint3f &pos,
+     PhysxForceMode mode=FM_force, bool wakeup=true);
+  void add_force_at_local_pos(const LVector3f force, const LPoint3f &pos,
+     PhysxForceMode mode=FM_force, bool wakeup=true);
+  void add_torque(const LVector3f torque,
+     PhysxForceMode mode=FM_force, bool wakeup=true);
+  void add_local_force(const LVector3f force,
+     PhysxForceMode mode=FM_force, bool wakeup=true);
+  void add_local_force_at_pos(const LVector3f force, const LPoint3f &pos,
+     PhysxForceMode mode=FM_force, bool wakeup=true);
+  void add_local_force_at_local_pos(const LVector3f force, const LPoint3f &pos,
+     PhysxForceMode mode=FM_force, bool wakeup=true);
+  void add_local_torque(const LVector3f torque,
+     PhysxForceMode mode=FM_force, bool wakeup=true);
+
+  // Mass manipulation
+  void set_mass(float mass);
+  void set_c_mass_offset_local_mat(const LMatrix4f &mat);
+  void set_c_mass_offset_local_pos(const LPoint3f &pos);
+  void set_c_mass_offset_local_orientation(const LMatrix3f &mat);
+  void set_c_mass_offset_global_mat(const LMatrix4f &mat);
+  void set_c_mass_offset_global_pos(const LPoint3f &pos);
+  void set_c_mass_offset_global_orientation(const LMatrix3f &mat);
+  void set_c_mass_global_mat(const LMatrix4f &mat);
+  void set_c_mass_global_pos(const LPoint3f &pos);
+  void set_c_mass_global_orientation(const LMatrix3f &mat);
+  void set_mass_space_inertia_tensor(const LVector3f &m);
+
+  float get_mass() const;
+  LMatrix4f get_c_mass_global_mat() const;
+  LPoint3f get_c_mass_global_pos() const;
+  LMatrix3f get_c_mass_global_orientation() const;
+  LMatrix4f get_c_mass_local_mat() const;
+  LPoint3f get_c_mass_local_pos() const;
+  LMatrix3f get_c_mass_local_orientation() const;
+  LVector3f get_mass_space_inertia_tensor() const;
+  LMatrix3f get_global_inertia_tensor() const;
+  LMatrix3f get_global_inertia_tensor_inverse() const;
+
+  // Damping
+  void set_linear_damping(float linDamp);
+  void set_angular_damping(float angDamp);
+  float get_linear_damping() const;
+  float get_angular_damping() const;
+
+  // Vecocity
+  void set_linear_velocity(const LVector3f &linVel);
+  void set_angular_velocity(const LVector3f &angVel);
+  void set_max_angular_velocity(float maxAngVel);
+
+  LVector3f get_linear_velocity() const;
+  LVector3f get_angular_velocity() const;
+  float get_max_angular_velocity() const;
+
+  // Point Velocity 
+  LVector3f get_point_velocity(const LPoint3f &point) const;
+  LVector3f get_local_point_velocity(const LPoint3f &point) const; 
+
+  // Momentum
+  void set_linear_momentum(const LVector3f &momentum);
+  void set_angular_momentum(const LVector3f &momentum);
+  LVector3f get_linear_momentum() const;
+  LVector3f get_angular_momentum() const;
+
+  // Sleeping
+  void set_sleep_linear_velocity(float threshold);
+  void set_sleep_angular_velocity(float threshold);
+  void set_sleep_energy_threshold(float threshold);
+  float get_sleep_linear_velocity() const;
+  float get_sleep_angular_velocity() const;
+  float get_sleep_energy_threshold() const;
+  bool is_sleeping() const;
+  void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL);
+  void put_to_sleep();
+
+  INLINE void ls() const;
+  INLINE void ls(ostream &out, int indent_level=0) const;
+
+public:
+  void update_transform(const LMatrix4f m);
+
+////////////////////////////////////////////////////////////////////
+PUBLISHED:
+  void release();
+
+public:
+  INLINE NxActor *ptr() const { return _ptr; };
+
+  void link_controller(PT(PhysxController) controller);
+  void link(NxActor *ptr);
+  void unlink();
+
+  PhysxObjectCollection<PhysxShape> _shapes;
+
+private:
+  NxActor *_ptr;
+  NodePath _np;
+  PT(PhysxController) _controller;
+
+////////////////////////////////////////////////////////////////////
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    PhysxObject::init_type();
+    register_type(_type_handle, "PhysxActor", 
+                  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 "physxActor.I"
+
+#endif // PHYSXACTOR_H

+ 27 - 43
panda/src/physx/physxActorDesc.I

@@ -1,5 +1,5 @@
 // Filename: physxActorDesc.I
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (05Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,64 +12,48 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-////////////////////////////////////////////////////////////////////
-//     Function : is_valid
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE bool PhysxActorDesc::
-is_valid() const {
-  return nActorDesc.isValid();
-}
 
-////////////////////////////////////////////////////////////////////
-//     Function : set_to_default
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxActorDesc::
-set_to_default() {
-  nActorDesc.setToDefault();
-}
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_density
-//       Access : Published
-//  Description :
+//     Function: PhysxActorDesc::Constructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE float PhysxActorDesc::
-get_density() const {
-  return nActorDesc.density;
+INLINE PhysxActorDesc::
+PhysxActorDesc() {
+
+  _desc.name = "";
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_flags
-//       Access : Published
-//  Description :
+//     Function: PhysxActorDesc::Destructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE unsigned int PhysxActorDesc::
-get_flags() const {
-  return nActorDesc.flags;
+INLINE PhysxActorDesc::
+~PhysxActorDesc() {
+
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_density
-//       Access : Published
-//  Description :
+//     Function: PhysxActorDesc::set_to_default
+//       Access: Published
+//  Description: (re)sets the structure to the default.
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysxActorDesc::
-set_density(float value) {
-  nActorDesc.density = value;
+set_to_default() {
+
+  _desc.setToDefault();
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_flags
-//       Access : Published
-//  Description :
+//     Function: PhysxActorDesc::is_valid
+//       Access: Published
+//  Description: Returns true if the descriptor is valid.
 ////////////////////////////////////////////////////////////////////
-INLINE void PhysxActorDesc::
-set_flags(unsigned int value) {
-  nActorDesc.flags = value;
-}
+INLINE bool PhysxActorDesc::
+is_valid() const {
 
+  return _desc.isValid();
+}
 

+ 126 - 37
panda/src/physx/physxActorDesc.cxx

@@ -1,5 +1,5 @@
 // Filename: physxActorDesc.cxx
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (05Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,70 +12,159 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifdef HAVE_PHYSX
-
 #include "physxActorDesc.h"
-#include "physxShapeDesc.h"
 #include "physxBodyDesc.h"
+#include "physxManager.h"
 
 ////////////////////////////////////////////////////////////////////
-//     Function : PhysxActorDesc
-//       Access : Published
-//  Description :
+//     Function: PhysxActorDesc::add_shape
+//       Access: Published
+//  Description: Adds a shape to the list of collision shapes
+//               composing this actor.
 ////////////////////////////////////////////////////////////////////
-PhysxActorDesc::
-PhysxActorDesc() {
+void PhysxActorDesc::
+add_shape(PhysxShapeDesc &desc) {
+
+  _desc.shapes.push_back(desc.ptr());
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : add_shape
-//       Access : Published
-//  Description :
+//     Function: PhysxActorDesc::set_name
+//       Access: Published
+//  Description: Sets the optional debug name for the actor.
 ////////////////////////////////////////////////////////////////////
 void PhysxActorDesc::
-add_shape(PhysxShapeDesc pShapeDesc) {
-  nActorDesc.shapes.pushBack(pShapeDesc.nShapeDesc);
+set_name(const char *name) {
+
+  _desc.name = name;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_body
-//       Access : Published
-//  Description :
+//     Function: PhysxActorDesc::set_density
+//       Access: Published
+//  Description: Set the density used during mass/intertia
+//               computation. This value is used if the actor's
+//               shapes do not have a mass asigned.
 ////////////////////////////////////////////////////////////////////
-const PhysxBodyDesc * PhysxActorDesc::
-get_body() const {
-  throw "Not Implemented"; // return nActorDesc.body;
+void PhysxActorDesc::
+set_density(float density) {
+
+  _desc.density = density;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_global_pose
-//       Access : Published
-//  Description :
+//     Function: PhysxActorDesc::set_global_pos
+//       Access: Published
+//  Description: Set the position of the actor in global space.
 ////////////////////////////////////////////////////////////////////
-LMatrix4f PhysxActorDesc::
-get_global_pose() const {
-  return PhysxManager::nxMat34_to_lMatrix4(nActorDesc.globalPose);
+void PhysxActorDesc::
+set_global_pos(const LPoint3f &pos) {
+
+  _desc.globalPose.t = PhysxManager::point3_to_nxVec3(pos);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActorDesc::set_global_mat
+//       Access: Published
+//  Description: Set the position and orientation of the actor
+//               in global space. Scaling and shear arenot
+//               supported, even if the matrix contains a scale or
+//               shear.
+////////////////////////////////////////////////////////////////////
+void PhysxActorDesc::
+set_global_mat(const LMatrix4f &mat) {
+
+  _desc.globalPose = PhysxManager::mat4_to_nxMat34(mat);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_body
-//       Access : Published
-//  Description :
+//     Function: PhysxActorDesc::set_global_hpr
+//       Access: Published
+//  Description: Sets the orientation of the actor in global space
+//               by providing angles for heading, pitch and roll.
 ////////////////////////////////////////////////////////////////////
 void PhysxActorDesc::
-set_body(const PhysxBodyDesc * value) {
-  nActorDesc.body = &(value->nBodyDesc);
+set_global_hpr(float h, float p, float r) {
+
+  LQuaternionf q;
+  LMatrix3f rot;
+  NxMat34 m;
+
+  q.set_hpr(LVector3f(h, p, r));
+  q.extract_to_matrix(rot);
+
+  _desc.globalPose.M = PhysxManager::mat3_to_nxMat33(rot);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_global_pose
-//       Access : Published
-//  Description :
+//     Function: PhysxActorDesc::set_body
+//       Access: Published
+//  Description: Sets the body descriptor for this actor. The actor
+//               will be dynmaic if a body descriptor is set, and
+//               static if no body descriptor is set.
 ////////////////////////////////////////////////////////////////////
 void PhysxActorDesc::
-set_global_pose(LMatrix4f value) {
-  nActorDesc.globalPose = PhysxManager::lMatrix4_to_nxMat34(value);
+set_body(PhysxBodyDesc &desc) {
+
+  _desc.body = &(desc._desc);
 }
 
-#endif // HAVE_PHYSX
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActorDesc::get_body
+//       Access: Published
+//  Description: Gets the body descriptor for this actor.
+////////////////////////////////////////////////////////////////////
+PhysxBodyDesc PhysxActorDesc::
+get_body() const {
+
+  throw "Not Implemented";
+
+  //PhysxBodyDesc value;
+  //value._desc = *(_desc.body);
+  //return value;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActorDesc::get_name
+//       Access: Published
+//  Description: Returns the optional debug name for this actor.
+////////////////////////////////////////////////////////////////////
+const char *PhysxActorDesc::
+get_name() const {
+
+  return _desc.name;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActorDesc::get_density
+//       Access: Published
+//  Description: Returns the actor's density.
+////////////////////////////////////////////////////////////////////
+float PhysxActorDesc::
+get_density() const {
+
+  return _desc.density;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActorDesc::get_global_pos
+//       Access: Published
+//  Description: Returns the actor's position in global space.
+////////////////////////////////////////////////////////////////////
+LPoint3f PhysxActorDesc::
+get_global_pos() const {
+
+  return PhysxManager::nxVec3_to_point3(_desc.globalPose.t);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxActorDesc::get_global_mat
+//       Access: Published
+//  Description: Returns the actor's transform in global space.
+////////////////////////////////////////////////////////////////////
+LMatrix4f PhysxActorDesc::
+get_global_mat() const {
+
+  return PhysxManager::nxMat34_to_mat4(_desc.globalPose);
+}
 

+ 24 - 24
panda/src/physx/physxActorDesc.h

@@ -1,5 +1,5 @@
 // Filename: physxActorDesc.h
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (05Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -15,48 +15,48 @@
 #ifndef PHYSXACTORDESC_H
 #define PHYSXACTORDESC_H
 
-#ifdef HAVE_PHYSX
-
 #include "pandabase.h"
+#include "lpoint3.h"
+#include "lmatrix.h"
 
-#include "physx_enumerations.h"
-#include "physxManager.h"
-#include "luse.h"
+#include "NoMinMax.h"
+#include "NxPhysics.h"
 
-class PhysxShapeDesc;
 class PhysxBodyDesc;
-
-#include "NxPhysics.h"
+class PhysxShapeDesc;
 
 ////////////////////////////////////////////////////////////////////
 //       Class : PhysxActorDesc
-// Description :
+// Description : Descriptor for PhysxActor.
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDAPHYSX PhysxActorDesc {
+
 PUBLISHED:
-  PhysxActorDesc();
+  INLINE PhysxActorDesc();
+  INLINE ~PhysxActorDesc();
 
-  INLINE bool is_valid() const;
   INLINE void set_to_default();
+  INLINE bool is_valid() const;
 
-  void add_shape(PhysxShapeDesc pShapeDesc);
+  void add_shape(PhysxShapeDesc &desc);
 
-  const PhysxBodyDesc * get_body() const;
-  INLINE float get_density() const;
-  INLINE unsigned int get_flags() const;
-  LMatrix4f get_global_pose() const;
+  void set_name(const char *name);
+  void set_density(float density);
+  void set_global_pos(const LPoint3f &pos);
+  void set_global_mat(const LMatrix4f &mat);
+  void set_global_hpr(float h, float p, float r);
+  void set_body(PhysxBodyDesc &desc);
 
-  void set_body( const PhysxBodyDesc * value );
-  INLINE void set_density( float value );
-  INLINE void set_flags( unsigned int value );
-  void set_global_pose( LMatrix4f value );
+  const char *get_name() const;
+  float get_density() const;
+  LPoint3f get_global_pos() const;
+  LMatrix4f get_global_mat() const;
+  PhysxBodyDesc get_body() const;
 
 public:
-  NxActorDesc nActorDesc;
+  NxActorDesc _desc;
 };
 
 #include "physxActorDesc.I"
 
-#endif // HAVE_PHYSX
-
 #endif // PHYSXACTORDESC_H

+ 0 - 79
panda/src/physx/physxActorNode.I

@@ -1,79 +0,0 @@
-// Filename: physxActorNode.I
-// Created by:  pratt (Apr 7, 2006)
-//
-////////////////////////////////////////////////////////////////////
-//
-// 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 : update_transform
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxActorNode::
-update_transform() {
-  _disable_transform_changed = true;
-  get_global_pose_optimized(&_tempMat4);
-  set_transform(TransformState::make_mat(_tempMat4));
-  _disable_transform_changed = false;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_global_pose_optimized
-//       Access : Published
-//  Description : This is an optimized version of get_global_pose that
-//                copies the pose data to a passed matrix rather than
-//                returning a new matrix, and also optimizes the
-//                translation from PhysX matrix to Panda matrix.
-//                It is primarily intended to be used by the
-//                update_transform method, which is called in a tight
-//                loop when transforms are copied from the PhysX
-//                library to Panda.
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxActorNode::
-get_global_pose_optimized(LMatrix4f *result) {
-  nassertv(nActor != NULL);
-
-  nActor->getGlobalPose().getColumnMajor44(_tempCells);
-  result->set(
-    _tempCells[0],  _tempCells[1],  _tempCells[2],  _tempCells[3],
-    _tempCells[4],  _tempCells[5],  _tempCells[6],  _tempCells[7],
-    _tempCells[8],  _tempCells[9],  _tempCells[10], _tempCells[11],
-    _tempCells[12], _tempCells[13], _tempCells[14], _tempCells[15]
-  );
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_global_pose
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE LMatrix4f PhysxActorNode::
-get_global_pose() const {
-  nassertr(nActor != NULL, *((LMatrix4f *)NULL));
-
-  return PhysxManager::nxMat34_to_lMatrix4(nActor->getGlobalPose());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : is_valid
-//       Access : Published
-//  Description : Returns true if the NxActor associated with this
-//                ActorNode is not NULL.  The NxActor will be NULL if
-//                the ActorNode has been released.
-////////////////////////////////////////////////////////////////////
-INLINE bool PhysxActorNode::
-is_valid() {
-  return nActor != NULL;
-}
-
-
-
-

+ 0 - 1190
panda/src/physx/physxActorNode.cxx

@@ -1,1190 +0,0 @@
-// Filename: physxActorNode.cxx
-// Created by:  pratt (Apr 7, 2006)
-//
-////////////////////////////////////////////////////////////////////
-//
-// 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."
-//
-////////////////////////////////////////////////////////////////////
-
-#ifdef HAVE_PHYSX
-
-#include "physxActorNode.h"
-
-#include "luse.h"
-#include "physxBodyDesc.h"
-#include "physxScene.h"
-#include "physxShape.h"
-#include "physxShapeDesc.h"
-#include "physxBoxShape.h"
-#include "physxCapsuleShape.h"
-#include "physxPlaneShape.h"
-#include "physxSphereShape.h"
-
-TypeHandle PhysxActorNode::_type_handle;
-
-////////////////////////////////////////////////////////////////////
-//     Function : PhysxActorNode
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-PhysxActorNode::
-PhysxActorNode(const string &name) : PandaNode(name) {
-  _disable_transform_changed = false;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_num_shapes
-//       Access : Published
-//  Description : Returns the number of PhysxShapes associated with
-//                this PhysxActorNode.
-////////////////////////////////////////////////////////////////////
-unsigned int PhysxActorNode::
-get_num_shapes() {
-  nassertr(nActor != NULL, -1);
-
-  return nActor->getNbShapes();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_shape
-//       Access : Published
-//  Description : Returns the PhysxShape associated with this
-//                PhysxActorNode at index i.
-////////////////////////////////////////////////////////////////////
-PhysxShape *PhysxActorNode::
-get_shape(unsigned int i) {
-  nassertr(nActor != NULL, NULL);
-
-  if((i >= 0) && (i < nActor->getNbShapes())) {
-    NxShape * const* nShapes = nActor->getShapes();
-    PhysxShape *pShape = (PhysxShape *)nShapes[i]->userData;
-    return pShape;
-  } else {
-    physx_warning( "PhysxActorNode::get_shape: " << this->get_name() << ": index out of bounds; i=" << i );
-    return NULL;
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : add_force
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-add_force(const LVecBase3f & force, PhysxForceMode mode, bool wakeup) {
-  nassertv(nActor != NULL);
-
-  nActor->addForce(PhysxManager::lVecBase3_to_nxVec3(force), (NxForceMode)mode, wakeup);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : add_force_at_local_pos
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-add_force_at_local_pos(const LVecBase3f & force, const LVecBase3f & pos, PhysxForceMode mode, bool wakeup) {
-  nassertv(nActor != NULL);
-
-  nActor->addForceAtLocalPos(PhysxManager::lVecBase3_to_nxVec3(force), PhysxManager::lVecBase3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : add_force_at_pos
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-add_force_at_pos(const LVecBase3f & force, const LVecBase3f & pos, PhysxForceMode mode, bool wakeup) {
-  nassertv(nActor != NULL);
-
-  nActor->addForceAtPos(PhysxManager::lVecBase3_to_nxVec3(force), PhysxManager::lVecBase3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : add_local_force
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-add_local_force(const LVecBase3f & force, PhysxForceMode mode, bool wakeup) {
-  nassertv(nActor != NULL);
-
-  nActor->addLocalForce(PhysxManager::lVecBase3_to_nxVec3(force), (NxForceMode)mode, wakeup);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : add_local_force_at_local_pos
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-add_local_force_at_local_pos(const LVecBase3f & force, const LVecBase3f & pos, PhysxForceMode mode, bool wakeup) {
-  nassertv(nActor != NULL);
-
-  nActor->addLocalForceAtLocalPos(PhysxManager::lVecBase3_to_nxVec3(force), PhysxManager::lVecBase3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : add_local_force_at_pos
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-add_local_force_at_pos(const LVecBase3f & force, const LVecBase3f & pos, PhysxForceMode mode, bool wakeup) {
-  nassertv(nActor != NULL);
-
-  nActor->addLocalForceAtPos(PhysxManager::lVecBase3_to_nxVec3(force), PhysxManager::lVecBase3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : add_local_torque
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-add_local_torque(const LVecBase3f & torque, PhysxForceMode mode, bool wakeup) {
-  nassertv(nActor != NULL);
-
-  nActor->addLocalTorque(PhysxManager::lVecBase3_to_nxVec3(torque), (NxForceMode)mode, wakeup);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : add_torque
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-add_torque(const LVecBase3f & torque, PhysxForceMode mode, bool wakeup) {
-  nassertv(nActor != NULL);
-
-  nActor->addTorque(PhysxManager::lVecBase3_to_nxVec3(torque), (NxForceMode)mode, wakeup);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : clear_actor_flag
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-clear_actor_flag(PhysxActorFlag actor_flag) {
-  nassertv(nActor != NULL);
-
-  nActor->clearActorFlag((NxActorFlag)actor_flag);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : clear_body_flag
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-clear_body_flag(PhysxBodyFlag body_flag) {
-  nassertv(nActor != NULL);
-
-  nActor->clearBodyFlag((NxBodyFlag)body_flag);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : compute_kinetic_energy
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-float PhysxActorNode::
-compute_kinetic_energy() const {
-  nassertr(nActor != NULL, -1.0f);
-
-  return nActor->computeKineticEnergy();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : create_shape
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-PhysxShape * PhysxActorNode::
-create_shape(const PhysxShapeDesc & desc) {
-  nassertr(nActor != NULL, NULL);
-
-  // Some pointer nastiness is required to cast PT(PhysxShape) to each
-  // specific shape type.
-  NxShape *nShape = nActor->createShape(*(desc.nShapeDesc));
-  PT(PhysxShape) pShape;
-  PhysxShape *pShapePointer;
-  if(nShape->getType() == NX_SHAPE_BOX) {
-    pShape = new PhysxBoxShape();
-    pShapePointer = (PhysxShape *)pShape;
-    ((PhysxBoxShape *)pShapePointer)->nBoxShape = (NxBoxShape *)nShape;
-  } else if(nShape->getType() == NX_SHAPE_CAPSULE) {
-    pShape = new PhysxCapsuleShape();
-    pShapePointer = (PhysxShape *)pShape;
-    ((PhysxCapsuleShape *)pShapePointer)->nCapsuleShape = (NxCapsuleShape *)nShape;
-  } else if(nShape->getType() == NX_SHAPE_PLANE) {
-    pShape = new PhysxPlaneShape();
-    pShapePointer = (PhysxShape *)pShape;
-    ((PhysxPlaneShape *)pShapePointer)->nPlaneShape = (NxPlaneShape *)nShape;
-  } else if(nShape->getType() == NX_SHAPE_SPHERE) {
-    pShape = new PhysxSphereShape();
-    pShapePointer = (PhysxShape *)pShape;
-    ((PhysxSphereShape *)pShapePointer)->nSphereShape = (NxSphereShape *)nShape;
-  }
-  nShape->userData = pShape;
-  pShape->nShape = nShape;
-  return pShape;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_angular_damping
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-float PhysxActorNode::
-get_angular_damping() const {
-  nassertr(nActor != NULL, -1.0f);
-
-  return nActor->getAngularDamping();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_angular_momentum
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxActorNode::
-get_angular_momentum() const {
-  nassertr(nActor != NULL, *((LVecBase3f *)NULL));
-
-  return PhysxManager::nxVec3_to_lVecBase3(nActor->getAngularMomentum());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_angular_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxActorNode::
-get_angular_velocity() const {
-  nassertr(nActor != NULL, *((LVecBase3f *)NULL));
-
-  return PhysxManager::nxVec3_to_lVecBase3(nActor->getAngularVelocity());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_c_mass_global_orientation
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LMatrix3f PhysxActorNode::
-get_c_mass_global_orientation() const {
-  nassertr(nActor != NULL, *((LMatrix3f *)NULL));
-
-  return PhysxManager::nxMat33_to_lMatrix3(nActor->getCMassGlobalOrientation());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_c_mass_global_pose
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LMatrix4f PhysxActorNode::
-get_c_mass_global_pose() const {
-  nassertr(nActor != NULL, *((LMatrix4f *)NULL));
-
-  return PhysxManager::nxMat34_to_lMatrix4(nActor->getCMassGlobalPose());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_c_mass_global_position
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxActorNode::
-get_c_mass_global_position() const {
-  nassertr(nActor != NULL, *((LVecBase3f *)NULL));
-
-  return PhysxManager::nxVec3_to_lVecBase3(nActor->getCMassGlobalPosition());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_c_mass_local_orientation
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LMatrix3f PhysxActorNode::
-get_c_mass_local_orientation() const {
-  nassertr(nActor != NULL, *((LMatrix3f *)NULL));
-
-  return PhysxManager::nxMat33_to_lMatrix3(nActor->getCMassLocalOrientation());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_c_mass_local_pose
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LMatrix4f PhysxActorNode::
-get_c_mass_local_pose() const {
-  nassertr(nActor != NULL, *((LMatrix4f *)NULL));
-
-  return PhysxManager::nxMat34_to_lMatrix4(nActor->getCMassLocalPose());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_c_mass_local_position
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxActorNode::
-get_c_mass_local_position() const {
-  nassertr(nActor != NULL, *((LVecBase3f *)NULL));
-
-  return PhysxManager::nxVec3_to_lVecBase3(nActor->getCMassLocalPosition());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_ccd_motion_threshold
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-float PhysxActorNode::
-get_ccd_motion_threshold() const {
-  nassertr(nActor != NULL, -1.0f);
-
-  return nActor->getCCDMotionThreshold();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_global_inertia_tensor
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LMatrix3f PhysxActorNode::
-get_global_inertia_tensor() const {
-  nassertr(nActor != NULL, *((LMatrix3f *)NULL));
-
-  return PhysxManager::nxMat33_to_lMatrix3(nActor->getGlobalInertiaTensor());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_global_inertia_tensor_inverse
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LMatrix3f PhysxActorNode::
-get_global_inertia_tensor_inverse() const {
-  nassertr(nActor != NULL, *((LMatrix3f *)NULL));
-
-  return PhysxManager::nxMat33_to_lMatrix3(nActor->getGlobalInertiaTensorInverse());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_global_orientation
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LMatrix3f PhysxActorNode::
-get_global_orientation() const {
-  nassertr(nActor != NULL, *((LMatrix3f *)NULL));
-
-  return PhysxManager::nxMat33_to_lMatrix3(nActor->getGlobalOrientation());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_global_orientation_quat
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LQuaternionf PhysxActorNode::
-get_global_orientation_quat() const {
-  nassertr(nActor != NULL, *((LQuaternionf *)NULL));
-
-  return PhysxManager::nxQuat_to_lQuaternion(nActor->getGlobalOrientationQuat());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_global_position
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxActorNode::
-get_global_position() const {
-  nassertr(nActor != NULL, *((LVecBase3f *)NULL));
-
-  return PhysxManager::nxVec3_to_lVecBase3(nActor->getGlobalPosition());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_group
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-unsigned short PhysxActorNode::
-get_group() const {
-  nassertr(nActor != NULL, -1);
-
-  return nActor->getGroup();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_linear_damping
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-float PhysxActorNode::
-get_linear_damping() const {
-  nassertr(nActor != NULL, -1.0f);
-
-  return nActor->getLinearDamping();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_linear_momentum
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxActorNode::
-get_linear_momentum() const {
-  nassertr(nActor != NULL, *((LVecBase3f *)NULL));
-
-  return PhysxManager::nxVec3_to_lVecBase3(nActor->getLinearMomentum());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_linear_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxActorNode::
-get_linear_velocity() const {
-  nassertr(nActor != NULL, *((LVecBase3f *)NULL));
-
-  return PhysxManager::nxVec3_to_lVecBase3(nActor->getLinearVelocity());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_local_point_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxActorNode::
-get_local_point_velocity(const LVecBase3f & point) const {
-  nassertr(nActor != NULL, *((LVecBase3f *)NULL));
-
-  return PhysxManager::nxVec3_to_lVecBase3(nActor->getLocalPointVelocity(PhysxManager::lVecBase3_to_nxVec3(point)));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_mass
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-float PhysxActorNode::
-get_mass() const {
-  nassertr(nActor != NULL, -1.0f);
-
-  return nActor->getMass();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_mass_space_inertia_tensor
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxActorNode::
-get_mass_space_inertia_tensor() const {
-  nassertr(nActor != NULL, *((LVecBase3f *)NULL));
-
-  return PhysxManager::nxVec3_to_lVecBase3(nActor->getMassSpaceInertiaTensor());
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_max_angular_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-float PhysxActorNode::
-get_max_angular_velocity() const {
-  nassertr(nActor != NULL, -1.0f);
-
-  return nActor->getMaxAngularVelocity();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_nb_shapes
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-unsigned int PhysxActorNode::
-get_nb_shapes() const {
-  nassertr(nActor != NULL, -1);
-
-  return nActor->getNbShapes();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_point_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxActorNode::
-get_point_velocity(const LVecBase3f & point) const {
-  nassertr(nActor != NULL, *((LVecBase3f *)NULL));
-
-  return PhysxManager::nxVec3_to_lVecBase3(nActor->getPointVelocity(PhysxManager::lVecBase3_to_nxVec3(point)));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_scene
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-PhysxScene & PhysxActorNode::
-get_scene() const {
-  nassertr(nActor != NULL, *((PhysxScene *)NULL));
-
-  return *((PhysxScene *)(nActor->getScene().userData));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_sleep_angular_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-float PhysxActorNode::
-get_sleep_angular_velocity() const {
-  nassertr(nActor != NULL, -1.0f);
-
-  return nActor->getSleepAngularVelocity();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_sleep_energy_threshold
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-float PhysxActorNode::
-get_sleep_energy_threshold() const {
-  nassertr(nActor != NULL, -1.0f);
-
-  return nActor->getSleepEnergyThreshold();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_sleep_linear_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-float PhysxActorNode::
-get_sleep_linear_velocity() const {
-  nassertr(nActor != NULL, -1.0f);
-
-  return nActor->getSleepLinearVelocity();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_solver_iteration_count
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-unsigned int PhysxActorNode::
-get_solver_iteration_count() const {
-  nassertr(nActor != NULL, -1);
-
-  return nActor->getSolverIterationCount();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : is_dynamic
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-bool PhysxActorNode::
-is_dynamic() const {
-  nassertr(nActor != NULL, false);
-
-  return nActor->isDynamic();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : is_group_sleeping
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-bool PhysxActorNode::
-is_group_sleeping() const {
-  nassertr(nActor != NULL, false);
-
-  return nActor->isGroupSleeping();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : is_sleeping
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-bool PhysxActorNode::
-is_sleeping() const {
-  nassertr(nActor != NULL, false);
-
-  return nActor->isSleeping();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : move_global_orientation
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-move_global_orientation(const LMatrix3f & mat) {
-  nassertv(nActor != NULL);
-
-  nActor->moveGlobalOrientation(PhysxManager::lMatrix3_to_nxMat33(mat));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : move_global_orientation_quat
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-move_global_orientation_quat(const LQuaternionf & quat) {
-  nassertv(nActor != NULL);
-
-  nActor->moveGlobalOrientationQuat(PhysxManager::lQuaternion_to_nxQuat(quat));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : move_global_pose
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-move_global_pose(const LMatrix4f & mat) {
-  nassertv(nActor != NULL);
-
-  nActor->moveGlobalPose(PhysxManager::lMatrix4_to_nxMat34(mat));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : move_global_position
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-move_global_position(const LVecBase3f & vec) {
-  nassertv(nActor != NULL);
-
-  nActor->moveGlobalPosition(PhysxManager::lVecBase3_to_nxVec3(vec));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : put_to_sleep
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-put_to_sleep() {
-  nassertv(nActor != NULL);
-
-  nActor->putToSleep();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : raise_actor_flag
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-raise_actor_flag(PhysxActorFlag actor_flag) {
-  nassertv(nActor != NULL);
-
-  nActor->raiseActorFlag((NxActorFlag)actor_flag);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : raise_body_flag
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-raise_body_flag(PhysxBodyFlag body_flag) {
-  nassertv(nActor != NULL);
-
-  nActor->raiseBodyFlag((NxBodyFlag)body_flag);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : read_actor_flag
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-bool PhysxActorNode::
-read_actor_flag(PhysxActorFlag actor_flag) const {
-  nassertr(nActor != NULL, false);
-
-  return nActor->readActorFlag((NxActorFlag)actor_flag);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : read_body_flag
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-bool PhysxActorNode::
-read_body_flag(PhysxBodyFlag body_flag) const {
-  nassertr(nActor != NULL, false);
-
-  return nActor->readBodyFlag((NxBodyFlag)body_flag);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : recompute_adaptive_force_counters
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-recompute_adaptive_force_counters() {
-  nassertv(nActor != NULL);
-
-  nActor->recomputeAdaptiveForceCounters();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : release_shape
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-release_shape(PhysxShape & shape) {
-  nassertv(nActor != NULL);
-
-  nActor->releaseShape(*(shape.nShape));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : reset_user_actor_pair_filtering
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-reset_user_actor_pair_filtering() {
-  nassertv(nActor != NULL);
-
-  nActor->resetUserActorPairFiltering();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : save_body_to_desc
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-bool PhysxActorNode::
-save_body_to_desc(PhysxBodyDesc & body_desc) {
-  nassertr(nActor != NULL, false);
-
-  return nActor->saveBodyToDesc(body_desc.nBodyDesc);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_angular_damping
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_angular_damping(float ang_damp) {
-  nassertv(nActor != NULL);
-
-  nActor->setAngularDamping(ang_damp);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_angular_momentum
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_angular_momentum(const LVecBase3f & ang_moment) {
-  nassertv(nActor != NULL);
-
-  nActor->setAngularMomentum(PhysxManager::lVecBase3_to_nxVec3(ang_moment));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_angular_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_angular_velocity(const LVecBase3f & ang_vel) {
-  nassertv(nActor != NULL);
-
-  nActor->setAngularVelocity(PhysxManager::lVecBase3_to_nxVec3(ang_vel));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_c_mass_global_orientation
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_c_mass_global_orientation(const LMatrix3f & mat) {
-  nassertv(nActor != NULL);
-
-  nActor->setCMassGlobalOrientation(PhysxManager::lMatrix3_to_nxMat33(mat));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_c_mass_global_pose
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_c_mass_global_pose(const LMatrix4f & mat) {
-  nassertv(nActor != NULL);
-
-  nActor->setCMassGlobalPose(PhysxManager::lMatrix4_to_nxMat34(mat));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_c_mass_global_position
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_c_mass_global_position(const LVecBase3f & vec) {
-  nassertv(nActor != NULL);
-
-  nActor->setCMassGlobalPosition(PhysxManager::lVecBase3_to_nxVec3(vec));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_c_mass_offset_global_orientation
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_c_mass_offset_global_orientation(const LMatrix3f & mat) {
-  nassertv(nActor != NULL);
-
-  nActor->setCMassOffsetGlobalOrientation(PhysxManager::lMatrix3_to_nxMat33(mat));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_c_mass_offset_global_pose
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_c_mass_offset_global_pose(const LMatrix4f & mat) {
-  nassertv(nActor != NULL);
-
-  nActor->setCMassOffsetGlobalPose(PhysxManager::lMatrix4_to_nxMat34(mat));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_c_mass_offset_global_position
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_c_mass_offset_global_position(const LVecBase3f & vec) {
-  nassertv(nActor != NULL);
-
-  nActor->setCMassOffsetGlobalPosition(PhysxManager::lVecBase3_to_nxVec3(vec));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_c_mass_offset_local_orientation
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_c_mass_offset_local_orientation(const LMatrix3f & mat) {
-  nassertv(nActor != NULL);
-
-  nActor->setCMassOffsetLocalOrientation(PhysxManager::lMatrix3_to_nxMat33(mat));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_c_mass_offset_local_pose
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_c_mass_offset_local_pose(const LMatrix4f & mat) {
-  nassertv(nActor != NULL);
-
-  nActor->setCMassOffsetLocalPose(PhysxManager::lMatrix4_to_nxMat34(mat));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_c_mass_offset_local_position
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_c_mass_offset_local_position(const LVecBase3f & vec) {
-  nassertv(nActor != NULL);
-
-  nActor->setCMassOffsetLocalPosition(PhysxManager::lVecBase3_to_nxVec3(vec));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_ccd_motion_threshold
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_ccd_motion_threshold(float thresh) {
-  nassertv(nActor != NULL);
-
-  nActor->setCCDMotionThreshold(thresh);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_global_orientation
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_global_orientation(const LMatrix3f & mat) {
-  nassertv(nActor != NULL);
-
-  nActor->setGlobalOrientation(PhysxManager::lMatrix3_to_nxMat33(mat));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_global_orientation_quat
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_global_orientation_quat(const LQuaternionf & mat) {
-  nassertv(nActor != NULL);
-
-  nActor->setGlobalOrientationQuat(PhysxManager::lQuaternion_to_nxQuat(mat));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_global_pose
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_global_pose(const LMatrix4f & mat) {
-  nassertv(nActor != NULL);
-
-  nActor->setGlobalPose(PhysxManager::lMatrix4_to_nxMat34(mat));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_global_position
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_global_position(const LVecBase3f & vec) {
-  nassertv(nActor != NULL);
-
-  nActor->setGlobalPosition(PhysxManager::lVecBase3_to_nxVec3(vec));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_group
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_group(unsigned short actor_group) {
-  nassertv(nActor != NULL);
-
-  nActor->setGroup(actor_group);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_linear_damping
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_linear_damping(float lin_damp) {
-  nassertv(nActor != NULL);
-
-  nActor->setLinearDamping(lin_damp);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_linear_momentum
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_linear_momentum(const LVecBase3f & lin_moment) {
-  nassertv(nActor != NULL);
-
-  nActor->setLinearMomentum(PhysxManager::lVecBase3_to_nxVec3(lin_moment));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_linear_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_linear_velocity(const LVecBase3f & lin_vel) {
-  nassertv(nActor != NULL);
-
-  nActor->setLinearVelocity(PhysxManager::lVecBase3_to_nxVec3(lin_vel));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_mass
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_mass(float mass) {
-  nassertv(nActor != NULL);
-
-  nActor->setMass(mass);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_mass_space_inertia_tensor
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_mass_space_inertia_tensor(const LVecBase3f & m) {
-  nassertv(nActor != NULL);
-
-  nActor->setMassSpaceInertiaTensor(PhysxManager::lVecBase3_to_nxVec3(m));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_max_angular_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_max_angular_velocity(float max_ang_vel) {
-  nassertv(nActor != NULL);
-
-  nActor->setMaxAngularVelocity(max_ang_vel);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_sleep_angular_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_sleep_angular_velocity(float threshold) {
-  nassertv(nActor != NULL);
-
-  nActor->setSleepAngularVelocity(threshold);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_sleep_energy_threshold
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_sleep_energy_threshold(float threshold) {
-  nassertv(nActor != NULL);
-
-  nActor->setSleepEnergyThreshold(threshold);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_sleep_linear_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_sleep_linear_velocity(float threshold) {
-  nassertv(nActor != NULL);
-
-  nActor->setSleepLinearVelocity(threshold);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_solver_iteration_count
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-set_solver_iteration_count(unsigned int iter_count) {
-  nassertv(nActor != NULL);
-
-  nActor->setSolverIterationCount(iter_count);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : update_mass_from_shapes
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-update_mass_from_shapes(float density, float total_mass) {
-  nassertv(nActor != NULL);
-
-  nActor->updateMassFromShapes(density, total_mass);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : wake_up
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-wake_up(float wake_counter_value) {
-  nassertv(nActor != NULL);
-
-  nActor->wakeUp(wake_counter_value);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : transform_changed
-//       Access : private, virtual
-//  Description : node hook.  This function handles outside
-//                (non-physics) actions on the PhysxActorNode
-//                and updates the internal representation of the node.
-//                i.e. copy from PandaNode to PhysxActor
-////////////////////////////////////////////////////////////////////
-void PhysxActorNode::
-transform_changed() {
-  nassertv(nActor != NULL);
-
-  PandaNode::transform_changed();
-
-  // _disable_transform_changed is used to prevent a recursive loop between
-  // transform_changed and update_transform.
-  if(_disable_transform_changed) {
-    return;
-  }
-
-  if(nActor->isDynamic()) {
-    CPT(TransformState) transform = get_transform();
-    if(nActor->readBodyFlag(NX_BF_KINEMATIC)) {
-      // If the Actor is kinematic, use moveGlobalPose
-      nActor->moveGlobalPose(PhysxManager::lMatrix4_to_nxMat34(transform->get_mat()));
-    } else {
-      // If the Actor is just dynamic, use setGlobalPose
-      nActor->setGlobalPose(PhysxManager::lMatrix4_to_nxMat34(transform->get_mat()));
-    }
-  } else {
-    // If the Actor is static, don't allow the transform to be updated
-    physx_error("Error: cannot update transform of static PhysxActorNode " << get_name());
-  }
-}
-
-#endif // HAVE_PHYSX
-

+ 0 - 178
panda/src/physx/physxActorNode.h

@@ -1,178 +0,0 @@
-// Filename: physxActorNode.h
-// Created by:  pratt (Apr 7, 2006)
-//
-////////////////////////////////////////////////////////////////////
-//
-// 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 PHYSXACTORNODE_H
-#define PHYSXACTORNODE_H
-
-#ifdef HAVE_PHYSX
-
-#include "pandabase.h"
-#include "pandaNode.h"
-
-#include "physx_enumerations.h"
-#include "physxManager.h"
-#include "luse.h"
-
-class PhysxBodyDesc;
-class PhysxScene;
-class PhysxShape;
-class PhysxShapeDesc;
-
-#include "NxPhysics.h"
-
-////////////////////////////////////////////////////////////////////
-//       Class : PhysxActorNode
-// Description :
-////////////////////////////////////////////////////////////////////
-class EXPCL_PANDAPHYSX PhysxActorNode : public PandaNode {
-PUBLISHED:
-  PhysxActorNode(const string &name);
-
-  INLINE void update_transform();
-  INLINE void get_global_pose_optimized(LMatrix4f *result);
-
-  unsigned int get_num_shapes();
-  PhysxShape *get_shape(unsigned int i);
-  INLINE bool is_valid();
-
-  void add_force(const LVecBase3f & force, PhysxForceMode mode, bool wakeup=true);
-  void add_force_at_local_pos(const LVecBase3f & force, const LVecBase3f & pos, PhysxForceMode mode, bool wakeup=true);
-  void add_force_at_pos(const LVecBase3f & force, const LVecBase3f & pos, PhysxForceMode mode, bool wakeup=true);
-  void add_local_force(const LVecBase3f & force, PhysxForceMode mode, bool wakeup=true);
-  void add_local_force_at_local_pos(const LVecBase3f & force, const LVecBase3f & pos, PhysxForceMode mode, bool wakeup=true);
-  void add_local_force_at_pos(const LVecBase3f & force, const LVecBase3f & pos, PhysxForceMode mode, bool wakeup=true);
-  void add_local_torque(const LVecBase3f & torque, PhysxForceMode mode, bool wakeup=true);
-  void add_torque(const LVecBase3f & torque, PhysxForceMode mode, bool wakeup=true);
-  void clear_actor_flag(PhysxActorFlag actor_flag);
-  void clear_body_flag(PhysxBodyFlag body_flag);
-  float compute_kinetic_energy() const;
-  PhysxShape * create_shape(const PhysxShapeDesc & desc);
-  float get_angular_damping() const;
-  LVecBase3f get_angular_momentum() const;
-  LVecBase3f get_angular_velocity() const;
-  LMatrix3f get_c_mass_global_orientation() const;
-  LMatrix4f get_c_mass_global_pose() const;
-  LVecBase3f get_c_mass_global_position() const;
-  LMatrix3f get_c_mass_local_orientation() const;
-  LMatrix4f get_c_mass_local_pose() const;
-  LVecBase3f get_c_mass_local_position() const;
-  float get_ccd_motion_threshold() const;
-  LMatrix3f get_global_inertia_tensor() const;
-  LMatrix3f get_global_inertia_tensor_inverse() const;
-  LMatrix3f get_global_orientation() const;
-  LQuaternionf get_global_orientation_quat() const;
-  INLINE LMatrix4f get_global_pose() const;
-  LVecBase3f get_global_position() const;
-  unsigned short get_group() const;
-  float get_linear_damping() const;
-  LVecBase3f get_linear_momentum() const;
-  LVecBase3f get_linear_velocity() const;
-  LVecBase3f get_local_point_velocity(const LVecBase3f & point) const;
-  float get_mass() const;
-  LVecBase3f get_mass_space_inertia_tensor() const;
-  float get_max_angular_velocity() const;
-  unsigned int get_nb_shapes() const;
-  LVecBase3f get_point_velocity(const LVecBase3f & point) const;
-  PhysxScene & get_scene() const;
-  float get_sleep_angular_velocity() const;
-  float get_sleep_energy_threshold() const;
-  float get_sleep_linear_velocity() const;
-  unsigned int get_solver_iteration_count() const;
-  bool is_dynamic() const;
-  bool is_group_sleeping() const;
-  bool is_sleeping() const;
-  void move_global_orientation(const LMatrix3f & mat);
-  void move_global_orientation_quat(const LQuaternionf & quat);
-  void move_global_pose(const LMatrix4f & mat);
-  void move_global_position(const LVecBase3f & vec);
-  void put_to_sleep();
-  void raise_actor_flag(PhysxActorFlag actor_flag);
-  void raise_body_flag(PhysxBodyFlag body_flag);
-  bool read_actor_flag(PhysxActorFlag actor_flag) const;
-  bool read_body_flag(PhysxBodyFlag body_flag) const;
-  void recompute_adaptive_force_counters();
-  void release_shape(PhysxShape & shape);
-  void reset_user_actor_pair_filtering();
-  bool save_body_to_desc(PhysxBodyDesc & body_desc);
-  void set_angular_damping(float ang_damp);
-  void set_angular_momentum(const LVecBase3f & ang_moment);
-  void set_angular_velocity(const LVecBase3f & ang_vel);
-  void set_c_mass_global_orientation(const LMatrix3f & mat);
-  void set_c_mass_global_pose(const LMatrix4f & mat);
-  void set_c_mass_global_position(const LVecBase3f & vec);
-  void set_c_mass_offset_global_orientation(const LMatrix3f & mat);
-  void set_c_mass_offset_global_pose(const LMatrix4f & mat);
-  void set_c_mass_offset_global_position(const LVecBase3f & vec);
-  void set_c_mass_offset_local_orientation(const LMatrix3f & mat);
-  void set_c_mass_offset_local_pose(const LMatrix4f & mat);
-  void set_c_mass_offset_local_position(const LVecBase3f & vec);
-  void set_ccd_motion_threshold(float thresh);
-  void set_global_orientation(const LMatrix3f & mat);
-  void set_global_orientation_quat(const LQuaternionf & mat);
-  void set_global_pose(const LMatrix4f & mat);
-  void set_global_position(const LVecBase3f & vec);
-  void set_group(unsigned short actor_group);
-  void set_linear_damping(float lin_damp);
-  void set_linear_momentum(const LVecBase3f & lin_moment);
-  void set_linear_velocity(const LVecBase3f & lin_vel);
-  void set_mass(float mass);
-  void set_mass_space_inertia_tensor(const LVecBase3f & m);
-  void set_max_angular_velocity(float max_ang_vel);
-  void set_sleep_angular_velocity(float threshold);
-  void set_sleep_energy_threshold(float threshold);
-  void set_sleep_linear_velocity(float threshold);
-  void set_solver_iteration_count(unsigned int iter_count);
-  void update_mass_from_shapes(float density, float total_mass);
-  void wake_up(float wake_counter_value);
-
-
-public:
-  NxActor *nActor;
-
-  bool safe_to_flatten() const {
-    return false;
-  }
-
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    PandaNode::init_type();
-    register_type(_type_handle, "PhysxActorNode", PandaNode::get_class_type());
-  }
-  virtual TypeHandle get_type() const {
-    return get_class_type();
-  }
-  virtual TypeHandle force_init_type() {
-    init_type();
-    return get_class_type();
-  }
-
-private:
-  virtual void transform_changed();
-  bool _disable_transform_changed;
-
-  // These variables are used by update_transform and
-  // get_global_pose_optimized for optimization purposes.
-  LMatrix4f _tempMat4;
-  float _tempCells[16];
-
-  static TypeHandle _type_handle;
-};
-
-#include "physxActorNode.I"
-
-#endif // HAVE_PHYSX
-
-#endif // PHYSXACTORNODE_H

+ 22 - 238
panda/src/physx/physxBodyDesc.I

@@ -1,5 +1,5 @@
 // Filename: physxBodyDesc.I
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (05Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,263 +12,47 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-////////////////////////////////////////////////////////////////////
-//     Function : is_valid
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE bool PhysxBodyDesc::
-is_valid() const {
-  return nBodyDesc.isValid();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_to_default
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBodyDesc::
-set_to_default() {
-  nBodyDesc.setToDefault();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_angular_damping
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE float PhysxBodyDesc::
-get_angular_damping() const {
-  return nBodyDesc.angularDamping;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_ccd_motion_threshold
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE float PhysxBodyDesc::
-get_ccd_motion_threshold() const {
-  return nBodyDesc.CCDMotionThreshold;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_flags
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE unsigned int PhysxBodyDesc::
-get_flags() const {
-  return nBodyDesc.flags;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_linear_damping
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE float PhysxBodyDesc::
-get_linear_damping() const {
-  return nBodyDesc.linearDamping;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_mass
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE float PhysxBodyDesc::
-get_mass() const {
-  return nBodyDesc.mass;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_max_angular_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE float PhysxBodyDesc::
-get_max_angular_velocity() const {
-  return nBodyDesc.maxAngularVelocity;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_sleep_angular_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE float PhysxBodyDesc::
-get_sleep_angular_velocity() const {
-  return nBodyDesc.sleepAngularVelocity;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_sleep_damping
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE float PhysxBodyDesc::
-get_sleep_damping() const {
-  return nBodyDesc.sleepDamping;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_sleep_energy_threshold
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE float PhysxBodyDesc::
-get_sleep_energy_threshold() const {
-  return nBodyDesc.sleepEnergyThreshold;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_sleep_linear_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE float PhysxBodyDesc::
-get_sleep_linear_velocity() const {
-  return nBodyDesc.sleepLinearVelocity;
-}
 
-////////////////////////////////////////////////////////////////////
-//     Function : get_solver_iteration_count
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE unsigned int PhysxBodyDesc::
-get_solver_iteration_count() const {
-  return nBodyDesc.solverIterationCount;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_wake_up_counter
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE float PhysxBodyDesc::
-get_wake_up_counter() const {
-  return nBodyDesc.wakeUpCounter;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_angular_damping
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBodyDesc::
-set_angular_damping(float value) {
-  nBodyDesc.angularDamping = value;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_ccd_motion_threshold
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBodyDesc::
-set_ccd_motion_threshold(float value) {
-  nBodyDesc.CCDMotionThreshold = value;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_flags
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBodyDesc::
-set_flags(unsigned int value) {
-  nBodyDesc.flags = value;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_linear_damping
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBodyDesc::
-set_linear_damping(float value) {
-  nBodyDesc.linearDamping = value;
-}
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_mass
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::Constructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE void PhysxBodyDesc::
-set_mass(float value) {
-  nBodyDesc.mass = value;
-}
+INLINE PhysxBodyDesc::
+PhysxBodyDesc() {
 
-////////////////////////////////////////////////////////////////////
-//     Function : set_max_angular_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBodyDesc::
-set_max_angular_velocity(float value) {
-  nBodyDesc.maxAngularVelocity = value;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_sleep_angular_velocity
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::Destructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE void PhysxBodyDesc::
-set_sleep_angular_velocity(float value) {
-  nBodyDesc.sleepAngularVelocity = value;
-}
+INLINE PhysxBodyDesc::
+~PhysxBodyDesc() {
 
-////////////////////////////////////////////////////////////////////
-//     Function : set_sleep_damping
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBodyDesc::
-set_sleep_damping(float value) {
-  nBodyDesc.sleepDamping = value;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_sleep_energy_threshold
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::set_to_default
+//       Access: Published
+//  Description: (re)sets the structure to the default.
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysxBodyDesc::
-set_sleep_energy_threshold(float value) {
-  nBodyDesc.sleepEnergyThreshold = value;
-}
+set_to_default() {
 
-////////////////////////////////////////////////////////////////////
-//     Function : set_sleep_linear_velocity
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBodyDesc::
-set_sleep_linear_velocity(float value) {
-  nBodyDesc.sleepLinearVelocity = value;
+  _desc.setToDefault();
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_solver_iteration_count
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::is_valid
+//       Access: Published
+//  Description: Returns true if the descriptor is valid.
 ////////////////////////////////////////////////////////////////////
-INLINE void PhysxBodyDesc::
-set_solver_iteration_count(unsigned int value) {
-  nBodyDesc.solverIterationCount = value;
-}
+INLINE bool PhysxBodyDesc::
+is_valid() const {
 
-////////////////////////////////////////////////////////////////////
-//     Function : set_wake_up_counter
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBodyDesc::
-set_wake_up_counter(float value) {
-  nBodyDesc.wakeUpCounter = value;
+  return _desc.isValid();
 }
 

+ 355 - 51
panda/src/physx/physxBodyDesc.cxx

@@ -1,5 +1,5 @@
 // Filename: physxBodyDesc.cxx
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (05Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,102 +12,406 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifdef HAVE_PHYSX
-
 #include "physxBodyDesc.h"
 
-#include "luse.h"
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_mass
+//       Access: Published
+//  Description: Set the mass of body. 
+////////////////////////////////////////////////////////////////////
+void PhysxBodyDesc::
+set_mass(float mass) {
 
+  _desc.mass = mass;
+}
 
 ////////////////////////////////////////////////////////////////////
-//     Function : PhysxBodyDesc
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::get_mass
+//       Access: Published
+//  Description: Get the mass of body. 
 ////////////////////////////////////////////////////////////////////
-PhysxBodyDesc::
-PhysxBodyDesc() {
+float PhysxBodyDesc::
+get_mass() const {
 
+  return _desc.mass;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_angular_velocity
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::set_linear_damping
+//       Access: Published
+//  Description: Set the linear damping applied to the body.
 ////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxBodyDesc::
-get_angular_velocity() const {
-  return PhysxManager::nxVec3_to_lVecBase3(nBodyDesc.angularVelocity);
+void PhysxBodyDesc::
+set_linear_damping(float damping) {
+
+  _desc.linearDamping = damping;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::get_linear_damping
+//       Access: Published
+//  Description: Get the linear damping applied to the body.
+////////////////////////////////////////////////////////////////////
+float PhysxBodyDesc::
+get_linear_damping() const {
+
+  return _desc.linearDamping;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_angular_damping
+//       Access: Published
+//  Description: Set the angular damping applied to the body.
+////////////////////////////////////////////////////////////////////
+void PhysxBodyDesc::
+set_angular_damping(float damping) {
+
+  _desc.angularDamping = damping;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_linear_velocity
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::get_angular_damping
+//       Access: Published
+//  Description: Get the angular damping applied to the body.
 ////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxBodyDesc::
+float PhysxBodyDesc::
+get_angular_damping() const {
+
+  return _desc.angularDamping;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_linear_velocity
+//       Access: Published
+//  Description: Set the linear Velocity of the body.
+////////////////////////////////////////////////////////////////////
+void PhysxBodyDesc::
+set_linear_velocity(const LVector3f &velocity) {
+
+  _desc.linearVelocity = PhysxManager::vec3_to_nxVec3(velocity);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::get_linear_velocity
+//       Access: Published
+//  Description: Get the linear Velocity of the body.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxBodyDesc::
 get_linear_velocity() const {
-  return PhysxManager::nxVec3_to_lVecBase3(nBodyDesc.linearVelocity);
+
+  return PhysxManager::nxVec3_to_vec3(_desc.linearVelocity);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_angular_velocity
+//       Access: Published
+//  Description: Set the angular velocity of the body.
+////////////////////////////////////////////////////////////////////
+void PhysxBodyDesc::
+set_angular_velocity(const LVector3f &velocity) {
+
+  _desc.angularVelocity = PhysxManager::vec3_to_nxVec3(velocity);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::get_angular_velocity
+//       Access: Published
+//  Description: Get the angular velocity of the body.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxBodyDesc::
+get_angular_velocity() const {
+
+  return PhysxManager::nxVec3_to_vec3(_desc.angularVelocity);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_max_angular_velocity
+//       Access: Published
+//  Description: Set the maximum allowed angular velocity for this
+//               body.
+////////////////////////////////////////////////////////////////////
+void PhysxBodyDesc::
+set_max_angular_velocity(float maximum) {
+
+  _desc.maxAngularVelocity = maximum;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::get_max_angular_velocity
+//       Access: Published
+//  Description: Get the maximum allowed angular velocity for this
+//               body.
+////////////////////////////////////////////////////////////////////
+float PhysxBodyDesc::
+get_max_angular_velocity() const {
+
+  return _desc.maxAngularVelocity;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_sleep_linear_velocity
+//       Access: Published
+//  Description: Set the maximum linear velocity at which the body
+//               can go to sleep.
+////////////////////////////////////////////////////////////////////
+void PhysxBodyDesc::
+set_sleep_linear_velocity(float velocity) {
+
+  _desc.sleepLinearVelocity = velocity;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::get_sleep_linear_velocity
+//       Access: Published
+//  Description: Get the maximum linear velocity at which the body
+//               can go to sleep.
+////////////////////////////////////////////////////////////////////
+float PhysxBodyDesc::
+get_sleep_linear_velocity() const {
+
+  return _desc.sleepLinearVelocity;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_sleep_angular_velocity
+//       Access: Published
+//  Description: Set the maximum angular velocity at which body
+//               can go to sleep.
+////////////////////////////////////////////////////////////////////
+void PhysxBodyDesc::
+set_sleep_angular_velocity(float velocity) {
+
+  _desc.sleepAngularVelocity = velocity;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::get_sleep_angular_velocity
+//       Access: Published
+//  Description: Get the maximum angular velocity at which body
+//               can go to sleep.
+////////////////////////////////////////////////////////////////////
+float PhysxBodyDesc::
+get_sleep_angular_velocity() const {
+
+  return _desc.sleepAngularVelocity;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_solver_iteration_count
+//       Access: Published
+//  Description: Set the number of solver iterations performed
+//               when processing joint/contacts connected to this
+//               body.
+////////////////////////////////////////////////////////////////////
+void PhysxBodyDesc::
+set_solver_iteration_count(unsigned int count) {
+
+  _desc.solverIterationCount = count;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_mass_local_pose
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::get_solver_iteration_count
+//       Access: Published
+//  Description: Get the number of solver iterations performed
+//               when processing joint/contacts connected to this
+//               body.
+////////////////////////////////////////////////////////////////////
+unsigned int PhysxBodyDesc::
+get_solver_iteration_count() const {
+
+  return _desc.solverIterationCount;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_sleep_energy_threshold
+//       Access: Published
+//  Description: Set the threshold for the energy-based sleeping
+//               algorithm. Only used when the BF_energy_sleep_test
+//               flag is set.
+////////////////////////////////////////////////////////////////////
+void PhysxBodyDesc::
+set_sleep_energy_threshold(float threshold) {
+
+  _desc.sleepEnergyThreshold = threshold;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::get_sleep_energy_threshold
+//       Access: Published
+//  Description: Get the threshold for the energy-based sleeping
+//               algorithm. Only used when the BF_energy_sleep_test
+//               flag is set.
+////////////////////////////////////////////////////////////////////
+float PhysxBodyDesc::
+get_sleep_energy_threshold() const {
+
+  return _desc.sleepEnergyThreshold;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_sleep_damping
+//       Access: Published
+//  Description: Set the damping factor for bodies that are about
+//               to sleep.
+////////////////////////////////////////////////////////////////////
+void PhysxBodyDesc::
+set_sleep_damping(float damping) {
+
+  _desc.sleepDamping = damping;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::get_sleep_damping
+//       Access: Published
+//  Description: Get the damping factor for bodies that are about
+//               to sleep.
+////////////////////////////////////////////////////////////////////
+float PhysxBodyDesc::
+get_sleep_damping() const {
+
+  return _desc.sleepDamping;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_mass_local_mat
+//       Access: Published
+//  Description: Set the position and orientation of the center
+//               of mass.
+////////////////////////////////////////////////////////////////////
+void PhysxBodyDesc::
+set_mass_local_mat(const LMatrix4f mat) {
+
+  _desc.massLocalPose = PhysxManager::mat4_to_nxMat34(mat);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::get_mass_local_mat
+//       Access: Published
+//  Description: Get the position and orientation of the center
+//               of mass.
 ////////////////////////////////////////////////////////////////////
 LMatrix4f PhysxBodyDesc::
-get_mass_local_pose() const {
-  return PhysxManager::nxMat34_to_lMatrix4(nBodyDesc.massLocalPose);
+get_mass_local_mat() const {
+
+  return PhysxManager::nxMat34_to_mat4(_desc.massLocalPose);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_mass_space_inertia
+//       Access: Published
+//  Description: Set the diagonal mass space inertia tensor in
+//               bodies mass frame.
+////////////////////////////////////////////////////////////////////
+void PhysxBodyDesc::
+set_mass_space_inertia(const LVector3f inertia) {
+
+  _desc.massSpaceInertia = PhysxManager::vec3_to_nxVec3(inertia);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_mass_space_inertia
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::get_mass_space_inertia
+//       Access: Published
+//  Description: Get the diagonal mass space inertia tensor in
+//               bodies mass frame.
 ////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxBodyDesc::
+LVector3f PhysxBodyDesc::
 get_mass_space_inertia() const {
-  return PhysxManager::nxVec3_to_lVecBase3(nBodyDesc.massSpaceInertia);
+
+  return PhysxManager::nxVec3_to_vec3(_desc.massSpaceInertia);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_angular_velocity
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::set_flag
+//       Access: Published
+//  Description: Raise or lower individual body flags.
 ////////////////////////////////////////////////////////////////////
 void PhysxBodyDesc::
-set_angular_velocity(LVecBase3f value) {
-  nBodyDesc.angularVelocity = PhysxManager::lVecBase3_to_nxVec3(value);
+set_flag(const PhysxBodyFlag flag, bool value) {
+
+  if (value == true) {
+    _desc.flags |= flag;
+  }
+  else {
+    _desc.flags &= ~(flag);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::get_flag
+//       Access: Published
+//  Description: Returns the specified body flag.
+////////////////////////////////////////////////////////////////////
+bool PhysxBodyDesc::
+get_flag(const PhysxBodyFlag flag) const {
+
+  return (_desc.flags & flag) ? true : false;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_linear_velocity
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::set_ccd_motion_threshold
+//       Access: Published
+//  Description: When CCD is globally enabled, it is still not
+//               performed if the motion distance of all points on
+//               the body is below this threshold. 
 ////////////////////////////////////////////////////////////////////
 void PhysxBodyDesc::
-set_linear_velocity(LVecBase3f value) {
-  nBodyDesc.linearVelocity = PhysxManager::lVecBase3_to_nxVec3(value);
+set_ccd_motion_threshold(float threshold) {
+
+  _desc.CCDMotionThreshold = threshold;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_mass_local_pose
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::get_ccd_motion_threshold
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+float PhysxBodyDesc::
+get_ccd_motion_threshold() const {
+
+  return _desc.CCDMotionThreshold;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::set_wake_up_counter
+//       Access: Published
+//  Description: Set the body's initial wake up counter.
 ////////////////////////////////////////////////////////////////////
 void PhysxBodyDesc::
-set_mass_local_pose(LMatrix4f value) {
-  nBodyDesc.massLocalPose = PhysxManager::lMatrix4_to_nxMat34(value);
+set_wake_up_counter(float value) {
+
+  _desc.wakeUpCounter = value;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::get_wake_up_counter
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+float PhysxBodyDesc::
+get_wake_up_counter() const {
+
+  return _desc.wakeUpCounter;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_mass_space_inertia
-//       Access : Published
-//  Description :
+//     Function: PhysxBodyDesc::set_contact_report_threshold
+//       Access: Published
+//  Description: Set The force threshold for contact reports.
 ////////////////////////////////////////////////////////////////////
 void PhysxBodyDesc::
-set_mass_space_inertia(LVecBase3f value) {
-  nBodyDesc.massSpaceInertia = PhysxManager::lVecBase3_to_nxVec3(value);
+set_contact_report_threshold(float threshold) {
+
+  _desc.contactReportThreshold = threshold;
 }
 
-#endif // HAVE_PHYSX
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBodyDesc::get_contact_report_threshold
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+float PhysxBodyDesc::
+get_contact_report_threshold() const {
+
+  return _desc.contactReportThreshold;
+}
 

+ 47 - 45
panda/src/physx/physxBodyDesc.h

@@ -1,5 +1,5 @@
 // Filename: physxBodyDesc.h
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (05Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -15,67 +15,69 @@
 #ifndef PHYSXBODYDESC_H
 #define PHYSXBODYDESC_H
 
-#ifdef HAVE_PHYSX
-
 #include "pandabase.h"
+#include "lvector3.h"
+#include "lmatrix.h"
 
-#include "physx_enumerations.h"
-#include "physxManager.h"
-#include "luse.h"
+#include "physxEnums.h"
 
+#include "NoMinMax.h"
 #include "NxPhysics.h"
 
 ////////////////////////////////////////////////////////////////////
 //       Class : PhysxBodyDesc
-// Description :
+// Description : Descriptor for the optional rigid body dynamic
+//               state of PhysxActor.
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDAPHYSX PhysxBodyDesc {
+class EXPCL_PANDAPHYSX PhysxBodyDesc : public PhysxEnums {
+
 PUBLISHED:
-  PhysxBodyDesc();
+  INLINE PhysxBodyDesc();
+  INLINE ~PhysxBodyDesc();
 
-  INLINE bool is_valid() const;
   INLINE void set_to_default();
+  INLINE bool is_valid() const;
 
-  INLINE float get_angular_damping() const;
-  LVecBase3f get_angular_velocity() const;
-  INLINE float get_ccd_motion_threshold() const;
-  INLINE unsigned int get_flags() const;
-  INLINE float get_linear_damping() const;
-  LVecBase3f get_linear_velocity() const;
-  INLINE float get_mass() const;
-  LMatrix4f get_mass_local_pose() const;
-  LVecBase3f get_mass_space_inertia() const;
-  INLINE float get_max_angular_velocity() const;
-  INLINE float get_sleep_angular_velocity() const;
-  INLINE float get_sleep_damping() const;
-  INLINE float get_sleep_energy_threshold() const;
-  INLINE float get_sleep_linear_velocity() const;
-  INLINE unsigned int get_solver_iteration_count() const;
-  INLINE float get_wake_up_counter() const;
+  void set_mass(float mass);
+  void set_linear_damping(float damping);
+  void set_angular_damping(float damping);
+  void set_linear_velocity(const LVector3f &velocity);
+  void set_angular_velocity(const LVector3f &velocity);
+  void set_max_angular_velocity(float maximum);
+  void set_sleep_linear_velocity(float velocity);
+  void set_sleep_angular_velocity(float velocity);
+  void set_solver_iteration_count(unsigned int count);
+  void set_sleep_energy_threshold(float threshold);
+  void set_sleep_damping(float damping);
+  void set_mass_local_mat(const LMatrix4f mat);
+  void set_mass_space_inertia(const LVector3f inertia);
+  void set_flag(PhysxBodyFlag flag, bool value);
+  void set_ccd_motion_threshold(float threshold);
+  void set_wake_up_counter(float value);
+  void set_contact_report_threshold(float threshold);
 
-  INLINE void set_angular_damping( float value );
-  void set_angular_velocity( LVecBase3f value );
-  INLINE void set_ccd_motion_threshold( float value );
-  INLINE void set_flags( unsigned int value );
-  INLINE void set_linear_damping( float value );
-  void set_linear_velocity( LVecBase3f value );
-  INLINE void set_mass( float value );
-  void set_mass_local_pose( LMatrix4f value );
-  void set_mass_space_inertia( LVecBase3f value );
-  INLINE void set_max_angular_velocity( float value );
-  INLINE void set_sleep_angular_velocity( float value );
-  INLINE void set_sleep_damping(float value);
-  INLINE void set_sleep_energy_threshold(float value);
-  INLINE void set_sleep_linear_velocity( float value );
-  INLINE void set_solver_iteration_count( unsigned int value );
-  INLINE void set_wake_up_counter( float value );
+  float get_mass() const;
+  float get_linear_damping() const;
+  float get_angular_damping() const;
+  LVector3f get_linear_velocity() const;
+  LVector3f get_angular_velocity() const;
+  float get_max_angular_velocity() const;
+  float get_sleep_linear_velocity() const;
+  float get_sleep_angular_velocity() const;
+  unsigned int get_solver_iteration_count() const;
+  float get_sleep_energy_threshold() const;
+  float get_sleep_damping() const;
+  LMatrix4f get_mass_local_mat() const;
+  LVector3f get_mass_space_inertia() const;
+  bool get_flag(PhysxBodyFlag flag) const;
+  float get_ccd_motion_threshold() const;
+  float get_wake_up_counter() const;
+  float get_contact_report_threshold() const;
 
 public:
-  NxBodyDesc nBodyDesc;
+  NxBodyDesc _desc;
 };
 
 #include "physxBodyDesc.I"
 
-#endif // HAVE_PHYSX
-
 #endif // PHYSXBODYDESC_H

+ 11 - 170
panda/src/physx/physxBounds3.I

@@ -1,5 +1,5 @@
 // Filename: physxBounds3.I
-// Created by:  pratt (Dec 12, 2007)
+// Created by:  enn0x (31Oct09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,183 +12,24 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-////////////////////////////////////////////////////////////////////
-//     Function : bounds_of_obb
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBounds3::
-bounds_of_obb(const LMatrix3f & orientation, const LVecBase3f & translation, const LVecBase3f & half_dims) {
-  nassertv(nBounds3 != NULL);
-
-  nBounds3->boundsOfOBB(PhysxManager::lMatrix3_to_nxMat33(orientation), PhysxManager::lVecBase3_to_nxVec3(translation), PhysxManager::lVecBase3_to_nxVec3(half_dims));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : combine
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBounds3::
-combine(const PhysxBounds3 & b2) {
-  nassertv(nBounds3 != NULL);
-
-  nBounds3->combine(*(b2.nBounds3));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : contain
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE bool PhysxBounds3::
-contain(const LVecBase3f & v) const {
-  nassertr(nBounds3 != NULL, false);
-
-  return nBounds3->contain(PhysxManager::lVecBase3_to_nxVec3(v));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : fatten
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBounds3::
-fatten(float distance) {
-  nassertv(nBounds3 != NULL);
-
-  nBounds3->fatten(distance);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_dimensions
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBounds3::
-get_dimensions(LVecBase3f & dims) const {
-  nassertv(nBounds3 != NULL);
-
-  nBounds3->getDimensions(PhysxManager::lVecBase3_to_nxVec3(dims));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : include
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBounds3::
-include(const LVecBase3f & v) {
-  nassertv(nBounds3 != NULL);
-
-  nBounds3->include(PhysxManager::lVecBase3_to_nxVec3(v));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : intersects
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE bool PhysxBounds3::
-intersects(const PhysxBounds3 & b) const {
-  nassertr(nBounds3 != NULL, false);
-
-  return nBounds3->intersects(*(b.nBounds3));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : intersects2d
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE bool PhysxBounds3::
-intersects2d(const PhysxBounds3 & b, unsigned axis_to_ignore) const {
-  nassertr(nBounds3 != NULL, false);
-
-  return nBounds3->intersects2D(*(b.nBounds3), axis_to_ignore);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : is_empty
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE bool PhysxBounds3::
-is_empty() const {
-  nassertr(nBounds3 != NULL, false);
-
-  return nBounds3->isEmpty();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : scale
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBounds3::
-scale(float scale) {
-  nassertv(nBounds3 != NULL);
-
-  nBounds3->scale(scale);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBounds3::
-set(const LVecBase3f & min, const LVecBase3f & max) {
-  nassertv(nBounds3 != NULL);
-
-  nBounds3->set(PhysxManager::lVecBase3_to_nxVec3(min), PhysxManager::lVecBase3_to_nxVec3(max));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_center_extents
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBounds3::
-set_center_extents(const LVecBase3f & c, const LVecBase3f & e) {
-  nassertv(nBounds3 != NULL);
-
-  nBounds3->setCenterExtents(PhysxManager::lVecBase3_to_nxVec3(c), PhysxManager::lVecBase3_to_nxVec3(e));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_empty
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxBounds3::
-set_empty() {
-  nassertv(nBounds3 != NULL);
-
-  nBounds3->setEmpty();
-}
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_infinite
-//       Access : Published
-//  Description :
+//     Function: PhysxBounds3::Constructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE void PhysxBounds3::
-set_infinite() {
-  nassertv(nBounds3 != NULL);
+INLINE PhysxBounds3::
+PhysxBounds3() {
 
-  nBounds3->setInfinite();
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : transform
-//       Access : Published
-//  Description :
+//     Function: PhysxBounds3::Destructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE void PhysxBounds3::
-transform(const LMatrix3f & orientation, const LVecBase3f & translation) {
-  nassertv(nBounds3 != NULL);
+INLINE PhysxBounds3::
+~PhysxBounds3() {
 
-  nBounds3->transform(PhysxManager::lMatrix3_to_nxMat33(orientation), PhysxManager::lVecBase3_to_nxVec3(translation));
 }
 

+ 230 - 43
panda/src/physx/physxBounds3.cxx

@@ -1,5 +1,5 @@
 // Filename: physxBounds3.cxx
-// Created by:  pratt (Dec 12, 2007)
+// Created by:  enn0x (31Oct09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,80 +12,267 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifdef HAVE_PHYSX
-
 #include "physxBounds3.h"
+#include "physxManager.h"
 
-#include "luse.h"
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::get_max
+//       Access: Published
+//  Description: Returns the minimum corner of the bounding box.
+////////////////////////////////////////////////////////////////////
+LPoint3f PhysxBounds3::
+get_max() const {
 
+  return PhysxManager::nxVec3_to_point3(_bounds.max);
+}
 
 ////////////////////////////////////////////////////////////////////
-//     Function : PhysxBounds3
-//       Access : Published
-//  Description :
+//     Function: PhysxBounds3::get_min
+//       Access: Published
+//  Description: Returns the maximum corner of the bounding box.
 ////////////////////////////////////////////////////////////////////
-PhysxBounds3::
-PhysxBounds3() {
-  nBounds3 = new NxBounds3();
+LPoint3f PhysxBounds3::
+get_min() const {
+
+  return PhysxManager::nxVec3_to_point3(_bounds.min);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : ~PhysxBounds3
-//       Access : Published
-//  Description :
+//     Function: PhysxBounds3::get_center
+//       Access: Published
+//  Description: Returns the center of the bounding box.
 ////////////////////////////////////////////////////////////////////
-PhysxBounds3::
-~PhysxBounds3() {
-  delete nBounds3;
+LPoint3f PhysxBounds3::
+get_center() const {
+
+  NxVec3 center;
+  _bounds.getCenter(center);
+  return PhysxManager::nxVec3_to_point3(center);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_max
-//       Access : Published
-//  Description :
+//     Function: PhysxBounds3::get_dimensions
+//       Access: Published
+//  Description: Returns the extents of the bounding box.
 ////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxBounds3::
-get_max() const {
-  nassertr(nBounds3 != NULL, *((LVecBase3f *)NULL));
+LVector3f PhysxBounds3::
+get_dimensions() const {
 
-  return PhysxManager::nxVec3_to_lVecBase3(nBounds3->max);
+  NxVec3 dims;
+  _bounds.getDimensions(dims);
+  return PhysxManager::nxVec3_to_vec3(dims);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_min
-//       Access : Published
-//  Description :
+//     Function: PhysxBounds3::set_max
+//       Access: Published
+//  Description: Sets the maximum corner of the bounding box.
 ////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxBounds3::
-get_min() const {
-  nassertr(nBounds3 != NULL, *((LVecBase3f *)NULL));
+void PhysxBounds3::
+set_max(LPoint3f value) {
+
+  nassertv(!value.is_nan());
+
+  _bounds.max = PhysxManager::point3_to_nxVec3(value);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::set_min
+//       Access: Published
+//  Description: Sets the minimum corner of the bounding box.
+////////////////////////////////////////////////////////////////////
+void PhysxBounds3::
+set_min(LPoint3f value) {
+
+  nassertv(!value.is_nan());
+
+  _bounds.min = PhysxManager::point3_to_nxVec3(value);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::bounds_of_obb
+//       Access: Published
+//  Description: Sets this to the AABB (axis ligned bounding box)
+//               of the OBB (oriented bounding box). The OBB is
+//               described by orientation, translation and half
+//               dimensions.
+////////////////////////////////////////////////////////////////////
+void PhysxBounds3::
+bounds_of_obb(const LMatrix3f &orientation, const LPoint3f &translation, const LVector3f &half_dims) {
+
+  nassertv(!orientation.is_nan());
+  nassertv(!translation.is_nan());
+  nassertv(!half_dims.is_nan());
 
-  return PhysxManager::nxVec3_to_lVecBase3(nBounds3->min);
+  _bounds.boundsOfOBB(PhysxManager::mat3_to_nxMat33(orientation),
+                      PhysxManager::point3_to_nxVec3(translation),
+                      PhysxManager::vec3_to_nxVec3(half_dims));
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_max
-//       Access : Published
-//  Description :
+//     Function: PhysxBounds3::combine
+//       Access: Published
+//  Description: Sets this to the union of this and b2. 
 ////////////////////////////////////////////////////////////////////
 void PhysxBounds3::
-set_max(LVecBase3f value) {
-  nassertv(nBounds3 != NULL);
+combine(const PhysxBounds3 &b2) {
+
+  _bounds.combine(b2._bounds);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::contain
+//       Access: Published
+//  Description: Returns TRUE if these bounds contain the point v.
+////////////////////////////////////////////////////////////////////
+bool PhysxBounds3::
+contain(const LPoint3f &p) const {
+
+  nassertr(!p.is_nan(), false);
 
-  nBounds3->max = PhysxManager::lVecBase3_to_nxVec3(value);
+  return _bounds.contain(PhysxManager::point3_to_nxVec3(p));
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_min
-//       Access : Published
-//  Description :
+//     Function: PhysxBounds3::fatten
+//       Access: Published
+//  Description: Fattens the AABB in all three dimensions by the
+//               given distance.
 ////////////////////////////////////////////////////////////////////
 void PhysxBounds3::
-set_min(LVecBase3f value) {
-  nassertv(nBounds3 != NULL);
+fatten(float distance) {
 
-  nBounds3->min = PhysxManager::lVecBase3_to_nxVec3(value);
+  _bounds.fatten(distance);
 }
 
-#endif // HAVE_PHYSX
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::include
+//       Access: Published
+//  Description: Expands the volume to include the point v.
+////////////////////////////////////////////////////////////////////
+void PhysxBounds3::
+include(const LPoint3f &p) {
+
+  nassertv(!p.is_nan());
+  _bounds.include(PhysxManager::point3_to_nxVec3(p));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::intersects
+//       Access: Published
+//  Description: Returns TRUE if the intersection of this and b is
+//               is not empty.
+////////////////////////////////////////////////////////////////////
+bool PhysxBounds3::
+intersects(const PhysxBounds3 &b) const {
+
+  return _bounds.intersects(b._bounds);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::intersects2d
+//       Access: Published
+//  Description: Indicates whether the intersection of this and b
+//               is empty or not in the plane orthogonal to the
+//               axis passed (X = 0, Y = 1 or Z = 2). 
+////////////////////////////////////////////////////////////////////
+bool PhysxBounds3::
+intersects2d(const PhysxBounds3 &b, unsigned axis_to_ignore) const {
+
+  return _bounds.intersects2D(b._bounds, axis_to_ignore);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::is_empty
+//       Access: Published
+//  Description: Returns TRUE if the bounding box is empty.
+////////////////////////////////////////////////////////////////////
+bool PhysxBounds3::
+is_empty() const {
+
+  return _bounds.isEmpty();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::scale
+//       Access: Published
+//  Description: Scales the AABB by the given factor.
+////////////////////////////////////////////////////////////////////
+void PhysxBounds3::
+scale(float scale) {
+
+  _bounds.scale(scale);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::set
+//       Access: Published
+//  Description: Setup this AABB from minimum corner and maximum
+//               corner.
+////////////////////////////////////////////////////////////////////
+void PhysxBounds3::
+set(const LPoint3f &min, const LPoint3f &max) {
+
+  nassertv(!min.is_nan());
+  nassertv(!max.is_nan());
+
+  _bounds.set(PhysxManager::point3_to_nxVec3(min),
+              PhysxManager::point3_to_nxVec3(max));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::set_center_extents
+//       Access: Published
+//  Description: Setup this AABB from center point and extents
+//               vector.
+////////////////////////////////////////////////////////////////////
+void PhysxBounds3::
+set_center_extents(const LPoint3f &center, const LVector3f &extents) {
+
+  nassertv(!center.is_nan());
+  nassertv(!extents.is_nan());
+
+  _bounds.setCenterExtents(PhysxManager::point3_to_nxVec3(center),
+                           PhysxManager::vec3_to_nxVec3(extents));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::set_empty
+//       Access: Published
+//  Description: Sets empty to TRUE.
+////////////////////////////////////////////////////////////////////
+void PhysxBounds3::
+set_empty() {
+
+  _bounds.setEmpty();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::set_infinite
+//       Access: Published
+//  Description: Sets infinite bounds.
+////////////////////////////////////////////////////////////////////
+void PhysxBounds3::
+set_infinite() {
+
+  _bounds.setInfinite();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBounds3::transform
+//       Access: Published
+//  Description: Transforms this volume as if it was an axis aligned
+//               bounding box, and then assigns the results' bounds
+//               to this. The orientation is applied first, then the
+//               translation.
+////////////////////////////////////////////////////////////////////
+void PhysxBounds3::
+transform(const LMatrix3f &orientation, const LPoint3f &translation) {
+
+  nassertv(!orientation.is_nan());
+  nassertv(!translation.is_nan());
+
+  _bounds.transform(PhysxManager::mat3_to_nxMat33(orientation),
+                    PhysxManager::point3_to_nxVec3(translation));
+}
 

+ 33 - 32
panda/src/physx/physxBounds3.h

@@ -1,5 +1,5 @@
 // Filename: physxBounds3.h
-// Created by:  pratt (Dec 12, 2007)
+// Created by:  enn0x (31Oct09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -15,53 +15,54 @@
 #ifndef PHYSXBOUNDS3_H
 #define PHYSXBOUNDS3_H
 
-#ifdef HAVE_PHYSX
-
 #include "pandabase.h"
-
-#include "physx_enumerations.h"
-#include "physxManager.h"
 #include "luse.h"
 
+#include "config_physx.h"
+
 #include "NxPhysics.h"
 
 ////////////////////////////////////////////////////////////////////
 //       Class : PhysxBounds3
-// Description :
+// Description : Represention of a axis aligned bounding box. 
+//               The box is stored as minimum and maximum extent
+//               corners. Alternate representation would be center
+//               and dimensions. May be empty or nonempty. If not
+//               empty, min <= max has to hold.
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDAPHYSX PhysxBounds3 {
+
 PUBLISHED:
-  PhysxBounds3();
-  ~PhysxBounds3();
+  INLINE PhysxBounds3();
+  INLINE ~PhysxBounds3();
 
-  INLINE void bounds_of_obb(const LMatrix3f & orientation, const LVecBase3f & translation, const LVecBase3f & half_dims);
-  INLINE void combine(const PhysxBounds3 & b2);
-  INLINE bool contain(const LVecBase3f & v) const;
-  INLINE void fatten(float distance);
-  INLINE void get_dimensions(LVecBase3f & dims) const;
-  INLINE void include(const LVecBase3f & v);
-  INLINE bool intersects(const PhysxBounds3 & b) const;
-  INLINE bool intersects2d(const PhysxBounds3 & b, unsigned axis_to_ignore) const;
-  INLINE bool is_empty() const;
-  INLINE void scale(float scale);
-  INLINE void set(const LVecBase3f & min, const LVecBase3f & max);
-  INLINE void set_center_extents(const LVecBase3f & c, const LVecBase3f & e);
-  INLINE void set_empty();
-  INLINE void set_infinite();
-  INLINE void transform(const LMatrix3f & orientation, const LVecBase3f & translation);
+  void bounds_of_obb(const LMatrix3f &orientation, const LPoint3f &translation, const LVector3f &half_dims);
+  void combine(const PhysxBounds3 &b2);
+  bool contain(const LPoint3f &p) const;
+  void fatten(float distance);
+  void include(const LPoint3f &v);
+  bool intersects(const PhysxBounds3 &b) const;
+  bool intersects2d(const PhysxBounds3 &b, unsigned axis_to_ignore) const;
+  bool is_empty() const;
+  void scale(float scale);
+  void set(const LPoint3f &min, const LPoint3f &max);
+  void set_center_extents(const LPoint3f &center, const LVector3f &extents);
+  void set_empty();
+  void set_infinite();
+  void transform(const LMatrix3f &orientation, const LPoint3f &translation);
 
-  LVecBase3f get_max() const;
-  LVecBase3f get_min() const;
+  LPoint3f get_max() const;
+  LPoint3f get_min() const;
+  LPoint3f get_center() const;
+  LVector3f get_dimensions() const;
 
-  void set_max(LVecBase3f value);
-  void set_min(LVecBase3f value);
+  void set_max(LPoint3f value);
+  void set_min(LPoint3f value);
 
 public:
-  NxBounds3 *nBounds3;
+  NxBounds3 _bounds;
 };
 
 #include "physxBounds3.I"
 
-#endif // HAVE_PHYSX
-
-#endif // PHYSXBOUNDS3_H
+#endif // PHYSBOUNDS3_H

+ 11 - 26
panda/src/physx/physxBox.I

@@ -1,5 +1,5 @@
 // Filename: physxBox.I
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (31Oct09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,39 +12,24 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-////////////////////////////////////////////////////////////////////
-//     Function : is_valid
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE bool PhysxBox::
-is_valid() const {
-  nassertr(nBox != NULL, false);
-
-  return nBox->isValid();
-}
 
 ////////////////////////////////////////////////////////////////////
-//     Function : rotate
-//       Access : Published
-//  Description :
+//     Function: PhysxBox::Constructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE void PhysxBox::
-rotate(const LMatrix4f & mtx, PhysxBox & obb) const {
-  nassertv(nBox != NULL);
+INLINE PhysxBox::
+PhysxBox() {
 
-  nBox->rotate(PhysxManager::lMatrix4_to_nxMat34(mtx), *(obb.nBox));
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_empty
-//       Access : Published
-//  Description :
+//     Function: PhysxBox::Destructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE void PhysxBox::
-set_empty() {
-  nassertv(nBox != NULL);
+INLINE PhysxBox::
+~PhysxBox() {
 
-  nBox->setEmpty();
 }
 

+ 72 - 59
panda/src/physx/physxBox.cxx

@@ -1,5 +1,5 @@
 // Filename: physxBox.cxx
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (31Oct09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,114 +12,127 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifdef HAVE_PHYSX
-
 #include "physxBox.h"
+#include "physxManager.h"
 
-#include "luse.h"
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBox::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+PhysxBox::
+PhysxBox(const LPoint3f &center, const LVector3f &extents, const LMatrix3f &rot) {
 
+  _box = NxBox(PhysxManager::point3_to_nxVec3(center),
+               PhysxManager::vec3_to_nxVec3(extents),
+               PhysxManager::mat3_to_nxMat33(rot));
+}
 
 ////////////////////////////////////////////////////////////////////
-//     Function : PhysxBox
-//       Access : Published
-//  Description :
+//     Function: PhysxBox::is_valid
+//       Access: Published
+//  Description: Returns TRUE if the box is valid.
 ////////////////////////////////////////////////////////////////////
-PhysxBox::
-PhysxBox() {
-  nBox = new NxBox();
+bool PhysxBox::
+is_valid() const {
+
+  return _box.isValid();
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : PhysxBox
-//       Access : Published
-//  Description :
+//     Function: PhysxBox::rotate
+//       Access: Published
+//  Description: Recomputes the box after an arbitrary transform by
+//               a 4x4 matrix.
 ////////////////////////////////////////////////////////////////////
-PhysxBox::
-PhysxBox(const LVecBase3f & _center, const LVecBase3f & _extents, const LMatrix3f & _rot) {
-  nBox = new NxBox(PhysxManager::lVecBase3_to_nxVec3(_center), PhysxManager::lVecBase3_to_nxVec3(_extents), PhysxManager::lMatrix3_to_nxMat33(_rot));
+void PhysxBox::
+rotate(const LMatrix4f &m, PhysxBox &obb) const {
+
+  nassertv(!m.is_nan());
+
+  _box.rotate(PhysxManager::mat4_to_nxMat34(m), obb._box);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : ~PhysxBox
-//       Access : Published
-//  Description :
+//     Function: PhysxBox::set_empty
+//       Access: Published
+//  Description: Setups an empty box.
 ////////////////////////////////////////////////////////////////////
-PhysxBox::
-~PhysxBox() {
-  delete nBox;
+void PhysxBox::
+set_empty() {
+
+  _box.setEmpty();
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_center
-//       Access : Published
-//  Description :
+//     Function: PhysxBox::get_center
+//       Access: Published
+//  Description: Return center of the box.
 ////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxBox::
+LPoint3f PhysxBox::
 get_center() const {
-  nassertr(nBox != NULL, *((LVecBase3f *)NULL));
 
-  return PhysxManager::nxVec3_to_lVecBase3(nBox->center);
+  return PhysxManager::nxVec3_to_point3(_box.GetCenter());
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_extents
-//       Access : Published
-//  Description :
+//     Function: PhysxBox::get_extents
+//       Access: Published
+//  Description: Returns the extents (radii) of the box.
 ////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxBox::
+LVector3f PhysxBox::
 get_extents() const {
-  nassertr(nBox != NULL, *((LVecBase3f *)NULL));
 
-  return PhysxManager::nxVec3_to_lVecBase3(nBox->extents);
+  return PhysxManager::nxVec3_to_vec3(_box.GetExtents());
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_rot
-//       Access : Published
-//  Description :
+//     Function: PhysxBox::get_rot
+//       Access: Published
+//  Description: Return the rotation of the box.
 ////////////////////////////////////////////////////////////////////
 LMatrix3f PhysxBox::
 get_rot() const {
-  nassertr(nBox != NULL, *((LMatrix3f *)NULL));
 
-  return PhysxManager::nxMat33_to_lMatrix3(nBox->rot);
+  return PhysxManager::nxMat33_to_mat3(_box.GetRot());
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_center
-//       Access : Published
-//  Description :
+//     Function: PhysxBox::set_center
+//       Access: Published
+//  Description: Sets the center of the box.
 ////////////////////////////////////////////////////////////////////
 void PhysxBox::
-set_center(LVecBase3f value) {
-  nassertv(nBox != NULL);
+set_center(LPoint3f center) {
 
-  nBox->center = PhysxManager::lVecBase3_to_nxVec3(value);
+  nassertv(!center.is_nan());
+
+  _box.center = PhysxManager::vec3_to_nxVec3(center);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_extents
-//       Access : Published
-//  Description :
+//     Function: PhysxBox::set_extents
+//       Access: Published
+//  Description: Sets the extents of the box.
 ////////////////////////////////////////////////////////////////////
 void PhysxBox::
-set_extents(LVecBase3f value) {
-  nassertv(nBox != NULL);
+set_extents(LVector3f extents) {
+
+  nassertv(!extents.is_nan());
 
-  nBox->extents = PhysxManager::lVecBase3_to_nxVec3(value);
+  _box.extents = PhysxManager::vec3_to_nxVec3(extents);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_rot
-//       Access : Published
-//  Description :
+//     Function: PhysxBox::set_rot
+//       Access: Published
+//  Description: Sets the rotation of the box.
 ////////////////////////////////////////////////////////////////////
 void PhysxBox::
-set_rot(LMatrix3f value) {
-  nassertv(nBox != NULL);
+set_rot(LMatrix3f rot) {
 
-  nBox->rot = PhysxManager::lMatrix3_to_nxMat33(value);
-}
+  nassertv(!rot.is_nan());
 
-#endif // HAVE_PHYSX
+  _box.rot = PhysxManager::mat3_to_nxMat33(rot);
+}
 

+ 21 - 23
panda/src/physx/physxBox.h

@@ -1,5 +1,5 @@
 // Filename: physxBox.h
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (31Oct09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -15,44 +15,42 @@
 #ifndef PHYSXBOX_H
 #define PHYSXBOX_H
 
-#ifdef HAVE_PHYSX
-
 #include "pandabase.h"
-
-#include "physx_enumerations.h"
-#include "physxManager.h"
 #include "luse.h"
 
-#include "NxPhysics.h"
+#include "config_physx.h"
 
 ////////////////////////////////////////////////////////////////////
 //       Class : PhysxBox
-// Description :
+// Description : Represents an oriented bounding box, as a center
+//               point, extents(radii) and a rotation. i.e. the
+//               center of the box is at the center point, the box
+//               is rotated around this point with the rotation and
+//               it is 2*extents in width, height and depth.
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDAPHYSX PhysxBox {
+
 PUBLISHED:
-  PhysxBox();
-  PhysxBox(const LVecBase3f & _center, const LVecBase3f & _extents, const LMatrix3f & _rot);
-  ~PhysxBox();
+  INLINE PhysxBox();
+  INLINE ~PhysxBox();
+  PhysxBox(const LPoint3f &center, const LVector3f &extents, const LMatrix3f &rot);
 
-  INLINE bool is_valid() const;
-  INLINE void rotate(const LMatrix4f & mtx, PhysxBox & obb) const;
-  INLINE void set_empty();
+  bool is_valid() const;
+  void rotate(const LMatrix4f &m, PhysxBox &obb) const;
+  void set_empty();
 
-  LVecBase3f get_center() const;
-  LVecBase3f get_extents() const;
+  LPoint3f get_center() const;
+  LVector3f get_extents() const;
   LMatrix3f get_rot() const;
 
-  void set_center( LVecBase3f value );
-  void set_extents( LVecBase3f value );
-  void set_rot( LMatrix3f value );
+  void set_center(LPoint3f center);
+  void set_extents(LVector3f extents);
+  void set_rot(LMatrix3f rot);
 
 public:
-  NxBox *nBox;
+  NxBox _box;
 };
 
 #include "physxBox.I"
 
-#endif // HAVE_PHYSX
-
-#endif // PHYSXBOX_H
+#endif // PHYSBOX_H

+ 16 - 14
panda/src/physx/physxJointLimitSoftPairDesc.I → panda/src/physx/physxBoxController.I

@@ -1,5 +1,5 @@
-// Filename: physxJointLimitSoftPairDesc.I
-// Created by:  pratt (Jun 20, 2006)
+// Filename: physxBoxController.I
+// Created by:  enn0x (24Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,23 +12,25 @@
 //
 ////////////////////////////////////////////////////////////////////
 
+
+
 ////////////////////////////////////////////////////////////////////
-//     Function : is_valid
-//       Access : Published
-//  Description :
+//     Function: PhysxBoxController::Constructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE bool PhysxJointLimitSoftPairDesc::
-is_valid() const {
-  return nJointLimitSoftPairDesc.isValid();
+INLINE PhysxBoxController::
+PhysxBoxController() : PhysxController() {
+
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_to_default
-//       Access : Published
-//  Description :
+//     Function: PhysxBoxController::Destructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE void PhysxJointLimitSoftPairDesc::
-set_to_default() {
-  nJointLimitSoftPairDesc.setToDefault();
+INLINE PhysxBoxController::
+~PhysxBoxController() {
+
 }
 

+ 85 - 0
panda/src/physx/physxBoxController.cxx

@@ -0,0 +1,85 @@
+// Filename: physxBoxController.cxx
+// Created by:  enn0x (24Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxBoxController.h"
+#include "physxManager.h"
+
+TypeHandle PhysxBoxController::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxController::link
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxBoxController::
+link(NxController *controllerPtr) {
+
+  nassertv(controllerPtr->getType() == NX_CONTROLLER_BOX);
+
+  // Link self
+  _ptr = (NxBoxController *)controllerPtr;
+  _error_type = ET_ok;
+
+  PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData;
+  scene->_controllers.add(this);
+
+  // Link actor
+  PT(PhysxActor) actor = new PhysxActor();
+  actor->link(_ptr->getActor());
+  actor->link_controller(this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxController::unlink
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxBoxController::
+unlink() {
+
+  // Unlink actor
+  PT(PhysxActor) actor = (PhysxActor *)ptr()->getActor()->userData;
+  actor->unlink();
+
+  // Unlink self
+  _error_type = ET_released;
+
+  PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData;
+  scene->_controllers.remove(this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxController::set_extents
+//       Access: Published
+//  Description: Sets controller's extents.
+////////////////////////////////////////////////////////////////////
+void PhysxBoxController::
+set_extents(const LVector3f &extents) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setExtents(PhysxManager::vec3_to_nxVec3(extents));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxController::get_extents
+//       Access: Published
+//  Description: Returns controller's extents.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxBoxController::
+get_extents() const {
+
+  nassertr(_error_type == ET_ok, LVector3f::zero());
+  return PhysxManager::nxVec3_to_vec3(_ptr->getExtents());
+}
+

+ 72 - 0
panda/src/physx/physxBoxController.h

@@ -0,0 +1,72 @@
+// Filename: physxBoxController.h
+// Created by:  enn0x (24Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXBOXCONTROLLER_H
+#define PHYSXBOXCONTROLLER_H
+
+#include "pandabase.h"
+#include "lvector3.h"
+
+#include "physxController.h"
+
+#include "NxBoxController.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxBoxController
+// Description : Box character controller.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxBoxController : public PhysxController {
+
+PUBLISHED:
+  INLINE PhysxBoxController();
+  INLINE ~PhysxBoxController();
+
+  void set_extents(const LVector3f &extents);
+  LVector3f get_extents() const;
+
+////////////////////////////////////////////////////////////////////
+public:
+  INLINE NxController *ptr() const { return (NxController *)_ptr; };
+
+  void link(NxController *controllerPtr);
+  void unlink();
+
+private:
+  NxBoxController *_ptr;
+
+////////////////////////////////////////////////////////////////////
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    PhysxController::init_type();
+    register_type(_type_handle, "PhysxBoxController", 
+                  PhysxController::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 "physxBoxController.I"
+
+#endif // PHYSXBOXCONTROLLER_H

+ 59 - 0
panda/src/physx/physxBoxControllerDesc.I

@@ -0,0 +1,59 @@
+// Filename: physxBoxControllerDesc.I
+// Created by:  enn0x (22Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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: PhysxBoxControllerDesc::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxBoxControllerDesc::
+PhysxBoxControllerDesc() : PhysxControllerDesc() {
+
+  _desc.upDirection = (NxHeightFieldAxis)physx_up_axis.get_value();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxControllerDesc::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxBoxControllerDesc::
+~PhysxBoxControllerDesc() {
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxControllerDesc::set_to_default
+//       Access: Published
+//  Description: (re)sets the structure to the default.
+////////////////////////////////////////////////////////////////////
+INLINE void PhysxBoxControllerDesc::
+set_to_default() {
+
+  _desc.setToDefault();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxControllerDesc::is_valid
+//       Access: Published
+//  Description: Returns true if the descriptor is valid.
+////////////////////////////////////////////////////////////////////
+INLINE bool PhysxBoxControllerDesc::
+is_valid() const {
+
+  return _desc.isValid();
+}
+

+ 43 - 0
panda/src/physx/physxBoxControllerDesc.cxx

@@ -0,0 +1,43 @@
+// Filename: physxBoxControllerDesc.cxx
+// Created by:  enn0x (22Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxBoxControllerDesc.h"
+#include "physxManager.h"
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxControllerDesc::set_extents
+//       Access: Published
+//  Description: Sets the dimensions of the box.
+//
+//               The dimensions are the 'radii' of the box,
+//               meaning 1/2 extents in x dimension, 1/2 extents
+//               in y dimension, 1/2 extents in z dimension.
+////////////////////////////////////////////////////////////////////
+void PhysxBoxControllerDesc::
+set_extents(const LVector3f &extents) {
+
+  _desc.extents = PhysxManager::vec3_to_nxVec3(extents);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxControllerDesc::get_extents
+//       Access: Published
+//  Description: Returns the dimensions of the box.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxBoxControllerDesc::
+get_extents() const {
+
+  return PhysxManager::nxVec3_to_vec3(_desc.extents);
+}
+

+ 49 - 0
panda/src/physx/physxBoxControllerDesc.h

@@ -0,0 +1,49 @@
+// Filename: physxBoxControllerDesc.h
+// Created by:  enn0x (22Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXBOXCONTROLLERDESC_H
+#define PHYSXBOXCONTROLLERDESC_H
+
+#include "pandabase.h"
+#include "lvector3.h"
+
+#include "physxControllerDesc.h"
+
+#include "NxBoxController.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxBoxControllerDesc
+// Description : Descriptor class for PhysxBoxController.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxBoxControllerDesc : public PhysxControllerDesc {
+
+PUBLISHED:
+  INLINE PhysxBoxControllerDesc();
+  INLINE ~PhysxBoxControllerDesc();
+
+  INLINE void set_to_default();
+  INLINE bool is_valid() const;
+
+  void set_extents(const LVector3f &extents);
+
+  LVector3f get_extents() const;
+
+public:
+  NxControllerDesc *ptr() const { return (NxControllerDesc *)&_desc; };
+  NxBoxControllerDesc _desc;
+};
+
+#include "physxBoxControllerDesc.I"
+
+#endif // PHYSXBOXCONTROLLERDESC_H

+ 16 - 28
panda/src/physx/physxTemplate.h → panda/src/physx/physxBoxForceFieldShape.I

@@ -1,5 +1,5 @@
-// Filename: physxTemplate.h
-// Created by:  pratt (Dec 12, 2007)
+// Filename: physxBoxForceFieldShape.I
+// Created by:  enn0x (15Nov09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,37 +12,25 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifndef PHYSXTEMPLATE_H
-#define PHYSXTEMPLATE_H
 
-#ifdef HAVE_PHYSX
 
-#include "pandabase.h"
-
-#include "physx_enumerations.h"
-#include "physxManager.h"
-#include "luse.h"
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxForceFieldShape::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxBoxForceFieldShape::
+PhysxBoxForceFieldShape() : PhysxForceFieldShape() {
 
-//superHeader
-//forwardDeclarations
-#include "NxPhysics.h"
+}
 
 ////////////////////////////////////////////////////////////////////
-//       Class : PhysxTemplate
-// Description :
+//     Function: PhysxBoxForceFieldShape::Destructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDAPHYSX PhysxTemplate /*baseclassref*/{
-PUBLISHED:
-//publicstructors
-//publicmethods
-//publicattributes
-public:
-//nxreference
-//typeinfo
-};
-
-#include "physxTemplate.I"
+INLINE PhysxBoxForceFieldShape::
+~PhysxBoxForceFieldShape() {
 
-#endif // HAVE_PHYSX
+}
 
-#endif // PHYSXTEMPLATE_H

+ 96 - 0
panda/src/physx/physxBoxForceFieldShape.cxx

@@ -0,0 +1,96 @@
+// Filename: physxBoxForceFieldShape.cxx
+// Created by:  enn0x (15Nov09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxBoxForceFieldShape.h"
+#include "physxBoxForceFieldShapeDesc.h"
+#include "physxManager.h"
+
+TypeHandle PhysxBoxForceFieldShape::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxForceFieldShape::link
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxBoxForceFieldShape::
+link(NxForceFieldShape *shapePtr) {
+
+  _ptr = shapePtr->isBox();
+  _ptr->userData = this;
+  _error_type = ET_ok;
+
+  PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData;
+  group->_shapes.add(this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxForceFieldShape::unlink
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxBoxForceFieldShape::
+unlink() {
+
+  _ptr->userData = NULL;
+  _error_type = ET_released;
+
+  PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData;
+  group->_shapes.remove(this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function : PhysxBoxForceFieldShape::save_to_desc
+//       Access : Published
+//  Description : Saves the state of the shape object to a 
+//                descriptor.
+////////////////////////////////////////////////////////////////////
+void PhysxBoxForceFieldShape::
+save_to_desc(PhysxBoxForceFieldShapeDesc &shapeDesc) const {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->saveToDesc(shapeDesc._desc);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxForceFieldShape::set_dimensions
+//       Access: Published
+//  Description: Sets the box dimensions. 
+//
+//               The dimensions are the 'radii' of the box,
+//               meaning 1/2 extents in x dimension, 1/2 extents
+//               in y dimension, 1/2 extents in z dimension.
+////////////////////////////////////////////////////////////////////
+void PhysxBoxForceFieldShape::
+set_dimensions(const LVector3f &vec) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setDimensions(PhysxManager::vec3_to_nxVec3(vec));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxForceFieldShape::get_dimensions
+//       Access: Published
+//  Description: Retrieves the dimensions of the box. 
+//
+//               The dimensions are the 'radii' of the box,
+//               meaning 1/2 extents in x dimension, 1/2 extents
+//               in y dimension, 1/2 extents in z dimension.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxBoxForceFieldShape::
+get_dimensions() const {
+
+  nassertr(_error_type == ET_ok, LVector3f::zero());
+  return PhysxManager::nxVec3_to_vec3(_ptr->getDimensions());
+}
+

+ 77 - 0
panda/src/physx/physxBoxForceFieldShape.h

@@ -0,0 +1,77 @@
+// Filename: physxBoxForceFieldShape.h
+// Created by:  enn0x (15Nov09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXBOXFORCEFIELDSHAPE_H
+#define PHYSXBOXFORCEFIELDSHAPE_H
+
+#include "pandabase.h"
+#include "lvector3.h"
+
+#include "physxForceFieldShape.h"
+
+#include "NoMinMax.h"
+#include "NxPhysics.h"
+
+class PhysxBoxForceFieldShapeDesc;
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxBoxForceFieldShape
+// Description : A box shaped region used to define a force field.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxBoxForceFieldShape : public PhysxForceFieldShape {
+
+PUBLISHED:
+  INLINE PhysxBoxForceFieldShape();
+  INLINE ~PhysxBoxForceFieldShape();
+
+  void save_to_desc(PhysxBoxForceFieldShapeDesc &shapeDesc) const;
+
+  void set_dimensions(const LVector3f &dimensions);
+  LVector3f get_dimensions() const;
+
+////////////////////////////////////////////////////////////////////
+public:
+  INLINE NxForceFieldShape *ptr() const { return (NxForceFieldShape *)_ptr; };
+
+  void link(NxForceFieldShape *shapePtr);
+  void unlink();
+
+private:
+  NxBoxForceFieldShape *_ptr;
+
+////////////////////////////////////////////////////////////////////
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    PhysxForceFieldShape::init_type();
+    register_type(_type_handle, "PhysxBoxForceFieldShape", 
+                  PhysxForceFieldShape::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 "physxBoxForceFieldShape.I"
+
+#endif // PHYSXBOXFORCEFIELDSHAPE_H

+ 59 - 0
panda/src/physx/physxBoxForceFieldShapeDesc.I

@@ -0,0 +1,59 @@
+// Filename: physxBoxForceFieldShapeDesc.I
+// Created by:  enn0x (06Nov09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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: PhysxBoxForceFieldShapeDesc::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxBoxForceFieldShapeDesc::
+PhysxBoxForceFieldShapeDesc() : PhysxForceFieldShapeDesc() {
+
+  _desc.name = "";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxForceFieldShapeDesc::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxBoxForceFieldShapeDesc::
+~PhysxBoxForceFieldShapeDesc() {
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxForceFieldShapeDesc::set_to_default
+//       Access: Published
+//  Description: (re)sets the structure to the default.
+////////////////////////////////////////////////////////////////////
+INLINE void PhysxBoxForceFieldShapeDesc::
+set_to_default() {
+
+  _desc.setToDefault();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxForceFieldShapeDesc::is_valid
+//       Access: Published
+//  Description: Returns true if the descriptor is valid.
+////////////////////////////////////////////////////////////////////
+INLINE bool PhysxBoxForceFieldShapeDesc::
+is_valid() const {
+
+  return _desc.isValid();
+}
+

+ 44 - 0
panda/src/physx/physxBoxForceFieldShapeDesc.cxx

@@ -0,0 +1,44 @@
+// Filename: physxBoxForceFieldShapeDesc.cxx
+// Created by:  enn0x (06Nov09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxBoxForceFieldShapeDesc.h"
+#include "physxManager.h"
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxForceFieldShapeDesc::set_dimensions
+//       Access: Published
+//  Description: Sets the dimensions of the box.
+//
+//               The dimensions are the 'radii' of the box,
+//               meaning 1/2 extents in x dimension, 1/2 extents
+//               in y dimension, 1/2 extents in z dimension.
+////////////////////////////////////////////////////////////////////
+void PhysxBoxForceFieldShapeDesc::
+set_dimensions(const LVector3f &dimensions) {
+
+  nassertv(!dimensions.is_nan());
+  _desc.dimensions = PhysxManager::vec3_to_nxVec3(dimensions);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxForceFieldShapeDesc::get_dimensions
+//       Access: Published
+//  Description: Returns the dimensions of the box.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxBoxForceFieldShapeDesc::
+get_dimensions() const {
+
+  return PhysxManager::nxVec3_to_vec3(_desc.dimensions);
+}
+

+ 50 - 0
panda/src/physx/physxBoxForceFieldShapeDesc.h

@@ -0,0 +1,50 @@
+// Filename: physxBoxForceFieldShapeDesc.h
+// Created by:  enn0x (06Nov09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXBOXFORCEFIELDSHAPEDESC_H
+#define PHYSXBOXFORCEFIELDSHAPEDESC_H
+
+#include "pandabase.h"
+#include "lvector3.h"
+
+#include "physxForceFieldShapeDesc.h"
+
+#include "NoMinMax.h"
+#include "NxPhysics.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxBoxForceFieldShapeDesc
+// Description : Descriptor for a box force field shape.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxBoxForceFieldShapeDesc : public PhysxForceFieldShapeDesc {
+
+PUBLISHED:
+  INLINE PhysxBoxForceFieldShapeDesc();
+  INLINE ~PhysxBoxForceFieldShapeDesc();
+
+  INLINE void set_to_default();
+  INLINE bool is_valid() const;
+
+  void set_dimensions(const LVector3f &dimensions);
+
+  LVector3f get_dimensions() const;
+
+public:
+  NxForceFieldShapeDesc *ptr() const { return (NxForceFieldShapeDesc *)&_desc; };
+  NxBoxForceFieldShapeDesc _desc;
+};
+
+#include "physxBoxForceFieldShapeDesc.I"
+
+#endif // PHYSXBOXFORCEFIELDSHAPEDESC_H

+ 23 - 1
panda/src/physx/physxBoxShape.I

@@ -1,5 +1,5 @@
 // Filename: physxBoxShape.I
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (16Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,3 +12,25 @@
 //
 ////////////////////////////////////////////////////////////////////
 
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxShape::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxBoxShape::
+PhysxBoxShape() : PhysxShape() {
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxShape::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxBoxShape::
+~PhysxBoxShape() {
+
+}
+

+ 53 - 31
panda/src/physx/physxBoxShape.cxx

@@ -1,5 +1,5 @@
 // Filename: physxBoxShape.cxx
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (16Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,63 +12,85 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifdef HAVE_PHYSX
-
 #include "physxBoxShape.h"
-
-#include "luse.h"
-#include "physxBox.h"
 #include "physxBoxShapeDesc.h"
+#include "physxManager.h"
 
 TypeHandle PhysxBoxShape::_type_handle;
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_dimensions
-//       Access : Published
-//  Description :
+//     Function: PhysxBoxShape::link
+//       Access: Public
+//  Description: 
 ////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxBoxShape::
-get_dimensions() const {
-  nassertr(nBoxShape != NULL, *((LVecBase3f *)NULL));
+void PhysxBoxShape::
+link(NxShape *shapePtr) {
+
+  _ptr = shapePtr->isBox();
+  _ptr->userData = this;
+  _error_type = ET_ok;
 
-  return PhysxManager::nxVec3_to_lVecBase3(nBoxShape->getDimensions());
+  PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
+  actor->_shapes.add(this);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_world_obb
-//       Access : Published
-//  Description :
+//     Function: PhysxBoxShape::unlink
+//       Access: Public
+//  Description: 
 ////////////////////////////////////////////////////////////////////
 void PhysxBoxShape::
-get_world_obb(PhysxBox & obb) const {
-  nassertv(nBoxShape != NULL);
+unlink() {
+
+  _ptr->userData = NULL;
+  _error_type = ET_released;
 
-  nBoxShape->getWorldOBB(*(obb.nBox));
+  PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
+  actor->_shapes.remove(this);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : save_to_desc
+//     Function : PhysxBoxShape::save_to_desc
 //       Access : Published
-//  Description :
+//  Description : Saves the state of the shape object to a 
+//                descriptor.
 ////////////////////////////////////////////////////////////////////
 void PhysxBoxShape::
-save_to_desc(PhysxBoxShapeDesc & desc) const {
-  nassertv(nBoxShape != NULL);
+save_to_desc(PhysxBoxShapeDesc &shapeDesc) const {
 
-  nBoxShape->saveToDesc(desc.nBoxShapeDesc);
+  nassertv(_error_type == ET_ok);
+  _ptr->saveToDesc(shapeDesc._desc);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_dimensions
-//       Access : Published
-//  Description :
+//     Function: PhysxBoxShape::set_dimensions
+//       Access: Published
+//  Description: Sets the box dimensions. 
+//
+//               The dimensions are the 'radii' of the box,
+//               meaning 1/2 extents in x dimension, 1/2 extents
+//               in y dimension, 1/2 extents in z dimension.
 ////////////////////////////////////////////////////////////////////
 void PhysxBoxShape::
-set_dimensions(const LVecBase3f & vec) {
-  nassertv(nBoxShape != NULL);
+set_dimensions(const LVector3f &vec) {
 
-  nBoxShape->setDimensions(PhysxManager::lVecBase3_to_nxVec3(vec));
+  nassertv(_error_type == ET_ok);
+  _ptr->setDimensions(PhysxManager::vec3_to_nxVec3(vec));
 }
 
-#endif // HAVE_PHYSX
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxShape::get_dimensions
+//       Access: Published
+//  Description: Retrieves the dimensions of the box. 
+//
+//               The dimensions are the 'radii' of the box,
+//               meaning 1/2 extents in x dimension, 1/2 extents
+//               in y dimension, 1/2 extents in z dimension.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxBoxShape::
+get_dimensions() const {
+
+  nassertr(_error_type == ET_ok, LVector3f::zero());
+  return PhysxManager::nxVec3_to_vec3(_ptr->getDimensions());
+}
 

+ 34 - 19
panda/src/physx/physxBoxShape.h

@@ -1,5 +1,5 @@
 // Filename: physxBoxShape.h
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (16Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -15,43 +15,60 @@
 #ifndef PHYSXBOXSHAPE_H
 #define PHYSXBOXSHAPE_H
 
-#ifdef HAVE_PHYSX
-
 #include "pandabase.h"
-
-#include "physx_enumerations.h"
-#include "physxManager.h"
-#include "luse.h"
+#include "lvector3.h"
 
 #include "physxShape.h"
 
-class PhysxBox;
-class PhysxBoxShapeDesc;
-
+#include "NoMinMax.h"
 #include "NxPhysics.h"
 
+class PhysxBoxShapeDesc;
+
 ////////////////////////////////////////////////////////////////////
 //       Class : PhysxBoxShape
-// Description :
+// Description : A box shaped collision detection primitive. Each
+//               shape is owned by the actor which it is attached
+//               to.
+//
+//               An instance can be created by calling the
+//               createShape() method of the PhysxActor object that
+//               will own it, with a PhysxBoxShapeDesc object as the
+//               parameter, or by adding the shape descriptor to the
+//               PhysxActorDesc class before creating the actor.
+//
+//               The shape is deleted by calling release() on the
+//               shape itself.
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDAPHYSX PhysxBoxShape : public PhysxShape {
+
 PUBLISHED:
+  INLINE PhysxBoxShape();
+  INLINE ~PhysxBoxShape();
 
-  LVecBase3f get_dimensions() const;
-  void get_world_obb(PhysxBox & obb) const;
-  void save_to_desc(PhysxBoxShapeDesc & desc) const;
-  void set_dimensions(const LVecBase3f & vec);
+  void save_to_desc(PhysxBoxShapeDesc &shapeDesc) const;
 
+  void set_dimensions(const LVector3f &dimensions);
+  LVector3f get_dimensions() const;
 
+////////////////////////////////////////////////////////////////////
 public:
-  NxBoxShape *nBoxShape;
+  INLINE NxShape *ptr() const { return (NxShape *)_ptr; };
+
+  void link(NxShape *shapePtr);
+  void unlink();
+
+private:
+  NxBoxShape *_ptr;
 
+////////////////////////////////////////////////////////////////////
+public:
   static TypeHandle get_class_type() {
     return _type_handle;
   }
   static void init_type() {
     PhysxShape::init_type();
-    register_type(_type_handle, "PhysxBoxShape",
+    register_type(_type_handle, "PhysxBoxShape", 
                   PhysxShape::get_class_type());
   }
   virtual TypeHandle get_type() const {
@@ -68,6 +85,4 @@ private:
 
 #include "physxBoxShape.I"
 
-#endif // HAVE_PHYSX
-
 #endif // PHYSXBOXSHAPE_H

+ 36 - 11
panda/src/physx/physxBoxShapeDesc.I

@@ -1,5 +1,5 @@
 // Filename: physxBoxShapeDesc.I
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (08Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,23 +12,48 @@
 //
 ////////////////////////////////////////////////////////////////////
 
+
+
 ////////////////////////////////////////////////////////////////////
-//     Function : is_valid
-//       Access : Published
-//  Description :
+//     Function: PhysxBoxShapeDesc::Constructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE bool PhysxBoxShapeDesc::
-is_valid() const {
-  return nBoxShapeDesc.isValid();
+INLINE PhysxBoxShapeDesc::
+PhysxBoxShapeDesc() : PhysxShapeDesc() {
+
+  _desc.name = "";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxShapeDesc::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxBoxShapeDesc::
+~PhysxBoxShapeDesc() {
+
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_to_default
-//       Access : Published
-//  Description :
+//     Function: PhysxBoxShapeDesc::set_to_default
+//       Access: Published
+//  Description: (re)sets the structure to the default.
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysxBoxShapeDesc::
 set_to_default() {
-  nBoxShapeDesc.setToDefault();
+
+  _desc.setToDefault();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxBoxShapeDesc::is_valid
+//       Access: Published
+//  Description: Returns true if the descriptor is valid.
+////////////////////////////////////////////////////////////////////
+INLINE bool PhysxBoxShapeDesc::
+is_valid() const {
+
+  return _desc.isValid();
 }
 

+ 18 - 28
panda/src/physx/physxBoxShapeDesc.cxx

@@ -1,5 +1,5 @@
 // Filename: physxBoxShapeDesc.cxx
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (08Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,43 +12,33 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifdef HAVE_PHYSX
-
 #include "physxBoxShapeDesc.h"
-
-#include "luse.h"
-
+#include "physxManager.h"
 
 ////////////////////////////////////////////////////////////////////
-//     Function : PhysxBoxShapeDesc
-//       Access : Published
-//  Description :
+//     Function: PhysxBoxShapeDesc::set_dimensions
+//       Access: Published
+//  Description: Sets the dimensions of the box.
+//
+//               The dimensions are the 'radii' of the box,
+//               meaning 1/2 extents in x dimension, 1/2 extents
+//               in y dimension, 1/2 extents in z dimension.
 ////////////////////////////////////////////////////////////////////
-PhysxBoxShapeDesc::
-PhysxBoxShapeDesc()
-: PhysxShapeDesc( &nBoxShapeDesc ) {
+void PhysxBoxShapeDesc::
+set_dimensions(const LVector3f &dimensions) {
 
+  nassertv(!dimensions.is_nan());
+  _desc.dimensions = PhysxManager::vec3_to_nxVec3(dimensions);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_dimensions
-//       Access : Published
-//  Description :
+//     Function: PhysxBoxShapeDesc::get_dimensions
+//       Access: Published
+//  Description: Returns the dimensions of the box.
 ////////////////////////////////////////////////////////////////////
-LVecBase3f PhysxBoxShapeDesc::
+LVector3f PhysxBoxShapeDesc::
 get_dimensions() const {
-  return PhysxManager::nxVec3_to_lVecBase3(nBoxShapeDesc.dimensions);
-}
 
-////////////////////////////////////////////////////////////////////
-//     Function : set_dimensions
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxBoxShapeDesc::
-set_dimensions(LVecBase3f value) {
-  nBoxShapeDesc.dimensions = PhysxManager::lVecBase3_to_nxVec3(value);
+  return PhysxManager::nxVec3_to_vec3(_desc.dimensions);
 }
 
-#endif // HAVE_PHYSX
-

+ 12 - 15
panda/src/physx/physxBoxShapeDesc.h

@@ -1,5 +1,5 @@
 // Filename: physxBoxShapeDesc.h
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (08Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -15,39 +15,36 @@
 #ifndef PHYSXBOXSHAPEDESC_H
 #define PHYSXBOXSHAPEDESC_H
 
-#ifdef HAVE_PHYSX
-
 #include "pandabase.h"
-
-#include "physx_enumerations.h"
-#include "physxManager.h"
-#include "luse.h"
+#include "lvector3.h"
 
 #include "physxShapeDesc.h"
 
+#include "NoMinMax.h"
 #include "NxPhysics.h"
 
 ////////////////////////////////////////////////////////////////////
 //       Class : PhysxBoxShapeDesc
-// Description :
+// Description : Descriptor class for PhysxBoxShape.
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDAPHYSX PhysxBoxShapeDesc : public PhysxShapeDesc {
+
 PUBLISHED:
-  PhysxBoxShapeDesc();
+  INLINE PhysxBoxShapeDesc();
+  INLINE ~PhysxBoxShapeDesc();
 
-  INLINE bool is_valid() const;
   INLINE void set_to_default();
+  INLINE bool is_valid() const;
 
-  LVecBase3f get_dimensions() const;
+  void set_dimensions(const LVector3f &dimensions);
 
-  void set_dimensions( LVecBase3f value );
+  LVector3f get_dimensions() const;
 
 public:
-  NxBoxShapeDesc nBoxShapeDesc;
+  NxShapeDesc *ptr() const { return (NxShapeDesc *)&_desc; };
+  NxBoxShapeDesc _desc;
 };
 
 #include "physxBoxShapeDesc.I"
 
-#endif // HAVE_PHYSX
-
 #endif // PHYSXBOXSHAPEDESC_H

+ 23 - 15
panda/src/physx/physxCapsule.I

@@ -1,5 +1,5 @@
 // Filename: physxCapsule.I
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (31Oct09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,27 +12,35 @@
 //
 ////////////////////////////////////////////////////////////////////
 
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsule::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxCapsule::
+PhysxCapsule() {
+
+}
+
 ////////////////////////////////////////////////////////////////////
-//     Function : get_radius
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsule::Constructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE float PhysxCapsule::
-get_radius() const {
-  nassertr(nCapsule != NULL, -1.0f);
+INLINE PhysxCapsule::
+PhysxCapsule(const PhysxSegment &segment, float radius) {
 
-  return nCapsule->radius;
+  _capsule = NxCapsule(segment._segment, radius);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_radius
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsule::Destructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE void PhysxCapsule::
-set_radius(float value) {
-  nassertv(nCapsule != NULL);
+INLINE PhysxCapsule::
+~PhysxCapsule() {
 
-  nCapsule->radius = value;
 }
 

+ 141 - 15
panda/src/physx/physxCapsule.cxx

@@ -1,5 +1,5 @@
 // Filename: physxCapsule.cxx
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (31Oct09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,32 +12,158 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifdef HAVE_PHYSX
-
 #include "physxCapsule.h"
+#include "physxManager.h"
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsule::get_radius
+//       Access: Published
+//  Description: Returns the capsule's radius.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsule::
+get_radius() const {
 
-#include "physxSegment.h"
+  return _capsule.radius;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsule::set_radius
+//       Access: Published
+//  Description: Sets the capsule's radius.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsule::
+set_radius(float radius) {
 
+  _capsule.radius = radius;
+}
 
 ////////////////////////////////////////////////////////////////////
-//     Function : PhysxCapsule
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsule::get_p0
+//       Access: Published
+//  Description: Returns the start point of the segment.
 ////////////////////////////////////////////////////////////////////
-PhysxCapsule::
-PhysxCapsule(const PhysxSegment & seg, float _radius) {
+LPoint3f PhysxCapsule::
+get_p0() const {
 
+  return PhysxManager::nxVec3_to_vec3(_capsule.p0);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : ~PhysxCapsule
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsule::set_p0
+//       Access: Published
+//  Description: Sets the start point of the segment.
 ////////////////////////////////////////////////////////////////////
-PhysxCapsule::
-~PhysxCapsule() {
+void PhysxCapsule::
+set_p0(LPoint3f p) {
 
+  nassertv(!p.is_nan());
+
+  _capsule.p0 = PhysxManager::vec3_to_nxVec3(p);
 }
 
-#endif // HAVE_PHYSX
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsule::get_p1
+//       Access: Published
+//  Description: Returns the end point of the segment.
+////////////////////////////////////////////////////////////////////
+LPoint3f PhysxCapsule::
+get_p1() const {
+
+  return PhysxManager::nxVec3_to_vec3(_capsule.p1);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsule::set_p1
+//       Access: Published
+//  Description: Sets the end point of the segment.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsule::
+set_p1(LPoint3f p) {
+
+  nassertv(!p.is_nan());
+
+  _capsule.p1 = PhysxManager::vec3_to_nxVec3(p);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsule::get_origin
+//       Access: Published
+//  Description: Returns the start point of the segment.
+////////////////////////////////////////////////////////////////////
+LPoint3f PhysxCapsule::
+get_origin() const {
+
+  return PhysxManager::nxVec3_to_point3(_capsule.getOrigin());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsule::compute_direction
+//       Access: Published
+//  Description: Returns the direction vector from the segment's
+//               start point to it's end point.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsule::
+compute_direction(LPoint3f &dir) const {
+
+  nassertv(!dir.is_nan());
+
+  NxVec3 nDir = PhysxManager::point3_to_nxVec3(dir);
+  _capsule.computeDirection(nDir);
+  PhysxManager::update_point3_from_nxVec3(dir, nDir);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsule::compute_length
+//       Access: Published
+//  Description: Returns the distance from the segment's start point
+//               to it's end point.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsule::
+compute_length() const {
+
+  return _capsule.computeLength();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsule::compute_point
+//       Access: Published
+//  Description: Computes a point on the segment. 
+////////////////////////////////////////////////////////////////////
+void PhysxCapsule::
+compute_point(LPoint3f &p, float t) const {
+
+  nassertv(!p.is_nan());
+
+  NxVec3 nP = PhysxManager::point3_to_nxVec3(p);
+  _capsule.computePoint(nP, t);
+  PhysxManager::update_point3_from_nxVec3(p, nP);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsule::compute_square_length
+//       Access: Published
+//  Description: Returns the square distance from the segment's
+//               start point to it's end point.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsule::
+compute_square_length() const {
+
+  return _capsule.computeSquareLength();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsule::set_origin_direction
+//       Access: Published
+//  Description: Setup this capsule from origin (start point) and
+//               direction vector.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsule::
+set_origin_direction(const LPoint3f &origin, const LVector3f &direction) {
+
+  nassertv(!origin.is_nan());
+  nassertv(!direction.is_nan());
+
+  _capsule.setOriginDirection(PhysxManager::point3_to_nxVec3(origin),
+                              PhysxManager::vec3_to_nxVec3(direction));
+}
 

+ 22 - 19
panda/src/physx/physxCapsule.h

@@ -1,5 +1,5 @@
 // Filename: physxCapsule.h
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (31Oct09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -15,38 +15,41 @@
 #ifndef PHYSXCAPSULE_H
 #define PHYSXCAPSULE_H
 
-#ifdef HAVE_PHYSX
-
 #include "pandabase.h"
 
-#include "physx_enumerations.h"
-#include "physxManager.h"
-#include "luse.h"
-
+#include "config_physx.h"
 #include "physxSegment.h"
 
-#include "NxPhysics.h"
-
 ////////////////////////////////////////////////////////////////////
 //       Class : PhysxCapsule
-// Description :
+// Description : Represents a capsule.
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDAPHYSX PhysxCapsule : public PhysxSegment {
+class EXPCL_PANDAPHYSX PhysxCapsule {
+
 PUBLISHED:
-  PhysxCapsule(const PhysxSegment & seg, float _radius);
-  ~PhysxCapsule();
+  INLINE PhysxCapsule();
+  INLINE PhysxCapsule(const PhysxSegment &segment, float radius);
+  INLINE ~PhysxCapsule();
 
+  void compute_direction(LPoint3f &dir) const;
+  float compute_length() const;
+  void compute_point(LPoint3f &p, float t) const;
+  float compute_square_length() const;
+  LPoint3f get_origin() const;
+  void set_origin_direction(const LPoint3f &origin, const LVector3f &direction);
 
-  INLINE float get_radius() const;
+  float get_radius() const;
+  LPoint3f get_p0() const;
+  LPoint3f get_p1() const;
 
-  INLINE void set_radius( float value );
+  void set_radius(float value);
+  void set_p0(LPoint3f p);
+  void set_p1(LPoint3f p);
 
 public:
-  NxCapsule *nCapsule;
+  NxCapsule _capsule;
 };
 
 #include "physxCapsule.I"
 
-#endif // HAVE_PHYSX
-
-#endif // PHYSXCAPSULE_H
+#endif // PHYSCAPSULE_H

+ 36 - 0
panda/src/physx/physxCapsuleController.I

@@ -0,0 +1,36 @@
+// Filename: physxCapsuleController.I
+// Created by:  enn0x (24Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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: PhysxCapsuleController::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxCapsuleController::
+PhysxCapsuleController() : PhysxController() {
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleController::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxCapsuleController::
+~PhysxCapsuleController() {
+
+}
+

+ 108 - 0
panda/src/physx/physxCapsuleController.cxx

@@ -0,0 +1,108 @@
+// Filename: physxCapsuleController.cxx
+// Created by:  enn0x (24Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxCapsuleController.h"
+
+TypeHandle PhysxCapsuleController::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleController::link
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleController::
+link(NxController *controllerPtr) {
+
+  nassertv(controllerPtr->getType() == NX_CONTROLLER_CAPSULE);
+
+  // Link self
+  _ptr = (NxCapsuleController *)controllerPtr;
+  _error_type = ET_ok;
+
+  PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData;
+  scene->_controllers.add(this);
+
+  // Link actor
+  PT(PhysxActor) actor = new PhysxActor();
+  actor->link(_ptr->getActor());
+  actor->link_controller(this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleController::unlink
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleController::
+unlink() {
+
+  // Unlink actor
+  PT(PhysxActor) actor = (PhysxActor *)ptr()->getActor()->userData;
+  actor->unlink();
+
+  // Unlink self
+  _error_type = ET_released;
+
+  PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData;
+  scene->_controllers.remove(this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleController::set_radius
+//       Access: Published
+//  Description: Resets the controller's radius.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleController::
+set_radius(float radius) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setRadius(radius);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleController::set_height
+//       Access: Published
+//  Description: Resets the controller's height.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleController::
+set_height(float height) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setHeight(height);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleController::get_radius
+//       Access: Published
+//  Description: Returns the controller's radius.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsuleController::
+get_radius() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getRadius();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleController::get_height
+//       Access: Published
+//  Description: Returns the controller's height.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsuleController::
+get_height() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getHeight();
+}
+

+ 90 - 0
panda/src/physx/physxCapsuleController.h

@@ -0,0 +1,90 @@
+// Filename: physxCapsuleController.h
+// Created by:  enn0x (24Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXCAPSULECONTROLLER_H
+#define PHYSXCAPSULECONTROLLER_H
+
+#include "pandabase.h"
+#include "lvector3.h"
+
+#include "physxController.h"
+
+#include "NxCapsuleController.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxCapsuleController
+// Description : A capsule character controller.
+//
+//               The capsule is defined as a position, a vertical
+//               height, and a radius. The height is the same height
+//               as for PhysxCapsuleShape objects, i.e. the distance
+//               between the two sphere centers at the end of the
+//               capsule. In other words:
+//
+//               p = pos (returned by controller)
+//               h = height
+//               r = radius
+//
+//               p = center of capsule
+//               top sphere center = p.y + h*0.5
+//               bottom sphere center = p.y - h*0.5
+//               top capsule point = p.y + h*0.5 + r
+//               bottom capsule point = p.y - h*0.5 - r
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxCapsuleController : public PhysxController {
+
+PUBLISHED:
+  INLINE PhysxCapsuleController();
+  INLINE ~PhysxCapsuleController();
+
+  void set_radius(float radius);
+  void set_height(float height);
+  float get_radius() const;
+  float get_height() const;
+
+////////////////////////////////////////////////////////////////////
+public:
+  INLINE NxController *ptr() const { return (NxController *)_ptr; };
+
+  void link(NxController *controllerPtr);
+  void unlink();
+
+private:
+  NxCapsuleController *_ptr;
+
+////////////////////////////////////////////////////////////////////
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    PhysxController::init_type();
+    register_type(_type_handle, "PhysxCapsuleController", 
+                  PhysxController::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 "physxCapsuleController.I"
+
+#endif // PHYSXCAPSULECONTROLLER_H

+ 59 - 0
panda/src/physx/physxCapsuleControllerDesc.I

@@ -0,0 +1,59 @@
+// Filename: physxCapsuleControllerDesc.I
+// Created by:  enn0x (22Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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: PhysxCapsuleControllerDesc::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxCapsuleControllerDesc::
+PhysxCapsuleControllerDesc() : PhysxControllerDesc() {
+
+  _desc.upDirection = (NxHeightFieldAxis)physx_up_axis.get_value();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleControllerDesc::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxCapsuleControllerDesc::
+~PhysxCapsuleControllerDesc() {
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleControllerDesc::set_to_default
+//       Access: Published
+//  Description: (re)sets the structure to the default.
+////////////////////////////////////////////////////////////////////
+INLINE void PhysxCapsuleControllerDesc::
+set_to_default() {
+
+  _desc.setToDefault();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleControllerDesc::is_valid
+//       Access: Published
+//  Description: Returns true if the descriptor is valid.
+////////////////////////////////////////////////////////////////////
+INLINE bool PhysxCapsuleControllerDesc::
+is_valid() const {
+
+  return _desc.isValid();
+}
+

+ 64 - 0
panda/src/physx/physxCapsuleControllerDesc.cxx

@@ -0,0 +1,64 @@
+// Filename: physxCapsuleControllerDesc.cxx
+// Created by:  enn0x (22Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxCapsuleControllerDesc.h"
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleControllerDesc::set_radius
+//       Access: Published
+//  Description: Sets the radius of the capsule's hemispherical
+//               ends and its trunk.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleControllerDesc::
+set_radius(float radius) {
+
+  _desc.radius = radius;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleControllerDesc::set_height
+//       Access: Published
+//  Description: Sets the distance between the two hemispherical
+//               ends of the capsule.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleControllerDesc::
+set_height(float height) {
+
+  _desc.height = height;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleControllerDesc::get_radius
+//       Access: Published
+//  Description: The radius of the capsule's hemispherical ends
+//               and its trunk.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsuleControllerDesc::
+get_radius() const {
+
+  return _desc.radius;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleControllerDesc::get_height
+//       Access: Published
+//  Description: The distance between the two hemispherical ends
+//               of the capsule.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsuleControllerDesc::
+get_height() const {
+
+  return _desc.height;
+}
+

+ 50 - 0
panda/src/physx/physxCapsuleControllerDesc.h

@@ -0,0 +1,50 @@
+// Filename: physxCapsuleControllerDesc.h
+// Created by:  enn0x (22Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXCAPSULECONTROLLERDESC_H
+#define PHYSXCAPSULECONTROLLERDESC_H
+
+#include "pandabase.h"
+
+#include "physxControllerDesc.h"
+
+#include "NxCapsuleController.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxCapsuleControllerDesc
+// Description : Descriptor class for PhysxCapsuleController.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxCapsuleControllerDesc : public PhysxControllerDesc {
+
+PUBLISHED:
+  INLINE PhysxCapsuleControllerDesc();
+  INLINE ~PhysxCapsuleControllerDesc();
+
+  INLINE void set_to_default();
+  INLINE bool is_valid() const;
+
+  void set_radius(float radius);
+  void set_height(float height);
+
+  float get_radius() const;
+  float get_height() const;
+
+public:
+  NxControllerDesc *ptr() const { return (NxControllerDesc *)&_desc; };
+  NxCapsuleControllerDesc _desc;
+};
+
+#include "physxCapsuleControllerDesc.I"
+
+#endif // PHYSXCAPSULECONTROLLERDESC_H

+ 36 - 0
panda/src/physx/physxCapsuleForceFieldShape.I

@@ -0,0 +1,36 @@
+// Filename: physxCapsuleForceFieldShape.I
+// Created by:  enn0x (15Nov09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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: PhysxCapsuleForceFieldShape::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxCapsuleForceFieldShape::
+PhysxCapsuleForceFieldShape() : PhysxForceFieldShape() {
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShape::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxCapsuleForceFieldShape::
+~PhysxCapsuleForceFieldShape() {
+
+}
+

+ 111 - 0
panda/src/physx/physxCapsuleForceFieldShape.cxx

@@ -0,0 +1,111 @@
+// Filename: physxCapsuleForceFieldShape.cxx
+// Created by:  enn0x (15Nov09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxCapsuleForceFieldShape.h"
+#include "physxCapsuleForceFieldShapeDesc.h"
+
+TypeHandle PhysxCapsuleForceFieldShape::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShape::link
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleForceFieldShape::
+link(NxForceFieldShape *shapePtr) {
+
+  _ptr = shapePtr->isCapsule();
+  _ptr->userData = this;
+  _error_type = ET_ok;
+
+  PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData;
+  group->_shapes.add(this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShape::unlink
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleForceFieldShape::
+unlink() {
+
+  _ptr->userData = NULL;
+  _error_type = ET_released;
+
+  PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData;
+  group->_shapes.remove(this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function : PhysxCapsuleForceFieldShape::save_to_desc
+//       Access : Published
+//  Description : Saves the state of the shape object to a 
+//                descriptor.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleForceFieldShape::
+save_to_desc(PhysxCapsuleForceFieldShapeDesc &shapeDesc) const {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->saveToDesc(shapeDesc._desc);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShape::set_radius
+//       Access: Published
+//  Description: Alters the radius of the capsule.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleForceFieldShape::
+set_radius(float radius) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setRadius(radius);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShape::set_height
+//       Access: Published
+//  Description: Alters the height of the capsule.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleForceFieldShape::
+set_height(float height) {
+
+  nassertv(_error_type == ET_ok);
+  _ptr->setHeight(height);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShape::get_radius
+//       Access: Published
+//  Description: Retrieves the radius of the capsule.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsuleForceFieldShape::
+get_radius() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getRadius();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShape::get_height
+//       Access: Published
+//  Description: Retrieves the height of the capsule.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsuleForceFieldShape::
+get_height() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getHeight();
+}
+

+ 81 - 0
panda/src/physx/physxCapsuleForceFieldShape.h

@@ -0,0 +1,81 @@
+// Filename: physxCapsuleForceFieldShape.h
+// Created by:  enn0x (15Nov09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXCAPSULEFORCEFIELDSHAPE_H
+#define PHYSXCAPSULEFORCEFIELDSHAPE_H
+
+#include "pandabase.h"
+#include "lvector3.h"
+
+#include "physxForceFieldShape.h"
+
+#include "NoMinMax.h"
+#include "NxPhysics.h"
+
+class PhysxCapsuleForceFieldShapeDesc;
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxCapsuleForceFieldShape
+// Description : A capsule shaped region used to define a force
+//               field.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxCapsuleForceFieldShape : public PhysxForceFieldShape {
+
+PUBLISHED:
+  INLINE PhysxCapsuleForceFieldShape();
+  INLINE ~PhysxCapsuleForceFieldShape();
+
+  void save_to_desc(PhysxCapsuleForceFieldShapeDesc &shapeDesc) const;
+
+  void set_radius(float radius);
+  void set_height(float height);
+
+  float get_radius() const;
+  float get_height() const;
+
+////////////////////////////////////////////////////////////////////
+public:
+  INLINE NxForceFieldShape *ptr() const { return (NxForceFieldShape *)_ptr; };
+
+  void link(NxForceFieldShape *shapePtr);
+  void unlink();
+
+private:
+  NxCapsuleForceFieldShape *_ptr;
+
+////////////////////////////////////////////////////////////////////
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    PhysxForceFieldShape::init_type();
+    register_type(_type_handle, "PhysxCapsuleForceFieldShape", 
+                  PhysxForceFieldShape::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 "physxCapsuleForceFieldShape.I"
+
+#endif // PHYSXCAPSULEFORCEFIELDSHAPE_H

+ 59 - 0
panda/src/physx/physxCapsuleForceFieldShapeDesc.I

@@ -0,0 +1,59 @@
+// Filename: physxCapsuleForceFieldShapeDesc.I
+// Created by:  enn0x (06Nov09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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: PhysxCapsuleForceFieldShapeDesc::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxCapsuleForceFieldShapeDesc::
+PhysxCapsuleForceFieldShapeDesc() : PhysxForceFieldShapeDesc() {
+
+  _desc.name = "";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShapeDesc::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxCapsuleForceFieldShapeDesc::
+~PhysxCapsuleForceFieldShapeDesc() {
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShapeDesc::set_to_default
+//       Access: Published
+//  Description: (re)sets the structure to the default.
+////////////////////////////////////////////////////////////////////
+INLINE void PhysxCapsuleForceFieldShapeDesc::
+set_to_default() {
+
+  _desc.setToDefault();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShapeDesc::is_valid
+//       Access: Published
+//  Description: Returns true if the descriptor is valid.
+////////////////////////////////////////////////////////////////////
+INLINE bool PhysxCapsuleForceFieldShapeDesc::
+is_valid() const {
+
+  return _desc.isValid();
+}
+

+ 64 - 0
panda/src/physx/physxCapsuleForceFieldShapeDesc.cxx

@@ -0,0 +1,64 @@
+// Filename: physxCapsuleForceFieldShapeDesc.cxx
+// Created by:  enn0x (06Nov09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxCapsuleForceFieldShapeDesc.h"
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShapeDesc::set_radius
+//       Access: Published
+//  Description: Sets the radius of the capsule's hemispherical
+//               ends and its trunk.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleForceFieldShapeDesc::
+set_radius(float radius) {
+
+  _desc.radius = radius;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShapeDesc::set_height
+//       Access: Published
+//  Description: Sets the distance between the two hemispherical
+//               ends of the capsule.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleForceFieldShapeDesc::
+set_height(float height) {
+
+  _desc.height = height;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShapeDesc::get_radius
+//       Access: Published
+//  Description: The radius of the capsule's hemispherical ends
+//               and its trunk.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsuleForceFieldShapeDesc::
+get_radius() const {
+
+  return _desc.radius;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleForceFieldShapeDesc::get_height
+//       Access: Published
+//  Description: The distance between the two hemispherical ends
+//               of the capsule.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsuleForceFieldShapeDesc::
+get_height() const {
+
+  return _desc.height;
+}
+

+ 51 - 0
panda/src/physx/physxCapsuleForceFieldShapeDesc.h

@@ -0,0 +1,51 @@
+// Filename: physxCapsuleForceFieldShapeDesc.h
+// Created by:  enn0x (06Nov09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXCAPSULEFORCEFIELDSHAPEDESC_H
+#define PHYSXCAPSULEFORCEFIELDSHAPEDESC_H
+
+#include "pandabase.h"
+
+#include "physxForceFieldShapeDesc.h"
+
+#include "NoMinMax.h"
+#include "NxPhysics.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxCapsuleForceFieldShapeDesc
+// Description : Descriptor for a capsule force field shape.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxCapsuleForceFieldShapeDesc : public PhysxForceFieldShapeDesc {
+
+PUBLISHED:
+  INLINE PhysxCapsuleForceFieldShapeDesc();
+  INLINE ~PhysxCapsuleForceFieldShapeDesc();
+
+  INLINE void set_to_default();
+  INLINE bool is_valid() const;
+
+  void set_radius(float radius);
+  void set_height(float height);
+
+  float get_radius() const;
+  float get_height() const;
+
+public:
+  NxForceFieldShapeDesc *ptr() const { return (NxForceFieldShapeDesc *)&_desc; };
+  NxCapsuleForceFieldShapeDesc _desc;
+};
+
+#include "physxCapsuleForceFieldShapeDesc.I"
+
+#endif // PHYSXCAPSULEFORCEFIELDSHAPEDESC_H

+ 23 - 1
panda/src/physx/physxCapsuleShape.I

@@ -1,5 +1,5 @@
 // Filename: physxCapsuleShape.I
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (16Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,3 +12,25 @@
 //
 ////////////////////////////////////////////////////////////////////
 
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleShape::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxCapsuleShape::
+PhysxCapsuleShape() : PhysxShape() {
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleShape::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxCapsuleShape::
+~PhysxCapsuleShape() {
+
+}
+

+ 54 - 52
panda/src/physx/physxCapsuleShape.cxx

@@ -1,5 +1,5 @@
 // Filename: physxCapsuleShape.cxx
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (16Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,98 +12,100 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifdef HAVE_PHYSX
-
 #include "physxCapsuleShape.h"
-
-#include "physxCapsule.h"
 #include "physxCapsuleShapeDesc.h"
 
 TypeHandle PhysxCapsuleShape::_type_handle;
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_height
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsuleShape::link
+//       Access: Public
+//  Description: 
 ////////////////////////////////////////////////////////////////////
-float PhysxCapsuleShape::
-get_height() const {
-  nassertr(nCapsuleShape != NULL, -1.0f);
+void PhysxCapsuleShape::
+link(NxShape *shapePtr) {
+
+  _ptr = shapePtr->isCapsule();
+  _ptr->userData = this;
+  _error_type = ET_ok;
 
-  return nCapsuleShape->getHeight();
+  PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
+  actor->_shapes.add(this);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_radius
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsuleShape::unlink
+//       Access: Public
+//  Description: 
 ////////////////////////////////////////////////////////////////////
-float PhysxCapsuleShape::
-get_radius() const {
-  nassertr(nCapsuleShape != NULL, -1.0f);
+void PhysxCapsuleShape::
+unlink() {
 
-  return nCapsuleShape->getRadius();
+  _ptr->userData = NULL;
+  _error_type = ET_released;
+
+  PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
+  actor->_shapes.remove(this);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_world_capsule
+//     Function : PhysxCapsuleShape::save_to_desc
 //       Access : Published
-//  Description :
+//  Description : Saves the state of the shape object to a 
+//                descriptor.
 ////////////////////////////////////////////////////////////////////
 void PhysxCapsuleShape::
-get_world_capsule(PhysxCapsule & world_capsule) const {
-  nassertv(nCapsuleShape != NULL);
+save_to_desc(PhysxCapsuleShapeDesc &shapeDesc) const {
 
-  nCapsuleShape->getWorldCapsule(*(world_capsule.nCapsule));
+  nassertv(_error_type == ET_ok);
+  _ptr->saveToDesc(shapeDesc._desc);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : save_to_desc
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsuleShape::set_radius
+//       Access: Published
+//  Description: Alters the radius of the capsule.
 ////////////////////////////////////////////////////////////////////
 void PhysxCapsuleShape::
-save_to_desc(PhysxCapsuleShapeDesc & desc) const {
-  nassertv(nCapsuleShape != NULL);
+set_radius(float radius) {
 
-  nCapsuleShape->saveToDesc(desc.nCapsuleShapeDesc);
+  nassertv(_error_type == ET_ok);
+  _ptr->setRadius(radius);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_dimensions
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsuleShape::set_height
+//       Access: Published
+//  Description: Alters the height of the capsule.
 ////////////////////////////////////////////////////////////////////
 void PhysxCapsuleShape::
-set_dimensions(float radius, float height) {
-  nassertv(nCapsuleShape != NULL);
+set_height(float height) {
 
-  nCapsuleShape->setDimensions(radius, height);
+  nassertv(_error_type == ET_ok);
+  _ptr->setHeight(height);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_height
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsuleShape::get_radius
+//       Access: Published
+//  Description: Retrieves the radius of the capsule.
 ////////////////////////////////////////////////////////////////////
-void PhysxCapsuleShape::
-set_height(float height) {
-  nassertv(nCapsuleShape != NULL);
+float PhysxCapsuleShape::
+get_radius() const {
 
-  nCapsuleShape->setHeight(height);
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getRadius();
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_radius
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsuleShape::get_height
+//       Access: Published
+//  Description: Retrieves the height of the capsule.
 ////////////////////////////////////////////////////////////////////
-void PhysxCapsuleShape::
-set_radius(float radius) {
-  nassertv(nCapsuleShape != NULL);
+float PhysxCapsuleShape::
+get_height() const {
 
-  nCapsuleShape->setRadius(radius);
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _ptr->getHeight();
 }
 
-#endif // HAVE_PHYSX
-

+ 41 - 21
panda/src/physx/physxCapsuleShape.h

@@ -1,5 +1,5 @@
 // Filename: physxCapsuleShape.h
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (16Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -15,46 +15,68 @@
 #ifndef PHYSXCAPSULESHAPE_H
 #define PHYSXCAPSULESHAPE_H
 
-#ifdef HAVE_PHYSX
-
 #include "pandabase.h"
-
-#include "physx_enumerations.h"
-#include "physxManager.h"
-#include "luse.h"
+#include "lvector3.h"
 
 #include "physxShape.h"
 
-class PhysxCapsule;
-class PhysxCapsuleShapeDesc;
-
+#include "NoMinMax.h"
 #include "NxPhysics.h"
 
+class PhysxCapsuleShapeDesc;
+
 ////////////////////////////////////////////////////////////////////
 //       Class : PhysxCapsuleShape
-// Description :
+// Description : A capsule shaped collision detection primitive,
+//               also known as a line swept sphere. 'radius' is the
+//               radius of the capsule's hemispherical ends and its
+//               trunk. 'height' is the distance between the two
+//               hemispherical ends of the capsule. The height is
+//               along the capsule's Y axis. Each shape is owned by
+//               an actor that it is attached to.
+//
+//               An instance can be created by calling the
+//               createShape() method of the PhysxActor object that
+//               should own it, with a PhysxCapsuleShapeDesc object
+//               as the parameter, or by adding the shape descriptor
+//               into the PhysxActorDesc class before creating the
+//               actor.
+//
+//               The shape is deleted by calling release() on the
+//               shape itself.
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDAPHYSX PhysxCapsuleShape : public PhysxShape {
+
 PUBLISHED:
+  INLINE PhysxCapsuleShape();
+  INLINE ~PhysxCapsuleShape();
+
+  void save_to_desc(PhysxCapsuleShapeDesc &shapeDesc) const;
 
-  float get_height() const;
-  float get_radius() const;
-  void get_world_capsule(PhysxCapsule & world_capsule) const;
-  void save_to_desc(PhysxCapsuleShapeDesc & desc) const;
-  void set_dimensions(float radius, float height);
-  void set_height(float height);
   void set_radius(float radius);
+  void set_height(float height);
 
+  float get_radius() const;
+  float get_height() const;
 
+////////////////////////////////////////////////////////////////////
 public:
-  NxCapsuleShape *nCapsuleShape;
+  INLINE NxShape *ptr() const { return (NxShape *)_ptr; };
+
+  void link(NxShape *shapePtr);
+  void unlink();
 
+private:
+  NxCapsuleShape *_ptr;
+
+////////////////////////////////////////////////////////////////////
+public:
   static TypeHandle get_class_type() {
     return _type_handle;
   }
   static void init_type() {
     PhysxShape::init_type();
-    register_type(_type_handle, "PhysxCapsuleShape",
+    register_type(_type_handle, "PhysxCapsuleShape", 
                   PhysxShape::get_class_type());
   }
   virtual TypeHandle get_type() const {
@@ -71,6 +93,4 @@ private:
 
 #include "physxCapsuleShape.I"
 
-#endif // HAVE_PHYSX
-
 #endif // PHYSXCAPSULESHAPE_H

+ 25 - 60
panda/src/physx/physxCapsuleShapeDesc.I

@@ -1,5 +1,5 @@
 // Filename: physxCapsuleShapeDesc.I
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (11Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,83 +12,48 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-////////////////////////////////////////////////////////////////////
-//     Function : is_valid
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE bool PhysxCapsuleShapeDesc::
-is_valid() const {
-  return nCapsuleShapeDesc.isValid();
-}
 
-////////////////////////////////////////////////////////////////////
-//     Function : set_to_default
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxCapsuleShapeDesc::
-set_to_default() {
-  nCapsuleShapeDesc.setToDefault();
-}
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_flags
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsuleShapeDesc::Constructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE unsigned int PhysxCapsuleShapeDesc::
-get_flags() const {
-  return nCapsuleShapeDesc.flags;
-}
+INLINE PhysxCapsuleShapeDesc::
+PhysxCapsuleShapeDesc() : PhysxShapeDesc() {
 
-////////////////////////////////////////////////////////////////////
-//     Function : get_height
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE float PhysxCapsuleShapeDesc::
-get_height() const {
-  return nCapsuleShapeDesc.height;
+  _desc.name = "";
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : get_radius
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsuleShapeDesc::Destructor
+//       Access: Published
+//  Description:
 ////////////////////////////////////////////////////////////////////
-INLINE float PhysxCapsuleShapeDesc::
-get_radius() const {
-  return nCapsuleShapeDesc.radius;
-}
+INLINE PhysxCapsuleShapeDesc::
+~PhysxCapsuleShapeDesc() {
 
-////////////////////////////////////////////////////////////////////
-//     Function : set_flags
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-INLINE void PhysxCapsuleShapeDesc::
-set_flags(unsigned int value) {
-  nCapsuleShapeDesc.flags = value;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_height
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsuleShapeDesc::set_to_default
+//       Access: Published
+//  Description: (re)sets the structure to the default.
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysxCapsuleShapeDesc::
-set_height(float value) {
-  nCapsuleShapeDesc.height = value;
+set_to_default() {
+
+  _desc.setToDefault();
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function : set_radius
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsuleShapeDesc::is_valid
+//       Access: Published
+//  Description: Returns true if the descriptor is valid.
 ////////////////////////////////////////////////////////////////////
-INLINE void PhysxCapsuleShapeDesc::
-set_radius(float value) {
-  nCapsuleShapeDesc.radius = value;
+INLINE bool PhysxCapsuleShapeDesc::
+is_valid() const {
+
+  return _desc.isValid();
 }
 

+ 41 - 10
panda/src/physx/physxCapsuleShapeDesc.cxx

@@ -1,5 +1,5 @@
 // Filename: physxCapsuleShapeDesc.cxx
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (11Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,22 +12,53 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifdef HAVE_PHYSX
-
 #include "physxCapsuleShapeDesc.h"
 
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleShapeDesc::set_radius
+//       Access: Published
+//  Description: Sets the radius of the capsule's hemispherical
+//               ends and its trunk.
+////////////////////////////////////////////////////////////////////
+void PhysxCapsuleShapeDesc::
+set_radius(float radius) {
 
+  _desc.radius = radius;
+}
 
 ////////////////////////////////////////////////////////////////////
-//     Function : PhysxCapsuleShapeDesc
-//       Access : Published
-//  Description :
+//     Function: PhysxCapsuleShapeDesc::set_height
+//       Access: Published
+//  Description: Sets the distance between the two hemispherical
+//               ends of the capsule.
 ////////////////////////////////////////////////////////////////////
-PhysxCapsuleShapeDesc::
-PhysxCapsuleShapeDesc()
-: PhysxShapeDesc( &nCapsuleShapeDesc ) {
+void PhysxCapsuleShapeDesc::
+set_height(float height) {
 
+  _desc.height = height;
 }
 
-#endif // HAVE_PHYSX
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleShapeDesc::get_radius
+//       Access: Published
+//  Description: The radius of the capsule's hemispherical ends
+//               and its trunk.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsuleShapeDesc::
+get_radius() const {
+
+  return _desc.radius;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxCapsuleShapeDesc::get_height
+//       Access: Published
+//  Description: The distance between the two hemispherical ends
+//               of the capsule.
+////////////////////////////////////////////////////////////////////
+float PhysxCapsuleShapeDesc::
+get_height() const {
+
+  return _desc.height;
+}
 

+ 13 - 19
panda/src/physx/physxCapsuleShapeDesc.h

@@ -1,5 +1,5 @@
 // Filename: physxCapsuleShapeDesc.h
-// Created by:  pratt (Apr 7, 2006)
+// Created by:  enn0x (11Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -15,43 +15,37 @@
 #ifndef PHYSXCAPSULESHAPEDESC_H
 #define PHYSXCAPSULESHAPEDESC_H
 
-#ifdef HAVE_PHYSX
-
 #include "pandabase.h"
 
-#include "physx_enumerations.h"
-#include "physxManager.h"
-#include "luse.h"
-
 #include "physxShapeDesc.h"
 
+#include "NoMinMax.h"
 #include "NxPhysics.h"
 
 ////////////////////////////////////////////////////////////////////
 //       Class : PhysxCapsuleShapeDesc
-// Description :
+// Description : Descriptor class for PhysxCapsuleShape.
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDAPHYSX PhysxCapsuleShapeDesc : public PhysxShapeDesc {
+
 PUBLISHED:
-  PhysxCapsuleShapeDesc();
+  INLINE PhysxCapsuleShapeDesc();
+  INLINE ~PhysxCapsuleShapeDesc();
 
-  INLINE bool is_valid() const;
   INLINE void set_to_default();
+  INLINE bool is_valid() const;
 
-  INLINE unsigned int get_flags() const;
-  INLINE float get_height() const;
-  INLINE float get_radius() const;
+  void set_radius(float radius);
+  void set_height(float height);
 
-  INLINE void set_flags( unsigned int value );
-  INLINE void set_height( float value );
-  INLINE void set_radius( float value );
+  float get_radius() const;
+  float get_height() const;
 
 public:
-  NxCapsuleShapeDesc nCapsuleShapeDesc;
+  NxShapeDesc *ptr() const { return (NxShapeDesc *)&_desc; };
+  NxCapsuleShapeDesc _desc;
 };
 
 #include "physxCapsuleShapeDesc.I"
 
-#endif // HAVE_PHYSX
-
 #endif // PHYSXCAPSULESHAPEDESC_H

+ 57 - 0
panda/src/physx/physxConstraintDominance.I

@@ -0,0 +1,57 @@
+// Filename: physxConstraintDominance.I
+// Created by:  enn0x (22Dec09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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: PhysxConstraintDominance::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxConstraintDominance::
+PhysxConstraintDominance(float d0, float d1) : _dominance(d0, d1) {
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxConstraintDominance::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxConstraintDominance::
+~PhysxConstraintDominance() {
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxConstraintDominance::get_dominance
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE NxConstraintDominance PhysxConstraintDominance::
+get_dominance() const {
+
+  return _dominance;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxConstraintDominance::set_dominance
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void PhysxConstraintDominance::
+set_dominance(NxConstraintDominance value) {
+
+  _dominance = value;
+}
+

+ 60 - 0
panda/src/physx/physxConstraintDominance.cxx

@@ -0,0 +1,60 @@
+// Filename: physxConstraintDominance.cxx
+// Created by:  enn0x (22Dec09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxConstraintDominance.h"
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxConstraintDominance::get_0
+//       Access: Published
+//  Description: Retruns the first dominance factor.
+////////////////////////////////////////////////////////////////////
+float PhysxConstraintDominance::
+get_0() const {
+
+  return _dominance.dominance0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxConstraintDominance::get_1
+//       Access: Published
+//  Description: Returns the second dominance factor.
+////////////////////////////////////////////////////////////////////
+float PhysxConstraintDominance::
+get_1() const {
+
+  return _dominance.dominance1;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxConstraintDominance::set_0
+//       Access: Published
+//  Description: Sets the first dominance factor.
+////////////////////////////////////////////////////////////////////
+void PhysxConstraintDominance::
+set_0(float d0) {
+
+  _dominance.dominance0 = d0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxConstraintDominance::set_1
+//       Access: Published
+//  Description: Sets the second dominance factor.
+////////////////////////////////////////////////////////////////////
+void PhysxConstraintDominance::
+set_1(float d1) {
+
+  _dominance.dominance1 = d1;
+}
+

+ 57 - 0
panda/src/physx/physxConstraintDominance.h

@@ -0,0 +1,57 @@
+// Filename: physxConstraintDominance.h
+// Created by:  enn0x (22Dec09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXCONSTRAINTDOMINANCE_H
+#define PHYSXCONSTRAINTDOMINANCE_H
+
+#include "pandabase.h"
+#include "lvector3.h"
+#include "lpoint3.h"
+
+#include "config_physx.h"
+
+class PhysxShape;
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxConstraintDominance
+// Description : Expresses the dominance relationship of a
+//               constraint. For the time being only three settings
+//               are permitted:. (1.0f, 1.0f), (0.0f, 1.0f), and
+//               (1.0f, 0.0f). 
+//
+//               See PhysxScene::set_dominance_group_pair for a
+//               detailed explanation of dominance behaviour.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxConstraintDominance {
+
+PUBLISHED:
+  INLINE PhysxConstraintDominance(float d0, float d1);
+  INLINE ~PhysxConstraintDominance();
+
+  float get_0() const;
+  float get_1() const;
+  void set_0(float d0);
+  void set_1(float d1);
+
+public:
+  INLINE void set_dominance(NxConstraintDominance value);
+  INLINE NxConstraintDominance get_dominance() const;
+
+private:
+  NxConstraintDominance _dominance;
+};
+
+#include "physxConstraintDominance.I"
+
+#endif // PHYSXCONSTRAINTDOMINANCE_H

+ 0 - 129
panda/src/physx/physxContactHandler.cxx

@@ -1,129 +0,0 @@
-// Filename: physxContactHandler.cxx
-// Created by:  pratt (May 25, 2006)
-//
-////////////////////////////////////////////////////////////////////
-//
-// 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."
-//
-////////////////////////////////////////////////////////////////////
-
-#ifdef HAVE_PHYSX
-
-#include "physxContactHandler.h"
-
-#include "eventParameter.h"
-#include "eventStorePandaNode.h"
-#include "throw_event.h"
-
-////////////////////////////////////////////////////////////////////
-//     Function : PhysxContactHandler
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-PhysxContactHandler::
-PhysxContactHandler() {
-  threshold = 0.01f;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : clear_events
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxContactHandler::
-clear_events() {
-  events.clear();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : throw_events
-//       Access : Published
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxContactHandler::
-throw_events() {
-  pvector<PhysxContactEvent>::const_iterator events_iter;
-  PhysxContactEvent event;
-  string on_start_name = "physxOnContactStart";
-  string on_end_name = "physxOnContactEnd";
-  string on_touch_name = "physxOnContactTouch";
-  for(events_iter = events.begin(); events_iter != events.end(); ++events_iter) {
-    event = *events_iter;
-    Event *ev = NULL;
-    if(event.flags & NX_NOTIFY_ON_START_TOUCH) {
-      ev = new Event(on_start_name);
-    } else if(event.flags & NX_NOTIFY_ON_END_TOUCH) {
-      ev = new Event(on_end_name);
-    } else if(event.flags & NX_NOTIFY_ON_TOUCH) {
-      ev = new Event(on_touch_name);
-    }
-    if(ev != NULL) {
-      PT(PhysxActorNode) pActorNode1 = (PhysxActorNode *)event.nActor1->userData;
-      PT(PhysxActorNode) pActorNode2 = (PhysxActorNode *)event.nActor2->userData;
-      ev->add_parameter(EventParameter(new EventStorePandaNode(pActorNode1)));
-      ev->add_parameter(EventParameter(new EventStorePandaNode(pActorNode2)));
-      ev->add_parameter(EventParameter(event.sumNormalForce.x));
-      ev->add_parameter(EventParameter(event.sumNormalForce.y));
-      ev->add_parameter(EventParameter(event.sumNormalForce.z));
-      ev->add_parameter(EventParameter(event.sumFrictionForce.x));
-      ev->add_parameter(EventParameter(event.sumFrictionForce.y));
-      ev->add_parameter(EventParameter(event.sumFrictionForce.z));
-      EventQueue::get_global_event_queue()->queue_event(ev);
-    }
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : set_threshold
-//       Access : Published
-//  Description : Contacts will only be reported if the magnitude
-//                of the normal force squared is greater than this
-//                threshold value.
-//                Default: 0.01
-////////////////////////////////////////////////////////////////////
-void PhysxContactHandler::
-set_threshold( float value ) {
-  threshold = value;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : get_threshold
-//       Access : Published
-//  Description : Contacts will only be reported if the magnitude
-//                of the normal force squared is greater than this
-//                threshold value.
-//                Default: 0.01
-////////////////////////////////////////////////////////////////////
-float PhysxContactHandler::
-get_threshold() {
-  return threshold;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function : onContactNotify
-//       Access : public
-//  Description :
-////////////////////////////////////////////////////////////////////
-void PhysxContactHandler::
-onContactNotify(NxContactPair &pair, NxU32 flags) {
-  if(pair.sumNormalForce.magnitudeSquared() >= threshold) {
-    PhysxContactEvent event;
-    event.nActor1 = pair.actors[0];
-    event.nActor2 = pair.actors[1];
-//    PhysxActorNode *pActorNode1 = (PhysxActorNode *)pair.actors[0]->userData;
-//    PhysxActorNode *pActorNode2 = (PhysxActorNode *)pair.actors[1]->userData;
-//    event.actorName1 = pActorNode1->get_name();
-//    event.actorName2 = pActorNode2->get_name();
-    event.sumNormalForce = pair.sumNormalForce;
-    event.sumFrictionForce = pair.sumFrictionForce;
-    event.flags = flags;
-    events.push_back(event);
-  }
-}
-
-#endif // HAVE_PHYSX

+ 0 - 67
panda/src/physx/physxContactHandler.h

@@ -1,67 +0,0 @@
-// Filename: physxContactHandler.h
-// Created by:  pratt (May 25, 2006)
-//
-////////////////////////////////////////////////////////////////////
-//
-// 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 PHYSXCONTACTHANDLER_H
-#define PHYSXCONTACTHANDLER_H
-
-#ifdef HAVE_PHYSX
-
-#include "pandabase.h"
-#include "pvector.h"
-
-#include "physx_enumerations.h"
-#include "physxManager.h"
-#include "luse.h"
-
-class PhysxShape;
-
-#include "NxPhysics.h"
-
-////////////////////////////////////////////////////////////////////
-//       Class : PhysxContactHandler
-// Description :
-////////////////////////////////////////////////////////////////////
-class EXPCL_PANDAPHYSX PhysxContactHandler : public NxUserContactReport {
-PUBLISHED:
-  PhysxContactHandler();
-
-  void clear_events();
-  void throw_events();
-
-  void set_threshold(float value);
-  float get_threshold();
-
-public:
-  void onContactNotify(NxContactPair& pair, NxU32 flags);
-
-private:
-  float threshold;
-  struct PhysxContactEvent {
-    NxActor *nActor1;
-    NxActor *nActor2;
-//    string actorName1;
-//    string actorName2;
-    NxVec3 sumNormalForce;
-    NxVec3 sumFrictionForce;
-    NxU32 flags;
-  };
-
-  pvector<PhysxContactEvent> events;
-};
-
-#include "physxContactHandler.I"
-
-#endif // HAVE_PHYSX
-
-#endif // PHYSXCONTACTHANDLER_H

+ 36 - 0
panda/src/physx/physxContactPair.I

@@ -0,0 +1,36 @@
+// Filename: physxContactPair.I
+// Created by:  enn0x (19Dec09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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: PhysxContactPair::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxContactPair::
+PhysxContactPair(const NxContactPair pair) {
+
+  _pair = pair;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPair::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxContactPair::
+~PhysxContactPair() {
+
+}
+

+ 129 - 0
panda/src/physx/physxContactPair.cxx

@@ -0,0 +1,129 @@
+// Filename: physxContactPair.cxx
+// Created by:  enn0x (19Dec09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxContactPair.h"
+#include "physxManager.h"
+#include "physxActor.h"
+#include "physxContactPoint.h"
+
+TypeHandle PhysxContactPair::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPair::get_actor_a
+//       Access: Published
+//  Description: Returns the first of the two actors that makes up
+//               this pair.
+////////////////////////////////////////////////////////////////////
+PT(PhysxActor) PhysxContactPair::
+get_actor_a() const {
+
+  NxActor *actorPtr = _pair.actors[0];
+  return (actorPtr == NULL) ? NULL : (PhysxActor *)actorPtr->userData;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPair::get_actor_b
+//       Access: Published
+//  Description: Returns the second of the two actors that make up
+//               his pair.
+////////////////////////////////////////////////////////////////////
+PT(PhysxActor) PhysxContactPair::
+get_actor_b() const {
+
+  NxActor *actorPtr = _pair.actors[1];
+  return (actorPtr == NULL) ? NULL : (PhysxActor *)actorPtr->userData;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPair::get_sum_normal_force
+//       Access: Published
+//  Description: Returns the total contact normal force that was
+//               applied for this pair, to maintain nonpenetration
+//               constraints.
+//
+//               You should set the ContactPairFlag 
+//               CPF_notify_forces in order to receive this value.
+//
+//               @see PhysxScene::set_actor_pair_flag
+//               @see PhysxScene::set_actor_group_pair_flag
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxContactPair::
+get_sum_normal_force() const {
+
+  return PhysxManager::nxVec3_to_vec3(_pair.sumNormalForce);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPair::get_sum_friction_force
+//       Access: Published
+//  Description: Returns the total tangential force that was applied
+//               for this pair.
+//
+//               You should set the ContactPairFlag 
+//               CPF_notify_forces in order to receive this value.
+//
+//               @see PhysxScene::set_actor_pair_flag
+//               @see PhysxScene::set_actor_group_pair_flag
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxContactPair::
+get_sum_friction_force() const {
+
+  return PhysxManager::nxVec3_to_vec3(_pair.sumFrictionForce);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPair::get_num_contact_points
+//       Access: Published
+//  Description: Returns the total number of contact points reported
+//               in this pair's contact stream.
+//
+//               This method is a helper for iterating over the
+//               pair's contact stream.
+////////////////////////////////////////////////////////////////////
+unsigned int PhysxContactPair::
+get_num_contact_points() {
+
+  if (_contacts.size() == 0) {
+    NxContactStreamIterator it(_pair.stream);
+    while(it.goNextPair()) {
+      while(it.goNextPatch()) {
+        while(it.goNextPoint()) {
+          PhysxContactPoint cp;
+          cp.set(it);
+          _contacts.push_back(cp);
+        }
+      }
+    }
+  }
+
+  return _contacts.size();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPair::get_contact_point
+//       Access: Published
+//  Description: Returns an instance of PhysxContactPoint, which
+//               represents a single entry of this pair's contact
+//               stream.
+//
+//               This method is a helper for iterating over the
+//               pair's contact stream.
+////////////////////////////////////////////////////////////////////
+PhysxContactPoint PhysxContactPair::
+get_contact_point(unsigned int idx) const {
+
+  nassertr(idx < _contacts.size(), PhysxContactPoint::empty());
+  return _contacts[idx];
+}
+

+ 79 - 0
panda/src/physx/physxContactPair.h

@@ -0,0 +1,79 @@
+// Filename: physxContactPair.h
+// Created by:  enn0x (19Dec09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXCONTACTPAIR_H
+#define PHYSXCONTACTPAIR_H
+
+#include "pandabase.h"
+#include "lvector3.h"
+#include "typedReferenceCount.h"
+#include "pvector.h"
+
+#include "config_physx.h"
+
+class PhysxShape;
+class PhysxContactPoint;
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxContactPair
+// Description : An instance of this class is send with contact
+//               reporting events. It contains detailed information
+//               on the contact.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxContactPair : public TypedReferenceCount {
+
+PUBLISHED:
+  INLINE ~PhysxContactPair();
+
+  PT(PhysxActor) get_actor_a() const;
+  PT(PhysxActor) get_actor_b() const;
+  LVector3f get_sum_normal_force() const;
+  LVector3f get_sum_friction_force() const;
+
+  unsigned int get_num_contact_points();
+  PhysxContactPoint get_contact_point(unsigned int idx) const;
+  MAKE_SEQ(get_contact_points, get_num_contact_points, get_contact_point);
+
+public:
+  INLINE PhysxContactPair(const NxContactPair pair);
+
+private:
+  NxContactPair _pair;
+  pvector<PhysxContactPoint> _contacts;
+
+////////////////////////////////////////////////////////////////////
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    TypedReferenceCount::init_type();
+    register_type(_type_handle, "PhysxContactPair", 
+                  TypedReferenceCount::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 "physxContactPair.I"
+
+#endif // PHYSXCONTACTPAIR_H

+ 36 - 0
panda/src/physx/physxContactPoint.I

@@ -0,0 +1,36 @@
+// Filename: physxContactPoint.I
+// Created by:  enn0x (20Dec09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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: PhysxContactPoint::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxContactPoint::
+PhysxContactPoint() {
+
+  //_hit = hit;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPoint::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxContactPoint::
+~PhysxContactPoint() {
+
+}
+

+ 114 - 0
panda/src/physx/physxContactPoint.cxx

@@ -0,0 +1,114 @@
+// Filename: physxContactPoint.cxx
+// Created by:  enn0x (20Dec09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxContactPoint.h"
+#include "physxManager.h"
+#include "physxShape.h"
+
+TypeHandle PhysxContactPoint::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPoint::set
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxContactPoint::
+set(NxContactStreamIterator it) {
+
+  _point = it.getPoint();
+  _normal = it.getPatchNormal();
+  _normal_force = it.getPointNormalForce();
+  _separation = it.getSeparation();
+  _feature_index0 = it.getFeatureIndex0();
+  _feature_index1 = it.getFeatureIndex1();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPoint::empty
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+PhysxContactPoint PhysxContactPoint::
+empty() {
+
+  return PhysxContactPoint();
+}
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPoint::get_point
+//       Access: Published
+//  Description: Returns the contact point position.
+////////////////////////////////////////////////////////////////////
+LPoint3f PhysxContactPoint::
+get_point() const {
+
+  return PhysxManager::nxVec3_to_point3(_point);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPoint::get_normal
+//       Access: Published
+//  Description: Retrieves the patch normal.
+////////////////////////////////////////////////////////////////////
+LVector3f PhysxContactPoint::
+get_normal() const {
+
+  return PhysxManager::nxVec3_to_vec3(_normal);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPoint::get_normal_force
+//       Access: Published
+//  Description: Retrieves the point normal force.
+////////////////////////////////////////////////////////////////////
+float PhysxContactPoint::
+get_normal_force() const {
+
+  return _normal_force;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPoint::get_separation
+//       Access: Published
+//  Description: Return the separation for the contact point.
+////////////////////////////////////////////////////////////////////
+float PhysxContactPoint::
+get_separation() const {
+
+  return _separation;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPoint::get_feature_index0
+//       Access: Published
+//  Description: Retrieves the feature index.
+////////////////////////////////////////////////////////////////////
+unsigned int PhysxContactPoint::
+get_feature_index0() const {
+
+  return _feature_index0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactPoint::get_feature_index1
+//       Access: Published
+//  Description: Retrieves the feature index.
+////////////////////////////////////////////////////////////////////
+unsigned int PhysxContactPoint::
+get_feature_index1() const {
+
+  return _feature_index1;
+}
+

+ 82 - 0
panda/src/physx/physxContactPoint.h

@@ -0,0 +1,82 @@
+// Filename: physxContactPoint.h
+// Created by:  enn0x (20Dec09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXCONTACTPOINT_H
+#define PHYSXCONTACTPOINT_H
+
+#include "pandabase.h"
+#include "lvector3.h"
+#include "lpoint3.h"
+#include "typedObject.h"
+
+#include "config_physx.h"
+
+class PhysxShape;
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxContactPoint
+// Description : A helper structure for iterating over contact
+//               streams reported by PhysxContactPair.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxContactPoint : public TypedObject {
+
+PUBLISHED:
+  INLINE PhysxContactPoint();
+  INLINE ~PhysxContactPoint();
+
+  LPoint3f get_point() const;
+  LVector3f get_normal() const;
+  float get_normal_force() const;
+  float get_separation() const;
+  unsigned int get_feature_index0() const;
+  unsigned int get_feature_index1() const;
+
+public:
+  static PhysxContactPoint empty();
+
+  void set(NxContactStreamIterator it);
+
+private:
+  NxVec3 _point;
+  NxVec3 _normal;
+  NxReal _normal_force;
+  NxReal _separation;
+  NxU32 _feature_index0;
+  NxU32 _feature_index1;
+
+////////////////////////////////////////////////////////////////////
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    TypedReferenceCount::init_type();
+    register_type(_type_handle, "PhysxContactPoint", 
+                  TypedReferenceCount::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 "physxContactPoint.I"
+
+#endif // PHYSXCONTACTPOINT_H

+ 36 - 0
panda/src/physx/physxContactReport.I

@@ -0,0 +1,36 @@
+// Filename: physxContactReport.I
+// Created by:  enn0x (19Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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: PhysxContactReport::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxContactReport::
+PhysxContactReport() : NxUserContactReport() {
+
+  _enabled = false;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactReport::Destructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxContactReport::
+~PhysxContactReport() {
+
+}
+

+ 101 - 0
panda/src/physx/physxContactReport.cxx

@@ -0,0 +1,101 @@
+// Filename: physxContactReport.cxx
+// Created by:  enn0x (19Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxContactReport.h"
+#include "physxContactPair.h"
+#include "physxManager.h"
+
+#include "event.h"
+#include "eventQueue.h"
+#include "eventParameter.h"
+
+PStatCollector PhysxContactReport::_pcollector("App:PhysX:Contact Reporting");
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactReport::enable
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+void PhysxContactReport::
+enable() {
+
+  _enabled = true;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactReport::disable
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+void PhysxContactReport::
+disable() {
+
+  _enabled = false;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactReport::is_enabled
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+bool PhysxContactReport::
+is_enabled() const {
+
+  return _enabled;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxContactReport::onContactNotify
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+void PhysxContactReport::
+onContactNotify(NxContactPair &pair, NxU32 flags) {
+
+  if (!_enabled) {
+    return;
+  }
+
+  _pcollector.start();
+
+  Event *event;
+  if (flags & NX_NOTIFY_ON_START_TOUCH) {
+    event = new Event("physx-contact-start");
+  }
+  else if (flags & NX_NOTIFY_ON_END_TOUCH) {
+    event = new Event("physx-contact-stop");
+  }
+  else if (flags & NX_NOTIFY_ON_TOUCH) {
+    event = new Event("physx-contact-touch");
+  }
+  else if (flags & NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD) {
+    event = new Event("physx-contact-start-force-threshold");
+  }
+  else if (flags & NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD) {
+    event = new Event("physx-contact-stop-force-threshold");
+  }
+  else if (flags & NX_NOTIFY_ON_TOUCH_FORCE_THRESHOLD) {
+    event = new Event("physx-contact-touch-force-threshold");
+  }
+  else {
+    return;
+  }
+
+  PT(PhysxContactPair) ppair = new PhysxContactPair(pair);
+  event->add_parameter(EventParameter(ppair));
+  EventQueue::get_global_event_queue()->queue_event(event);
+
+  _pcollector.stop();
+}
+

+ 48 - 0
panda/src/physx/physxContactReport.h

@@ -0,0 +1,48 @@
+// Filename: physxContactReport.h
+// Created by:  enn0x (19Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXCONTACTREPORT_H
+#define PHYSXCONTACTREPORT_H
+
+#include "pandabase.h"
+#include "pStatCollector.h"
+
+#include "NoMinMax.h"
+#include "NxPhysics.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxContactReport
+// Description : Implementation of the NxUserContactReport
+//               interface.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxContactReport : public NxUserContactReport {
+
+public:
+  INLINE PhysxContactReport();
+  INLINE ~PhysxContactReport();
+
+  void enable();
+  void disable();
+  bool is_enabled() const;
+
+  void onContactNotify(NxContactPair& pair, NxU32 flags);
+
+private:
+  bool _enabled;
+  static PStatCollector _pcollector;
+};
+
+#include "physxContactReport.I"
+
+#endif // PHYSXCONTACTREPORT_H

+ 79 - 0
panda/src/physx/physxController.I

@@ -0,0 +1,79 @@
+// Filename: physxController.I
+// Created by:  enn0x (24Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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: PhysxController::Constructor
+//       Access: Protected
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxController::
+PhysxController() : PhysxObject() {
+
+  _speed = NxVec3(0.0f, 0.0f, 0.0f);
+  _omega = 0.0f;
+  _heading = 0.0f;
+
+  _jumping = false;
+  _jump_time = 0.0f;
+  _jump_v0 = 0.0f;
+
+  _sharpness = 1.0f;
+  _min_dist = 0.0001f;
+
+  _up_vector = NxVec3(0.0f, 1.0f, 0.0f);
+  _up_axis = (NxHeightFieldAxis)physx_up_axis.get_value();
+
+  switch (_up_axis) {
+  case NX_Z:
+    _up_quat = NxQuat(90.0f, NxVec3(1.0f, 0.0f, 0.0f));
+    break;
+  case NX_Y:
+    _up_quat = NxQuat(0.0f, NxVec3(1.0f, 0.0f, 0.0f));
+    break;
+  default:
+    physx_cat.error() << "only y-up and z-up are permitted" << endl;
+  }
+
+  _up_quat_inv = _up_quat;
+  _up_quat_inv.invert();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::ls
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+INLINE void PhysxController::
+ls() const {
+
+  ls(nout);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::ls
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+INLINE void PhysxController::
+ls(ostream &out, int indent_level) const {
+
+  indent(out, indent_level) << get_type().get_name()
+                            << " (at 0x" << this << ")";
+
+  out << " A:0x" << get_actor();
+  out << "\n";
+}
+

+ 389 - 0
panda/src/physx/physxController.cxx

@@ -0,0 +1,389 @@
+// Filename: physxController.cxx
+// Created by:  enn0x (24Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "event.h"
+#include "eventQueue.h"
+#include "eventParameter.h"
+
+#include "physxController.h"
+#include "physxManager.h"
+#include "physxActor.h"
+#include "physxBoxController.h"
+#include "physxCapsuleController.h"
+
+TypeHandle PhysxController::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::release
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+release() {
+
+  nassertv(_error_type == ET_ok);
+
+  unlink();
+  get_actor()->get_scene()->cm()->releaseController(*ptr());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::factory
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+PT(PhysxController) PhysxController::
+factory(NxControllerType controllerType) {
+
+  switch (controllerType) {
+
+  case NX_CONTROLLER_BOX:
+    return new PhysxBoxController();
+
+  case NX_CONTROLLER_CAPSULE:
+    return new PhysxCapsuleController();
+
+  }
+
+  physx_cat.error() << "Unknown controller type.\n";
+  return NULL;
+}
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::get_actor
+//       Access: Published
+//  Description: Retrieves the actor which this controller is
+//               associated with.
+////////////////////////////////////////////////////////////////////
+PT(PhysxActor) PhysxController::
+get_actor() const {
+
+  nassertr(_error_type == ET_ok, NULL);
+  return (PhysxActor *)(ptr()->getActor()->userData);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::set_pos
+//       Access: Published
+//  Description: Sets the position of the controller is global
+//               space. This can be used for initial placement or
+//               for teleporting the character.
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+set_pos(const LPoint3f &pos) {
+
+  nassertv(_error_type == ET_ok);
+  ptr()->setPosition(PhysxManager::point3_to_nxExtVec3(pos));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::get_pos
+//       Access: Published
+//  Description: Retruns the position of the controller is global
+//               space.
+////////////////////////////////////////////////////////////////////
+LPoint3f PhysxController::
+get_pos() const {
+
+  nassertr(_error_type == ET_ok, LPoint3f::zero());
+  return PhysxManager::nxExtVec3_to_point3(ptr()->getPosition());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::set_sharpness
+//       Access: Published
+//  Description: Sharpness is used to smooth motion with a feedback
+//               filter, having a value between 0 (so smooth it
+//               doesn't move) and 1 (no smoothing = unfiltered
+//               motion). Sharpness can ease the motion curve when
+//               the auto-step feature is used with boxes.
+//               Default value is 1.0.
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+set_sharpness(float sharpness) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv(sharpness > 0.0f);
+  nassertv(sharpness <= 1.0f);
+
+  _sharpness = sharpness;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::get_sharpness
+//       Access: Published
+//  Description: Returns the sharpness used to ease the motion curve
+//               when the auto-step feature is used.
+//               Default value is 1.0.
+////////////////////////////////////////////////////////////////////
+float PhysxController::
+get_sharpness() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _sharpness;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::set_collision
+//       Access: Published
+//  Description: Enable/Disable collisions for this controller and
+//               actor.
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+set_collision(bool enable) {
+
+  nassertv(_error_type == ET_ok);
+  ptr()->setCollision(enable);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::set_min_distance
+//       Access: Published
+//  Description: Sets the the minimum travelled distance to consider
+//               when moving the controller. If travelled distance
+//               is smaller, the character doesn't move. This is
+//               used to stop the recursive motion algorithm when
+//               remaining distance to travel is small. 
+//               The default value is 0.0001.
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+set_min_distance(float min_dist) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv(min_dist > 0.0f);
+
+  _min_dist = min_dist;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::set_step_offset
+//       Access: Published
+//  Description: Sets the step height/offset for the controller.
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+set_step_offset(float offset) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv(offset > 0.0f);
+
+  ptr()->setStepOffset(offset);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::set_global_speed
+//       Access: Published
+//  Description: Sets the linear speed of the controller in global
+//               space.
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+set_global_speed(const LVector3f &speed) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!speed.is_nan());
+
+  _speed = NxVec3(speed.get_x(), speed.get_y(), speed.get_z());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::set_local_speed
+//       Access: Published
+//  Description: Sets the linear speed of the controller in local
+//               coordinates.
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+set_local_speed(const LVector3f &speed) {
+
+  nassertv(_error_type == ET_ok);
+  nassertv_always(!speed.is_nan());
+
+  NodePath np = get_actor()->get_node_path();
+  nassertv(!np.is_empty());
+
+  NxQuat q = ptr()->getActor()->getGlobalOrientationQuat();
+  NxVec3 s = NxVec3(speed.get_x(), speed.get_y(), speed.get_z());
+  _speed = (q * _up_quat_inv).rot(s);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::set_omega
+//       Access: Published
+//  Description: Sets the angular velocity (degrees per second)
+//               of the controller. The angular velocity is used to
+//               compute the new heading when updating the
+//               controller.
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+set_omega(float omega) {
+
+  nassertv(_error_type == ET_ok);
+  _omega = omega;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::set_h
+//       Access: Published
+//  Description: Sets the heading of the controller is global
+//               space. Note: only heading is supported. Pitch and
+//               roll are constrained by PhysX in order to alyways
+//               keep the character upright.
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+set_h(float heading) {
+
+  nassertv(_error_type == ET_ok);
+
+  _heading = heading;
+  NxQuat q(_heading, _up_vector);
+  ptr()->getActor()->moveGlobalOrientationQuat(_up_quat * q);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::get_h
+//       Access: Published
+//  Description: Returns the heading of the controller in global
+//               space.
+////////////////////////////////////////////////////////////////////
+float PhysxController::
+get_h() const {
+
+  nassertr(_error_type == ET_ok, 0.0f);
+  return _heading;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::report_scene_changed
+//       Access: Published
+//  Description: The character controller uses caching in order to
+//               speed up collision testing, this caching can not
+//               detect when static objects have changed in the
+//               scene. You need to call this method when such
+//               changes have been made.
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+report_scene_changed() {
+
+  nassertv(_error_type == ET_ok);
+  ptr()->reportSceneChanged();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::update
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+update(float dt) {
+
+  nassertv(_error_type == ET_ok);
+
+  // Speed
+  NxU32 mask = 0xFFFFFFFF;
+  NxU32 collision_flags;
+  NxVec3 gravity;
+
+  ptr()->getActor()->getScene().getGravity(gravity);
+
+  NxVec3 d = (_speed + gravity) * dt;
+
+  NxReal heightDelta = get_jump_height(dt, gravity);
+  if (heightDelta != 0.0f) {
+    ((_up_axis == NX_Z) ? d.z : d.y) += heightDelta;
+  }
+
+  ptr()->move(d, mask, _min_dist, collision_flags, _sharpness);
+
+  if (collision_flags & NXCC_COLLISION_DOWN) {
+    stop_jump();
+  }
+
+  // Omega
+  if (_omega != 0.0f) {
+    NxReal delta = _omega * dt;
+    _heading += delta;
+    NxQuat q(_heading, _up_vector);
+    ptr()->getActor()->moveGlobalOrientationQuat(_up_quat * q);
+  }
+
+  // Reset speed and omega
+  _speed.zero();
+  _omega = 0.0f;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::get_jump_height
+//       Access: Private
+//  Description: 
+////////////////////////////////////////////////////////////////////
+NxReal PhysxController::
+get_jump_height(float dt, NxVec3 &gravity) {
+
+  if (_jumping == false) {
+    return 0.0f;
+  }
+
+  _jump_time += dt;
+
+  float G = (_up_axis == NX_Z) ? gravity.z : gravity.y;
+  float h = 2.0f * G * _jump_time * _jump_time + _jump_v0 * _jump_time;
+  return (h - G) * dt;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::start_jump
+//       Access: Published
+//  Description: Enters the jump mode. The parameter is the intial
+//               upward velocity of the character.
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+start_jump(float v0) {
+
+  nassertv(_error_type == ET_ok);
+
+  if (_jumping == true) {
+     return;
+  }
+
+  _jumping = true;
+  _jump_time = 0.0f;
+  _jump_v0 = v0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxController::stop_jump
+//       Access: Published
+//  Description: Leaves the jump mode. This method is automatically
+//               called if a ground collision is detected. Usually
+//               users need not call this method.
+////////////////////////////////////////////////////////////////////
+void PhysxController::
+stop_jump() {
+
+  nassertv(_error_type == ET_ok);
+
+  if (_jumping == false) {
+    return;
+  }
+
+  _jumping = false;
+
+  //NxVec3 v = ptr()->getActor()->getLinearVelocity();
+  //double velocity = (_up_axis == NX_Z) ? v.z : v.y;
+
+  Event *event = new Event("physx-controller-down");
+  event->add_parameter(EventParameter(this));
+  //event->add_parameter(EventParameter(velocity));
+  EventQueue::get_global_event_queue()->queue_event(event);
+}
+

+ 120 - 0
panda/src/physx/physxController.h

@@ -0,0 +1,120 @@
+// Filename: physxController.h
+// Created by:  enn0x (24Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXCONTROLLER_H
+#define PHYSXCONTROLLER_H
+
+#include "pandabase.h"
+#include "pointerTo.h"
+#include "lpoint3.h"
+#include "lmatrix.h"
+#include "lquaternion.h"
+
+#include "physxObject.h"
+#include "physxEnums.h"
+
+#include "NxController.h"
+
+class PhysxActor;
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxController
+// Description : Abstract base class for character controllers.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxController : public PhysxObject, public PhysxEnums {
+
+PUBLISHED:
+  void release();
+
+  PT(PhysxActor) get_actor() const;
+
+  void set_pos(const LPoint3f &pos);
+  void set_sharpness(float sharpness);
+  void set_collision(bool enable);
+  void set_min_distance(float min_dist);
+  void set_step_offset(float offset);
+
+  LPoint3f get_pos() const;
+  float get_sharpness() const;
+
+  void set_global_speed(const LVector3f &speed);
+  void set_local_speed(const LVector3f &speed);
+  void set_omega(float omega);
+  void set_h(float heading);
+  float get_h() const;
+
+  void report_scene_changed();
+  void start_jump(float v0);
+  void stop_jump();
+
+  INLINE void ls() const;
+  INLINE void ls(ostream &out, int indent_level=0) const;
+
+public:
+  void update(float dt);
+
+  static PT(PhysxController) factory(NxControllerType shapeType);
+
+  virtual NxController *ptr() const = 0;
+
+  virtual void link(NxController *controllerPtr) = 0;
+  virtual void unlink() = 0;
+
+protected:
+  INLINE PhysxController();
+
+private:
+  NxReal get_jump_height(float dt, NxVec3 &gravity);
+
+  float _sharpness;
+  float _min_dist;
+
+  bool  _jumping;
+  float _jump_time;
+  float _jump_v0;
+
+  float _omega;
+  float _heading;
+  NxVec3 _speed;
+
+  NxVec3 _up_vector;
+  NxQuat _up_quat;
+  NxQuat _up_quat_inv;
+  NxHeightFieldAxis _up_axis;
+
+////////////////////////////////////////////////////////////////////
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    PhysxObject::init_type();
+    register_type(_type_handle, "PhysxController", 
+                  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 "physxController.I"
+
+#endif // PHYSXCONTROLLER_H

+ 11 - 10
panda/src/physx/physxTemplate.cxx → panda/src/physx/physxControllerDesc.I

@@ -1,5 +1,5 @@
-// Filename: physxTemplate.cxx
-// Created by:  pratt (Dec 12, 2007)
+// Filename: physxControllerDesc.I
+// Created by:  enn0x (22Sep09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -12,14 +12,15 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifdef HAVE_PHYSX
 
-#include "physxTemplate.h"
 
-//includes
-//typehandle
-//publicstructors
-//publicmethods
-//publicattributes
-#endif // HAVE_PHYSX
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxControllerDesc::Constructor
+//       Access: Protected
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE PhysxControllerDesc::
+PhysxControllerDesc() {
+
+}
 

+ 148 - 0
panda/src/physx/physxControllerDesc.cxx

@@ -0,0 +1,148 @@
+// Filename: physxControllerDesc.cxx
+// Created by:  enn0x (22Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "physxControllerDesc.h"
+#include "physxManager.h"
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxControllerDesc::set_pos
+//       Access: Published
+//  Description: Set the position of the character.
+////////////////////////////////////////////////////////////////////
+void PhysxControllerDesc::
+set_pos(const LPoint3f &pos) {
+
+  ptr()->position = PhysxManager::point3_to_nxExtVec3(pos);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxControllerDesc::set_slope_limit
+//       Access: Published
+//  Description: Sets the maximum slope which the character can walk
+//               up. In general it is desirable to limit where the
+//               character can walk, in particular it is unrealistic
+//               for the character to be able to climb arbitary
+//               slopes.
+//               The value is expressed in degrees.
+//               Default: 45.0 degrees.
+////////////////////////////////////////////////////////////////////
+void PhysxControllerDesc::
+set_slope_limit(float slopeLimit) {
+
+  ptr()->slopeLimit = cosf(NxMath::degToRad(slopeLimit));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxControllerDesc::set_skin_width
+//       Access: Published
+//  Description: Sets the skin width used by the controller. 
+//               A "skin" around the controller is necessary to
+//               avoid numerical precision issues.
+//               This is dependant on the scale of the users world,
+//               but should be a small, positive non zero value.
+//               Default: 0.1 
+////////////////////////////////////////////////////////////////////
+void PhysxControllerDesc::
+set_skin_width(float skinWidth) {
+
+  ptr()->skinWidth = skinWidth;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxControllerDesc::set_step_offset
+//       Access: Published
+//  Description: Defines the maximum height of an obstacle which the
+//               character can climb. 
+//               A small value will mean that the character gets
+//               stuck and cannot walk up stairs etc, a value which
+//               is too large will mean that the character can climb
+//               over unrealistically high obstacles.
+//               Default: 0.5
+////////////////////////////////////////////////////////////////////
+void PhysxControllerDesc::
+set_step_offset(float stepOffset) {
+
+  ptr()->stepOffset = stepOffset;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxControllerDesc::set_interaction_flag
+//       Access: Published
+//  Description: The interaction flag controls if a character
+//               controller collides with other controllers.
+//               The default is to collide with other controllers.
+////////////////////////////////////////////////////////////////////
+void PhysxControllerDesc::
+set_interaction_flag(bool interactionFlag) {
+
+  ptr()->interactionFlag = (NxCCTInteractionFlag)interactionFlag;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxControllerDesc::get_pos
+//       Access: Published
+//  Description: Returns the position of the character.
+////////////////////////////////////////////////////////////////////
+LPoint3f PhysxControllerDesc::
+get_pos() const {
+
+  return PhysxManager::nxExtVec3_to_point3(ptr()->position);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxControllerDesc::get_slope_limit
+//       Access: Published
+//  Description: Returns the maximum slope which the character can
+//               walk up.
+////////////////////////////////////////////////////////////////////
+float PhysxControllerDesc::
+get_slope_limit() const {
+
+  return NxMath::radToDeg(acosf(ptr()->slopeLimit));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxControllerDesc::get_skin_width
+//       Access: Published
+//  Description: Returns the skin width used by the controller. 
+////////////////////////////////////////////////////////////////////
+float PhysxControllerDesc::
+get_skin_width() const {
+
+  return ptr()->skinWidth;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxControllerDesc::get_step_offset
+//       Access: Published
+//  Description: Returns the maximum height of an obstacle which the
+//               character can climb. 
+////////////////////////////////////////////////////////////////////
+float PhysxControllerDesc::
+get_step_offset() const {
+
+  return ptr()->stepOffset;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PhysxControllerDesc::get_interaction_flag
+//       Access: Published
+//  Description: Returns the interaction flag.
+////////////////////////////////////////////////////////////////////
+bool PhysxControllerDesc::
+get_interaction_flag() const {
+
+  return (ptr()->interactionFlag) ? true : false;
+}
+

+ 54 - 0
panda/src/physx/physxControllerDesc.h

@@ -0,0 +1,54 @@
+// Filename: physxControllerDesc.h
+// Created by:  enn0x (22Sep09)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 PHYSXCONTROLLERDESC_H
+#define PHYSXCONTROLLERDESC_H
+
+#include "pandabase.h"
+#include "lpoint3.h"
+
+#include "NxController.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : PhysxControllerDesc
+// Description : Descriptor class for a character controller.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAPHYSX PhysxControllerDesc {
+
+PUBLISHED:
+  virtual void set_to_default() = 0;
+  virtual bool is_valid() const = 0;
+
+  void set_pos(const LPoint3f &pos);
+  void set_slope_limit(float slopeLimit);
+  void set_skin_width(float skinWidth);
+  void set_step_offset(float setpOffset);
+  void set_interaction_flag(bool interactionFlag);
+
+  LPoint3f get_pos() const;
+  float get_slope_limit() const;
+  float get_skin_width() const;
+  float get_step_offset() const;
+  bool get_interaction_flag() const;
+
+public:
+  virtual NxControllerDesc *ptr() const = 0;
+
+protected:
+  INLINE PhysxControllerDesc();
+};
+
+#include "physxControllerDesc.I"
+
+#endif // PHYSXCONTROLLERDESC_H

Some files were not shown because too many files changed in this diff