Merging dev_physx_2009 to HEAD.

This commit is contained in:
enn0x 2009-12-28 11:33:36 +00:00
parent acb7eae95a
commit 1a7942b40c
357 changed files with 29810 additions and 12071 deletions

View File

@ -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

View File

@ -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

View File

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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

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

View File

@ -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
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;
#include "NxFoundation.h" //include the all of the foundation SDK
enum NxSDKCreateError;
enum NxAssertResponse;
enum NxErrorCode;
enum NxTriggerFlag;
enum NxHeightFieldAxis;
template<class T> class NxUserEntityReport;
//////////////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 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

View File

@ -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

View File

@ -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 \

View File

@ -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

View File

@ -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

View File

@ -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
#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
#define TARGET pandaphysx
#define SOURCES pandaphysx.cxx pandaphysx.h
#define INSTALL_HEADERS pandaphysx.h
#end metalib_target

View File

@ -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
}

View File

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

View File

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

View File

@ -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

View File

@ -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

View File

@ -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");
}

View File

@ -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

View File

@ -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()

File diff suppressed because it is too large Load Diff

View File

@ -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);
}

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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 :
// Function: PhysxActorDesc::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool PhysxActorDesc::
is_valid() const {
return nActorDesc.isValid();
INLINE PhysxActorDesc::
PhysxActorDesc() {
_desc.name = "";
}
////////////////////////////////////////////////////////////////////
// Function : set_to_default
// Access : Published
// Description :
// Function: PhysxActorDesc::Destructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE PhysxActorDesc::
~PhysxActorDesc() {
}
////////////////////////////////////////////////////////////////////
// Function: PhysxActorDesc::set_to_default
// Access: Published
// Description: (re)sets the structure to the default.
////////////////////////////////////////////////////////////////////
INLINE void PhysxActorDesc::
set_to_default() {
nActorDesc.setToDefault();
_desc.setToDefault();
}
////////////////////////////////////////////////////////////////////
// Function : get_density
// Access : Published
// Description :
// Function: PhysxActorDesc::is_valid
// Access: Published
// Description: Returns true if the descriptor is valid.
////////////////////////////////////////////////////////////////////
INLINE float PhysxActorDesc::
get_density() const {
return nActorDesc.density;
INLINE bool PhysxActorDesc::
is_valid() const {
return _desc.isValid();
}
////////////////////////////////////////////////////////////////////
// Function : get_flags
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
INLINE unsigned int PhysxActorDesc::
get_flags() const {
return nActorDesc.flags;
}
////////////////////////////////////////////////////////////////////
// Function : set_density
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
INLINE void PhysxActorDesc::
set_density(float value) {
nActorDesc.density = value;
}
////////////////////////////////////////////////////////////////////
// Function : set_flags
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
INLINE void PhysxActorDesc::
set_flags(unsigned int value) {
nActorDesc.flags = value;
}

View File

@ -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 :
////////////////////////////////////////////////////////////////////
PhysxActorDesc::
PhysxActorDesc() {
}
////////////////////////////////////////////////////////////////////
// Function : add_shape
// Access : Published
// Description :
// Function: PhysxActorDesc::add_shape
// Access: Published
// Description: Adds a shape to the list of collision shapes
// composing this actor.
////////////////////////////////////////////////////////////////////
void PhysxActorDesc::
add_shape(PhysxShapeDesc pShapeDesc) {
nActorDesc.shapes.pushBack(pShapeDesc.nShapeDesc);
add_shape(PhysxShapeDesc &desc) {
_desc.shapes.push_back(desc.ptr());
}
////////////////////////////////////////////////////////////////////
// Function : get_body
// Access : Published
// Description :
// Function: PhysxActorDesc::set_name
// Access: Published
// Description: Sets the optional debug name for the actor.
////////////////////////////////////////////////////////////////////
const PhysxBodyDesc * PhysxActorDesc::
void PhysxActorDesc::
set_name(const char *name) {
_desc.name = name;
}
////////////////////////////////////////////////////////////////////
// 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.
////////////////////////////////////////////////////////////////////
void PhysxActorDesc::
set_density(float density) {
_desc.density = density;
}
////////////////////////////////////////////////////////////////////
// Function: PhysxActorDesc::set_global_pos
// Access: Published
// Description: Set the position of the actor in global space.
////////////////////////////////////////////////////////////////////
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: 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_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: 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_body(PhysxBodyDesc &desc) {
_desc.body = &(desc._desc);
}
////////////////////////////////////////////////////////////////////
// Function: PhysxActorDesc::get_body
// Access: Published
// Description: Gets the body descriptor for this actor.
////////////////////////////////////////////////////////////////////
PhysxBodyDesc PhysxActorDesc::
get_body() const {
throw "Not Implemented"; // return nActorDesc.body;
throw "Not Implemented";
//PhysxBodyDesc value;
//value._desc = *(_desc.body);
//return value;
}
////////////////////////////////////////////////////////////////////
// Function : get_global_pose
// Access : Published
// Description :
// 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_pose() const {
return PhysxManager::nxMat34_to_lMatrix4(nActorDesc.globalPose);
get_global_mat() const {
return PhysxManager::nxMat34_to_mat4(_desc.globalPose);
}
////////////////////////////////////////////////////////////////////
// Function : set_body
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
void PhysxActorDesc::
set_body(const PhysxBodyDesc * value) {
nActorDesc.body = &(value->nBodyDesc);
}
////////////////////////////////////////////////////////////////////
// Function : set_global_pose
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
void PhysxActorDesc::
set_global_pose(LMatrix4f value) {
nActorDesc.globalPose = PhysxManager::lMatrix4_to_nxMat34(value);
}
#endif // HAVE_PHYSX

View File

@ -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"
class PhysxShapeDesc;
class PhysxBodyDesc;
#include "NoMinMax.h"
#include "NxPhysics.h"
class PhysxBodyDesc;
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

View File

@ -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;
}

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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 :
// Function: PhysxBodyDesc::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool PhysxBodyDesc::
is_valid() const {
return nBodyDesc.isValid();
INLINE PhysxBodyDesc::
PhysxBodyDesc() {
}
////////////////////////////////////////////////////////////////////
// Function : set_to_default
// Access : Published
// Description :
// Function: PhysxBodyDesc::Destructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE PhysxBodyDesc::
~PhysxBodyDesc() {
}
////////////////////////////////////////////////////////////////////
// Function: PhysxBodyDesc::set_to_default
// Access: Published
// Description: (re)sets the structure to the default.
////////////////////////////////////////////////////////////////////
INLINE void PhysxBodyDesc::
set_to_default() {
nBodyDesc.setToDefault();
_desc.setToDefault();
}
////////////////////////////////////////////////////////////////////
// Function : get_angular_damping
// Access : Published
// Description :
// Function: PhysxBodyDesc::is_valid
// Access: Published
// Description: Returns true if the descriptor is valid.
////////////////////////////////////////////////////////////////////
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 :
////////////////////////////////////////////////////////////////////
INLINE void PhysxBodyDesc::
set_mass(float value) {
nBodyDesc.mass = value;
}
////////////////////////////////////////////////////////////////////
// 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 :
////////////////////////////////////////////////////////////////////
INLINE void PhysxBodyDesc::
set_sleep_angular_velocity(float value) {
nBodyDesc.sleepAngularVelocity = value;
}
////////////////////////////////////////////////////////////////////
// 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 :
////////////////////////////////////////////////////////////////////
INLINE void PhysxBodyDesc::
set_sleep_energy_threshold(float value) {
nBodyDesc.sleepEnergyThreshold = value;
}
////////////////////////////////////////////////////////////////////
// Function : set_sleep_linear_velocity
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
INLINE void PhysxBodyDesc::
set_sleep_linear_velocity(float value) {
nBodyDesc.sleepLinearVelocity = value;
}
////////////////////////////////////////////////////////////////////
// Function : set_solver_iteration_count
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
INLINE void PhysxBodyDesc::
set_solver_iteration_count(unsigned int value) {
nBodyDesc.solverIterationCount = value;
}
////////////////////////////////////////////////////////////////////
// Function : set_wake_up_counter
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
INLINE void PhysxBodyDesc::
set_wake_up_counter(float value) {
nBodyDesc.wakeUpCounter = value;
INLINE bool PhysxBodyDesc::
is_valid() const {
return _desc.isValid();
}

View File

@ -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
// Access : Published
// Description :
// Function: PhysxBodyDesc::set_mass
// Access: Published
// Description: Set the mass of body.
////////////////////////////////////////////////////////////////////
PhysxBodyDesc::
PhysxBodyDesc() {
void PhysxBodyDesc::
set_mass(float mass) {
_desc.mass = mass;
}
////////////////////////////////////////////////////////////////////
// Function : get_angular_velocity
// Access : Published
// Description :
// Function: PhysxBodyDesc::get_mass
// Access: Published
// Description: Get the mass of body.
////////////////////////////////////////////////////////////////////
LVecBase3f PhysxBodyDesc::
get_angular_velocity() const {
return PhysxManager::nxVec3_to_lVecBase3(nBodyDesc.angularVelocity);
float PhysxBodyDesc::
get_mass() const {
return _desc.mass;
}
////////////////////////////////////////////////////////////////////
// Function : get_linear_velocity
// Access : Published
// Description :
// Function: PhysxBodyDesc::set_linear_damping
// Access: Published
// Description: Set the linear damping applied to the body.
////////////////////////////////////////////////////////////////////
LVecBase3f PhysxBodyDesc::
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: PhysxBodyDesc::get_angular_damping
// Access: Published
// Description: Get the angular damping applied to the body.
////////////////////////////////////////////////////////////////////
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 : get_mass_local_pose
// Access : Published
// Description :
// 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: 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 : get_mass_space_inertia
// Access : Published
// Description :
// Function: PhysxBodyDesc::set_mass_space_inertia
// Access: Published
// Description: Set the diagonal mass space inertia tensor in
// bodies mass frame.
////////////////////////////////////////////////////////////////////
LVecBase3f PhysxBodyDesc::
void PhysxBodyDesc::
set_mass_space_inertia(const LVector3f inertia) {
_desc.massSpaceInertia = PhysxManager::vec3_to_nxVec3(inertia);
}
////////////////////////////////////////////////////////////////////
// Function: PhysxBodyDesc::get_mass_space_inertia
// Access: Published
// Description: Get the diagonal mass space inertia tensor in
// bodies mass frame.
////////////////////////////////////////////////////////////////////
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 : set_linear_velocity
// Access : Published
// Description :
// 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: 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 : set_mass_space_inertia
// Access : Published
// Description :
// Function: PhysxBodyDesc::get_wake_up_counter
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
float PhysxBodyDesc::
get_wake_up_counter() const {
return _desc.wakeUpCounter;
}
////////////////////////////////////////////////////////////////////
// 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;
}

View File

@ -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

View File

@ -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: PhysxBounds3::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE PhysxBounds3::
PhysxBounds3() {
}
////////////////////////////////////////////////////////////////////
// Function : combine
// Access : Published
// Description :
// Function: PhysxBounds3::Destructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void PhysxBounds3::
combine(const PhysxBounds3 & b2) {
nassertv(nBounds3 != NULL);
INLINE PhysxBounds3::
~PhysxBounds3() {
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 :
////////////////////////////////////////////////////////////////////
INLINE void PhysxBounds3::
set_infinite() {
nassertv(nBounds3 != NULL);
nBounds3->setInfinite();
}
////////////////////////////////////////////////////////////////////
// Function : transform
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
INLINE void PhysxBounds3::
transform(const LMatrix3f & orientation, const LVecBase3f & translation) {
nassertv(nBounds3 != NULL);
nBounds3->transform(PhysxManager::lMatrix3_to_nxMat33(orientation), PhysxManager::lVecBase3_to_nxVec3(translation));
}

View File

@ -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 "luse.h"
#include "physxManager.h"
////////////////////////////////////////////////////////////////////
// Function : PhysxBounds3
// Access : Published
// Description :
// Function: PhysxBounds3::get_max
// Access: Published
// Description: Returns the minimum corner of the bounding box.
////////////////////////////////////////////////////////////////////
PhysxBounds3::
PhysxBounds3() {
nBounds3 = new NxBounds3();
}
////////////////////////////////////////////////////////////////////
// Function : ~PhysxBounds3
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
PhysxBounds3::
~PhysxBounds3() {
delete nBounds3;
}
////////////////////////////////////////////////////////////////////
// Function : get_max
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
LVecBase3f PhysxBounds3::
LPoint3f PhysxBounds3::
get_max() const {
nassertr(nBounds3 != NULL, *((LVecBase3f *)NULL));
return PhysxManager::nxVec3_to_lVecBase3(nBounds3->max);
return PhysxManager::nxVec3_to_point3(_bounds.max);
}
////////////////////////////////////////////////////////////////////
// Function : get_min
// Access : Published
// Description :
// Function: PhysxBounds3::get_min
// Access: Published
// Description: Returns the maximum corner of the bounding box.
////////////////////////////////////////////////////////////////////
LVecBase3f PhysxBounds3::
LPoint3f PhysxBounds3::
get_min() const {
nassertr(nBounds3 != NULL, *((LVecBase3f *)NULL));
return PhysxManager::nxVec3_to_lVecBase3(nBounds3->min);
return PhysxManager::nxVec3_to_point3(_bounds.min);
}
////////////////////////////////////////////////////////////////////
// Function : set_max
// Access : Published
// Description :
// Function: PhysxBounds3::get_center
// Access: Published
// Description: Returns the center of the bounding box.
////////////////////////////////////////////////////////////////////
LPoint3f PhysxBounds3::
get_center() const {
NxVec3 center;
_bounds.getCenter(center);
return PhysxManager::nxVec3_to_point3(center);
}
////////////////////////////////////////////////////////////////////
// Function: PhysxBounds3::get_dimensions
// Access: Published
// Description: Returns the extents of the bounding box.
////////////////////////////////////////////////////////////////////
LVector3f PhysxBounds3::
get_dimensions() const {
NxVec3 dims;
_bounds.getDimensions(dims);
return PhysxManager::nxVec3_to_vec3(dims);
}
////////////////////////////////////////////////////////////////////
// Function: PhysxBounds3::set_max
// Access: Published
// Description: Sets the maximum corner of the bounding box.
////////////////////////////////////////////////////////////////////
void PhysxBounds3::
set_max(LVecBase3f value) {
nassertv(nBounds3 != NULL);
set_max(LPoint3f value) {
nBounds3->max = PhysxManager::lVecBase3_to_nxVec3(value);
nassertv(!value.is_nan());
_bounds.max = PhysxManager::point3_to_nxVec3(value);
}
////////////////////////////////////////////////////////////////////
// Function : set_min
// Access : Published
// Description :
// Function: PhysxBounds3::set_min
// Access: Published
// Description: Sets the minimum corner of the bounding box.
////////////////////////////////////////////////////////////////////
void PhysxBounds3::
set_min(LVecBase3f value) {
nassertv(nBounds3 != NULL);
set_min(LPoint3f value) {
nBounds3->min = PhysxManager::lVecBase3_to_nxVec3(value);
nassertv(!value.is_nan());
_bounds.min = PhysxManager::point3_to_nxVec3(value);
}
#endif // HAVE_PHYSX
////////////////////////////////////////////////////////////////////
// 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());
_bounds.boundsOfOBB(PhysxManager::mat3_to_nxMat33(orientation),
PhysxManager::point3_to_nxVec3(translation),
PhysxManager::vec3_to_nxVec3(half_dims));
}
////////////////////////////////////////////////////////////////////
// Function: PhysxBounds3::combine
// Access: Published
// Description: Sets this to the union of this and b2.
////////////////////////////////////////////////////////////////////
void PhysxBounds3::
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);
return _bounds.contain(PhysxManager::point3_to_nxVec3(p));
}
////////////////////////////////////////////////////////////////////
// Function: PhysxBounds3::fatten
// Access: Published
// Description: Fattens the AABB in all three dimensions by the
// given distance.
////////////////////////////////////////////////////////////////////
void PhysxBounds3::
fatten(float distance) {
_bounds.fatten(distance);
}
////////////////////////////////////////////////////////////////////
// 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));
}

View File

@ -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

View File

@ -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: PhysxBox::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE PhysxBox::
PhysxBox() {
}
////////////////////////////////////////////////////////////////////
// Function : rotate
// Access : Published
// Description :
// Function: PhysxBox::Destructor
// 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 :
////////////////////////////////////////////////////////////////////
INLINE void PhysxBox::
set_empty() {
nassertv(nBox != NULL);
nBox->setEmpty();
}

View File

@ -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 "luse.h"
#include "physxManager.h"
////////////////////////////////////////////////////////////////////
// Function : PhysxBox
// Access : Published
// Description :
// Function: PhysxBox::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
PhysxBox::
PhysxBox() {
nBox = new NxBox();
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(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));
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() {
delete nBox;
void PhysxBox::
rotate(const LMatrix4f &m, PhysxBox &obb) const {
nassertv(!m.is_nan());
_box.rotate(PhysxManager::mat4_to_nxMat34(m), obb._box);
}
////////////////////////////////////////////////////////////////////
// Function : get_center
// Access : Published
// Description :
// Function: PhysxBox::set_empty
// Access: Published
// Description: Setups an empty box.
////////////////////////////////////////////////////////////////////
LVecBase3f PhysxBox::
void PhysxBox::
set_empty() {
_box.setEmpty();
}
////////////////////////////////////////////////////////////////////
// Function: PhysxBox::get_center
// Access: Published
// Description: Return center of the box.
////////////////////////////////////////////////////////////////////
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) {
nBox->extents = PhysxManager::lVecBase3_to_nxVec3(value);
nassertv(!extents.is_nan());
_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());
_box.rot = PhysxManager::mat3_to_nxMat33(rot);
}
#endif // HAVE_PHYSX

View File

@ -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

View File

@ -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() {
}

View File

@ -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());
}

View File

@ -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

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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

View File

@ -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"
//superHeader
//forwardDeclarations
#include "NxPhysics.h"
////////////////////////////////////////////////////////////////////
// Class : PhysxTemplate
// Description :
// Function: PhysxBoxForceFieldShape::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
class EXPCL_PANDAPHYSX PhysxTemplate /*baseclassref*/{
PUBLISHED:
//publicstructors
//publicmethods
//publicattributes
public:
//nxreference
//typeinfo
};
INLINE PhysxBoxForceFieldShape::
PhysxBoxForceFieldShape() : PhysxForceFieldShape() {
#include "physxTemplate.I"
}
#endif // HAVE_PHYSX
////////////////////////////////////////////////////////////////////
// Function: PhysxBoxForceFieldShape::Destructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE PhysxBoxForceFieldShape::
~PhysxBoxForceFieldShape() {
}
#endif // PHYSXTEMPLATE_H

View File

@ -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());
}

View File

@ -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

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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

View File

@ -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() {
}

View File

@ -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::
void PhysxBoxShape::
link(NxShape *shapePtr) {
_ptr = shapePtr->isBox();
_ptr->userData = this;
_error_type = ET_ok;
PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
actor->_shapes.add(this);
}
////////////////////////////////////////////////////////////////////
// Function: PhysxBoxShape::unlink
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void PhysxBoxShape::
unlink() {
_ptr->userData = NULL;
_error_type = ET_released;
PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
actor->_shapes.remove(this);
}
////////////////////////////////////////////////////////////////////
// Function : PhysxBoxShape::save_to_desc
// Access : Published
// Description : Saves the state of the shape object to a
// descriptor.
////////////////////////////////////////////////////////////////////
void PhysxBoxShape::
save_to_desc(PhysxBoxShapeDesc &shapeDesc) const {
nassertv(_error_type == ET_ok);
_ptr->saveToDesc(shapeDesc._desc);
}
////////////////////////////////////////////////////////////////////
// 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 LVector3f &vec) {
nassertv(_error_type == ET_ok);
_ptr->setDimensions(PhysxManager::vec3_to_nxVec3(vec));
}
////////////////////////////////////////////////////////////////////
// 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(nBoxShape != NULL, *((LVecBase3f *)NULL));
return PhysxManager::nxVec3_to_lVecBase3(nBoxShape->getDimensions());
nassertr(_error_type == ET_ok, LVector3f::zero());
return PhysxManager::nxVec3_to_vec3(_ptr->getDimensions());
}
////////////////////////////////////////////////////////////////////
// Function : get_world_obb
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
void PhysxBoxShape::
get_world_obb(PhysxBox & obb) const {
nassertv(nBoxShape != NULL);
nBoxShape->getWorldOBB(*(obb.nBox));
}
////////////////////////////////////////////////////////////////////
// Function : save_to_desc
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
void PhysxBoxShape::
save_to_desc(PhysxBoxShapeDesc & desc) const {
nassertv(nBoxShape != NULL);
nBoxShape->saveToDesc(desc.nBoxShapeDesc);
}
////////////////////////////////////////////////////////////////////
// Function : set_dimensions
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
void PhysxBoxShape::
set_dimensions(const LVecBase3f & vec) {
nassertv(nBoxShape != NULL);
nBoxShape->setDimensions(PhysxManager::lVecBase3_to_nxVec3(vec));
}
#endif // HAVE_PHYSX

View File

@ -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

View File

@ -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 : set_to_default
// Access : Published
// Description :
// Function: PhysxBoxShapeDesc::Destructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE PhysxBoxShapeDesc::
~PhysxBoxShapeDesc() {
}
////////////////////////////////////////////////////////////////////
// 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();
}

View File

@ -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 :
////////////////////////////////////////////////////////////////////
PhysxBoxShapeDesc::
PhysxBoxShapeDesc()
: PhysxShapeDesc( &nBoxShapeDesc ) {
}
////////////////////////////////////////////////////////////////////
// Function : get_dimensions
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
LVecBase3f PhysxBoxShapeDesc::
get_dimensions() const {
return PhysxManager::nxVec3_to_lVecBase3(nBoxShapeDesc.dimensions);
}
////////////////////////////////////////////////////////////////////
// Function : set_dimensions
// 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.
////////////////////////////////////////////////////////////////////
void PhysxBoxShapeDesc::
set_dimensions(LVecBase3f value) {
nBoxShapeDesc.dimensions = PhysxManager::lVecBase3_to_nxVec3(value);
set_dimensions(const LVector3f &dimensions) {
nassertv(!dimensions.is_nan());
_desc.dimensions = PhysxManager::vec3_to_nxVec3(dimensions);
}
#endif // HAVE_PHYSX
////////////////////////////////////////////////////////////////////
// Function: PhysxBoxShapeDesc::get_dimensions
// Access: Published
// Description: Returns the dimensions of the box.
////////////////////////////////////////////////////////////////////
LVector3f PhysxBoxShapeDesc::
get_dimensions() const {
return PhysxManager::nxVec3_to_vec3(_desc.dimensions);
}

View File

@ -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

View File

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

View File

@ -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 "physxSegment.h"
#include "physxManager.h"
////////////////////////////////////////////////////////////////////
// Function : PhysxCapsule
// Access : Published
// Description :
// Function: PhysxCapsule::get_radius
// Access: Published
// Description: Returns the capsule's radius.
////////////////////////////////////////////////////////////////////
PhysxCapsule::
PhysxCapsule(const PhysxSegment & seg, float _radius) {
float PhysxCapsule::
get_radius() const {
return _capsule.radius;
}
////////////////////////////////////////////////////////////////////
// Function : ~PhysxCapsule
// Access : Published
// Description :
// Function: PhysxCapsule::set_radius
// Access: Published
// Description: Sets the capsule's radius.
////////////////////////////////////////////////////////////////////
PhysxCapsule::
~PhysxCapsule() {
void PhysxCapsule::
set_radius(float radius) {
_capsule.radius = radius;
}
#endif // HAVE_PHYSX
////////////////////////////////////////////////////////////////////
// Function: PhysxCapsule::get_p0
// Access: Published
// Description: Returns the start point of the segment.
////////////////////////////////////////////////////////////////////
LPoint3f PhysxCapsule::
get_p0() const {
return PhysxManager::nxVec3_to_vec3(_capsule.p0);
}
////////////////////////////////////////////////////////////////////
// Function: PhysxCapsule::set_p0
// Access: Published
// Description: Sets the start point of the segment.
////////////////////////////////////////////////////////////////////
void PhysxCapsule::
set_p0(LPoint3f p) {
nassertv(!p.is_nan());
_capsule.p0 = PhysxManager::vec3_to_nxVec3(p);
}
////////////////////////////////////////////////////////////////////
// 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));
}

View File

@ -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

View File

@ -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() {
}

View File

@ -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();
}

View File

@ -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

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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

View File

@ -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() {
}

View File

@ -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();
}

View File

@ -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

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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

View File

@ -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() {
}

View File

@ -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 :
////////////////////////////////////////////////////////////////////
float PhysxCapsuleShape::
get_height() const {
nassertr(nCapsuleShape != NULL, -1.0f);
return nCapsuleShape->getHeight();
}
////////////////////////////////////////////////////////////////////
// Function : get_radius
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
float PhysxCapsuleShape::
get_radius() const {
nassertr(nCapsuleShape != NULL, -1.0f);
return nCapsuleShape->getRadius();
}
////////////////////////////////////////////////////////////////////
// Function : get_world_capsule
// Access : Published
// Description :
// Function: PhysxCapsuleShape::link
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void PhysxCapsuleShape::
get_world_capsule(PhysxCapsule & world_capsule) const {
nassertv(nCapsuleShape != NULL);
link(NxShape *shapePtr) {
nCapsuleShape->getWorldCapsule(*(world_capsule.nCapsule));
_ptr = shapePtr->isCapsule();
_ptr->userData = this;
_error_type = ET_ok;
PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
actor->_shapes.add(this);
}
////////////////////////////////////////////////////////////////////
// Function : save_to_desc
// Access : Published
// Description :
// Function: PhysxCapsuleShape::unlink
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void PhysxCapsuleShape::
save_to_desc(PhysxCapsuleShapeDesc & desc) const {
nassertv(nCapsuleShape != NULL);
unlink() {
nCapsuleShape->saveToDesc(desc.nCapsuleShapeDesc);
_ptr->userData = NULL;
_error_type = ET_released;
PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
actor->_shapes.remove(this);
}
////////////////////////////////////////////////////////////////////
// Function : set_dimensions
// Function : PhysxCapsuleShape::save_to_desc
// Access : Published
// Description :
// Description : Saves the state of the shape object to a
// descriptor.
////////////////////////////////////////////////////////////////////
void PhysxCapsuleShape::
set_dimensions(float radius, float height) {
nassertv(nCapsuleShape != NULL);
save_to_desc(PhysxCapsuleShapeDesc &shapeDesc) const {
nCapsuleShape->setDimensions(radius, height);
nassertv(_error_type == ET_ok);
_ptr->saveToDesc(shapeDesc._desc);
}
////////////////////////////////////////////////////////////////////
// Function : set_height
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
void PhysxCapsuleShape::
set_height(float height) {
nassertv(nCapsuleShape != NULL);
nCapsuleShape->setHeight(height);
}
////////////////////////////////////////////////////////////////////
// Function : set_radius
// Access : Published
// Description :
// Function: PhysxCapsuleShape::set_radius
// Access: Published
// Description: Alters the radius of the capsule.
////////////////////////////////////////////////////////////////////
void PhysxCapsuleShape::
set_radius(float radius) {
nassertv(nCapsuleShape != NULL);
nCapsuleShape->setRadius(radius);
nassertv(_error_type == ET_ok);
_ptr->setRadius(radius);
}
#endif // HAVE_PHYSX
////////////////////////////////////////////////////////////////////
// Function: PhysxCapsuleShape::set_height
// Access: Published
// Description: Alters the height of the capsule.
////////////////////////////////////////////////////////////////////
void PhysxCapsuleShape::
set_height(float height) {
nassertv(_error_type == ET_ok);
_ptr->setHeight(height);
}
////////////////////////////////////////////////////////////////////
// Function: PhysxCapsuleShape::get_radius
// Access: Published
// Description: Retrieves the radius of the capsule.
////////////////////////////////////////////////////////////////////
float PhysxCapsuleShape::
get_radius() const {
nassertr(_error_type == ET_ok, 0.0f);
return _ptr->getRadius();
}
////////////////////////////////////////////////////////////////////
// Function: PhysxCapsuleShape::get_height
// Access: Published
// Description: Retrieves the height of the capsule.
////////////////////////////////////////////////////////////////////
float PhysxCapsuleShape::
get_height() const {
nassertr(_error_type == ET_ok, 0.0f);
return _ptr->getHeight();
}

View File

@ -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

View File

@ -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 :
// Function: PhysxCapsuleShapeDesc::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool PhysxCapsuleShapeDesc::
is_valid() const {
return nCapsuleShapeDesc.isValid();
INLINE PhysxCapsuleShapeDesc::
PhysxCapsuleShapeDesc() : PhysxShapeDesc() {
_desc.name = "";
}
////////////////////////////////////////////////////////////////////
// Function : set_to_default
// Access : Published
// Description :
// Function: PhysxCapsuleShapeDesc::Destructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE PhysxCapsuleShapeDesc::
~PhysxCapsuleShapeDesc() {
}
////////////////////////////////////////////////////////////////////
// Function: PhysxCapsuleShapeDesc::set_to_default
// Access: Published
// Description: (re)sets the structure to the default.
////////////////////////////////////////////////////////////////////
INLINE void PhysxCapsuleShapeDesc::
set_to_default() {
nCapsuleShapeDesc.setToDefault();
_desc.setToDefault();
}
////////////////////////////////////////////////////////////////////
// Function : get_flags
// Access : Published
// Description :
// Function: PhysxCapsuleShapeDesc::is_valid
// Access: Published
// Description: Returns true if the descriptor is valid.
////////////////////////////////////////////////////////////////////
INLINE unsigned int PhysxCapsuleShapeDesc::
get_flags() const {
return nCapsuleShapeDesc.flags;
}
////////////////////////////////////////////////////////////////////
// Function : get_height
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
INLINE float PhysxCapsuleShapeDesc::
get_height() const {
return nCapsuleShapeDesc.height;
}
////////////////////////////////////////////////////////////////////
// Function : get_radius
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
INLINE float PhysxCapsuleShapeDesc::
get_radius() const {
return nCapsuleShapeDesc.radius;
}
////////////////////////////////////////////////////////////////////
// Function : set_flags
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
INLINE void PhysxCapsuleShapeDesc::
set_flags(unsigned int value) {
nCapsuleShapeDesc.flags = value;
}
////////////////////////////////////////////////////////////////////
// Function : set_height
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
INLINE void PhysxCapsuleShapeDesc::
set_height(float value) {
nCapsuleShapeDesc.height = value;
}
////////////////////////////////////////////////////////////////////
// Function : set_radius
// Access : Published
// Description :
////////////////////////////////////////////////////////////////////
INLINE void PhysxCapsuleShapeDesc::
set_radius(float value) {
nCapsuleShapeDesc.radius = value;
INLINE bool PhysxCapsuleShapeDesc::
is_valid() const {
return _desc.isValid();
}

View File

@ -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
// Access : Published
// Description :
// Function: PhysxCapsuleShapeDesc::set_radius
// Access: Published
// Description: Sets the radius of the capsule's hemispherical
// ends and its trunk.
////////////////////////////////////////////////////////////////////
PhysxCapsuleShapeDesc::
PhysxCapsuleShapeDesc()
: PhysxShapeDesc( &nCapsuleShapeDesc ) {
void PhysxCapsuleShapeDesc::
set_radius(float radius) {
_desc.radius = radius;
}
#endif // HAVE_PHYSX
////////////////////////////////////////////////////////////////////
// Function: PhysxCapsuleShapeDesc::set_height
// Access: Published
// Description: Sets the distance between the two hemispherical
// ends of the capsule.
////////////////////////////////////////////////////////////////////
void PhysxCapsuleShapeDesc::
set_height(float height) {
_desc.height = height;
}
////////////////////////////////////////////////////////////////////
// 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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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() {
}

View File

@ -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];
}

View File

@ -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

View File

@ -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() {
}

View File

@ -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;
}

View File

@ -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

View File

@ -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() {
}

View File

@ -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();
}

View File

@ -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

View File

@ -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";
}

View File

@ -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);
}

View File

@ -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

View File

@ -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() {
}

View File

@ -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;
}

View File

@ -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 have changed in this diff Show More