From 27d8bd17114e736a687c69ecbed48325cc4cb8c4 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 1 Feb 2001 19:37:34 +0000 Subject: [PATCH] *** empty log message *** --- dtool/Config.pp | 38 +++++++++++ dtool/LocalSetup.pp | 10 +++ dtool/pptempl/Global.msvc.pp | 67 ++++++++++++------- dtool/src/dtoolbase/dtoolbase_cc.h | 2 +- panda/metalibs/panda/Sources.pp | 13 ++++ panda/metalibs/panda/panda.cxx | 24 +++++++ panda/metalibs/pandagl/Sources.pp | 14 ++-- panda/metalibs/pandagl/pandagl.cxx | 6 +- panda/metalibs/pandaphysics/Sources.pp | 13 +++- panda/metalibs/pandaphysics/pandaphysics.cxx | 26 +++++-- panda/metalibs/pandaphysics/pandaphysics.h | 13 ++++ panda/src/audio/audio_win_traits.cxx | 28 +++++--- panda/src/net/datagramQueue.cxx | 10 +++ panda/src/net/datagramQueue.h | 11 ++- .../particlesystem/config_particlesystem.cxx | 19 ++++++ .../particlesystem/config_particlesystem.h | 2 + panda/src/physics/config_physics.cxx | 43 ++++++++---- panda/src/physics/config_physics.h | 2 + 18 files changed, 277 insertions(+), 64 deletions(-) create mode 100644 panda/metalibs/pandaphysics/pandaphysics.h diff --git a/dtool/Config.pp b/dtool/Config.pp index 65dce9bd90..fe5e0233cc 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -292,6 +292,44 @@ #defer HAVE_MAYA $[isdir $[MAYA_LOCATION]] +// Define this to generate static libraries and executables, rather than +// dynamic libraries. +//#define LINK_ALL_STATIC yes + +// Define this to export the templates from the DLL. This is only +// meaningful if LINK_ALL_STATIC is not defined, and we are building +// on Windows. This can only be used if VC++ is the compiler in +// use, since other compilers don't support the syntax. +#defer EXPORT_TEMPLATES $[eq $[USE_COMPILER],MSVC] + +// Define this to explicitly link in the various external drivers, which +// are normally separate, as part of the Panda library. +//#define LINK_IN_GL yes +//#define LINK_IN_DX yes +//#define LINK_IN_EGG yes +//#define LINK_IN_PHYSICS yes + +// Define USE_COMPILER to switch the particular compiler that should +// be used. A handful of tokens are recognized, depending on BUILD_TYPE. +// This may also be further customized within Global.$[BUILD_TYPE].pp. + +// If BUILD_TYPE is "unix", this may be one of: +// GCC (gcc/g++) +// MIPS (Irix MIPSPro compiler) +// +// If BUILD_TYPE is "msvc" or "gmsvc", this may be one of: +// MSVC (Microsoft Visual C++) +// BOUNDS (BoundsChecker) +// INTEL (Intel C/C++ compiler)e + +#if $[eq $[PLATFORM], Irix] + #define USE_COMPILER MIPS +#elif $[eq $[PLATFORM], Linux] + #define USE_COMPILER GCC +#elif $[eq $[PLATFORM], Windows] + #define USE_COMPILER MSVC +#endif + /////////////////////////////////////////////////////////////////////// // The following variables are meaningful when BUILD_TYPE is "unix" or // "msvc". They define a few environmental things. diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index 8f0377ccd3..18b1353600 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -85,6 +85,16 @@ $[cdefine HAVE_NET] /* Define if we want to compile the audio code. */ $[cdefine HAVE_AUDIO] +/* Define if we want to export template classes from the DLL. Only + makes sense to MSVC++. */ +$[cdefine EXPORT_TEMPLATES] + +/* Define if we are linking PANDAGL in with PANDA. */ +$[cdefine LINK_IN_GL] + +/* Define if we are linking PANDAPHYSICS in with PANDA. */ +$[cdefine LINK_IN_PHYSICS] + /* Define if we have a gettimeofday() function. */ $[cdefine HAVE_GETTIMEOFDAY] diff --git a/dtool/pptempl/Global.msvc.pp b/dtool/pptempl/Global.msvc.pp index 9bd97dd500..3d0f2cc671 100644 --- a/dtool/pptempl/Global.msvc.pp +++ b/dtool/pptempl/Global.msvc.pp @@ -62,7 +62,6 @@ #else #define BROWSEINFO_FLAG #endif -#defer CFLAGS_SHARED // Define LINK_ALL_STATIC to generate static libs instead of DLL's. #if $[LINK_ALL_STATIC] @@ -75,32 +74,52 @@ #define dlllib dll #endif -#defer OPTFLAGS /O2 /Ob1 /Ogity /G6 +#define CFLAGS_SHARED + +#if $[eq $[USE_COMPILER], MSVC] + #define COMPILER cl + #define LINKER link + #define LIBBER lib + #define COMMONFLAGS /Gi- + #define OPTFLAGS /O2 /Ob1 /Ogity /G6 + #define DEBUGFLAGS /MDd /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[target:%.obj=%.pdb]]" + #define RELEASEFLAGS /MD + #define EXTRA_LIBPATH + +#elif $[eq $[USE_COMPILER], BOUNDS] + #define COMPILER nmcl + #define LINKER nmlink + #define LIBBER lib + #define COMMONFLAGS + #define OPTFLAGS /O2 /Ogity /G6 + #define DEBUGFLAGS /MDd /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[target:%.obj=%.pdb]]" + #define RELEASEFLAGS /MD + #define EXTRA_LIBPATH + +#elif $[eq $[USE_COMPILER], INTEL] + #define COMPILER icl + #define LINKER xilink + #define LIBBER xilib + #define COMMONFLAGS /Gi- + #define OPTFLAGS /O3 /Ob1 /Ogity /G6 /Qip + #define DEBUGFLAGS /MDd /Zi $[BROWSEINFO_FLAG] + #define RELEASEFLAGS /MD + // We assume the Intel compiler installation dir is mounted as /ia32. + #define EXTRA_LIBPATH /ia32/lib + +#else + #error Invalid value specified for USE_COMPILER. +#endif #defer CDEFINES_OPT1 _DEBUG $[dlink_all_static] #defer CDEFINES_OPT2 _DEBUG $[dlink_all_static] #defer CDEFINES_OPT3 $[dlink_all_static] #defer CDEFINES_OPT4 NDEBUG $[dlink_all_static] -#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] /MDd /Gi- /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[target:%.obj=%.pdb]]" -#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] /MDd /Gi- /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[target:%.obj=%.pdb]]" -#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] /MD /Gi- -#defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=/D%] /MD /Gi- - -#defer COMPILER cl -#defer LINKER link - -// Define USE_BOUNDSCHECKER for BoundsChecker instrumentaion: -#if $[USE_BOUNDSCHECKER] - #defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] /MDd /GZ /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[target:%.obj=%.pdb]]" - #defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] /MDd /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[target:%.obj=%.pdb]]" - #defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] /MD - #defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=/D%] /MD - - #defer OPTFLAGS /O2 /Ogity /G6 - #defer COMPILER nmcl - #defer LINKER nmlink -#endif +#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] +#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPTFLAGS] +#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] +#defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] // NODEFAULTLIB ensures static libs linked in will connect to the correct msvcrt, so no debug/release mixing occurs #defer LDFLAGS_OPT1 /debug /incremental:no /NODEFAULTLIB:MSVCRT.LIB /WARN:3 @@ -130,15 +149,15 @@ #defer COMPILE_C $[COMPILER] /nologo /c /Fo"$[osfilename $[target]]" $[decygwin %,/I"%",$[ipath]] $[flags] $[extra_cflags] $[source] #defer COMPILE_C++ $[COMPILE_C] -#defer STATIC_LIB_C lib /nologo $[sources] /OUT:"$[osfilename $[target]]" +#defer STATIC_LIB_C $[LIBBER] /nologo $[sources] /OUT:"$[osfilename $[target]]" #defer STATIC_LIB_C++ $[STATIC_LIB_C] #defer ver_resource $[directory]\ver.res -#defer SHARED_LIB_C $[LINKER] /nologo /dll $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] "$[ver_resource]" $[decygwin %,/LIBPATH:"%",$[lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]" +#defer SHARED_LIB_C $[LINKER] /nologo /dll $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] "$[ver_resource]" $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]" #defer SHARED_LIB_C++ $[SHARED_LIB_C] -#defer LINK_BIN_C $[LINKER] /nologo $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] $[decygwin %,/LIBPATH:"%",$[lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]" +#defer LINK_BIN_C $[LINKER] /nologo $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]" #defer LINK_BIN_C++ $[LINK_BIN_C] #if $[LINK_ALL_STATIC] diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index f69c305dfa..07a73ca98f 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -63,7 +63,7 @@ using namespace std; #define INLINE inline #endif -#if defined(WIN32_VC) && !defined(LINK_ALL_STATIC) +#if defined(WIN32_VC) && !defined(LINK_ALL_STATIC) && defined(EXPORT_TEMPLATES) // This macro must be used to export an instantiated template class // from a DLL. If the template class name itself contains commas, it // may be necessary to first define a macro for the class name, to diff --git a/panda/metalibs/panda/Sources.pp b/panda/metalibs/panda/Sources.pp index f3c7fd84f2..b158997271 100644 --- a/panda/metalibs/panda/Sources.pp +++ b/panda/metalibs/panda/Sources.pp @@ -21,6 +21,19 @@ #define LOCAL_LIBS downloader event ipc express pandabase #define OTHER_LIBS dtoolconfig dtool +#if $[LINK_IN_GL] + #define BUILDING_DLL $[BUILDING_DLL] BUILDING_PANDAGL + #define COMPONENT_LIBS $[COMPONENT_LIBS] \ + glgsg glxdisplay wgldisplay glutdisplay \ + sgidisplay sgiglxdisplay sgiglutdisplay +#endif + +#if $[LINK_IN_PHYSICS] + #define BUILDING_DLL $[BUILDING_DLL] BUILDING_PANDAPHYSICS + #define COMPONENT_LIBS $[COMPONENT_LIBS] \ + physics particlesystem +#endif + #begin metalib_target #define TARGET panda diff --git a/panda/metalibs/panda/panda.cxx b/panda/metalibs/panda/panda.cxx index 5016af4927..d6803bd189 100644 --- a/panda/metalibs/panda/panda.cxx +++ b/panda/metalibs/panda/panda.cxx @@ -12,6 +12,18 @@ #include #include +#ifdef LINK_IN_GL +#include +#ifdef HAVE_WGL +#include +#endif +#endif + +#ifdef LINK_IN_PHYSICS +#include +#include +#endif + //////////////////////////////////////////////////////////////////// // Function: init_libpanda // Description: Initializes the library. This must be called at @@ -28,4 +40,16 @@ init_libpanda() { init_libpnmimagetypes(); init_libpstatclient(); init_libsgraph(); + +#ifdef LINK_IN_GL + init_libglgsg(); +#ifdef HAVE_WGL + init_libwgldisplay(); +#endif +#endif + +#ifdef LINK_IN_PHYSICS + init_libphysics(); + init_libparticlesystem(); +#endif } diff --git a/panda/metalibs/pandagl/Sources.pp b/panda/metalibs/pandagl/Sources.pp index 2423501052..a0a0c758b1 100644 --- a/panda/metalibs/pandagl/Sources.pp +++ b/panda/metalibs/pandagl/Sources.pp @@ -1,5 +1,3 @@ -#define DIRECTORY_IF_GL yes - // DIR_TYPE "metalib" indicates we are building a shared library that // consists mostly of references to other shared libraries. Under // Windows, this directly produces a DLL (as opposed to the regular @@ -8,10 +6,15 @@ #define DIR_TYPE metalib #define BUILDING_DLL BUILDING_PANDAGL +#define DIRECTORY_IF_GL yes -#define COMPONENT_LIBS \ - glgsg glxdisplay wgldisplay glutdisplay \ - sgidisplay sgiglxdisplay sgiglutdisplay +#if $[eq $[LINK_IN_GL],] + // We don't have any components if we're linking the GL library + // directly into Panda. + #define COMPONENT_LIBS \ + glgsg glxdisplay wgldisplay glutdisplay \ + sgidisplay sgiglxdisplay sgiglutdisplay +#endif #define LOCAL_LIBS gsgbase display express #define OTHER_LIBS dtoolconfig dtool @@ -20,7 +23,6 @@ #define TARGET pandagl #define SOURCES pandagl.cxx pandagl.h - #define INSTALL_HEADERS pandagl.h #end metalib_target diff --git a/panda/metalibs/pandagl/pandagl.cxx b/panda/metalibs/pandagl/pandagl.cxx index 6e34261cb6..f5b49349f4 100644 --- a/panda/metalibs/pandagl/pandagl.cxx +++ b/panda/metalibs/pandagl/pandagl.cxx @@ -5,11 +5,12 @@ #include "pandagl.h" +#ifndef LINK_IN_GL #include - #ifdef HAVE_WGL #include #endif +#endif //////////////////////////////////////////////////////////////////// // Function: init_libpandagl @@ -21,9 +22,10 @@ //////////////////////////////////////////////////////////////////// void init_libpandagl() { +#ifndef LINK_IN_GL init_libglgsg(); - #ifdef HAVE_WGL init_libwgldisplay(); #endif +#endif } diff --git a/panda/metalibs/pandaphysics/Sources.pp b/panda/metalibs/pandaphysics/Sources.pp index 1af58c2894..8d0eb51401 100644 --- a/panda/metalibs/pandaphysics/Sources.pp +++ b/panda/metalibs/pandaphysics/Sources.pp @@ -7,13 +7,20 @@ #define DIR_TYPE metalib #define BUILDING_DLL BUILDING_PANDAPHYSICS -#define COMPONENT_LIBS \ - physics particlesystem +#if $[eq $[LINK_IN_PHYSICS],] + // We don't have any components if we're linking the Physics library + // directly into Panda. + #define COMPONENT_LIBS \ + physics particlesystem +#endif + #define LOCAL_LIBS linmath putil express #define OTHER_LIBS dtoolconfig dtool #begin metalib_target #define TARGET pandaphysics - #define SOURCES pandaphysics.cxx + #define SOURCES pandaphysics.cxx pandaphysics.h + #define INSTALL_HEADERS pandaphysics.h + #end metalib_target diff --git a/panda/metalibs/pandaphysics/pandaphysics.cxx b/panda/metalibs/pandaphysics/pandaphysics.cxx index acf791875c..4a37a1869b 100644 --- a/panda/metalibs/pandaphysics/pandaphysics.cxx +++ b/panda/metalibs/pandaphysics/pandaphysics.cxx @@ -3,7 +3,25 @@ // //////////////////////////////////////////////////////////////////// -// This is a dummy file whose sole purpose is to give the compiler -// something to compile when making libpandaphysics.so in NO_DEFER mode, -// which generates an empty library that itself links with all the -// other shared libraries that make up libpandaphysics. +#include "pandaphysics.h" + +#ifndef LINK_IN_PHYSICS +#include +#include +#endif + +//////////////////////////////////////////////////////////////////// +// Function: init_libpandaphysics +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libpandaphysics() { +#ifndef LINK_IN_PHYSICS + init_libphysics(); + init_libparticlesystem(); +#endif +} diff --git a/panda/metalibs/pandaphysics/pandaphysics.h b/panda/metalibs/pandaphysics/pandaphysics.h new file mode 100644 index 0000000000..3b017b83d2 --- /dev/null +++ b/panda/metalibs/pandaphysics/pandaphysics.h @@ -0,0 +1,13 @@ +// Filename: pandaphysics.h +// Created by: drose (2Jan01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef PANDAPHYSICS_H +#define PANDAPHYSICS_H + +#include + +EXPCL_PANDAPHYSICS void init_libpandaphysics(); + +#endif diff --git a/panda/src/audio/audio_win_traits.cxx b/panda/src/audio/audio_win_traits.cxx index 87982c277b..79c60ae6c4 100644 --- a/panda/src/audio/audio_win_traits.cxx +++ b/panda/src/audio/audio_win_traits.cxx @@ -35,6 +35,7 @@ static IDirectSound* musicDirectSound = NULL; // #define MULTI_TO_WIDE(_in, _out) MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, _in, -1, _out, DMUS_MAX_FILENAME) #define MULTI_TO_WIDE(x,y) MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, y, -1, x, _MAX_PATH); + static void update_win(void) { } @@ -693,17 +694,22 @@ WinSamplePlaying::WinSamplePlaying(AudioTraits::SoundClass* s) audio_cat->debug() << "WinSamplePlaying::WinSamplePlaying _data = 0x" << (void*)(ws->_data) << " dst = 0x" << (void*)dst << endl; - try { - memcpy(dst, ws->_data, ws->_len); - } - catch (...) { - _channel = NULL; - if (audio_cat->is_debug()) - audio_cat->debug() << "memcpy failed. dst = 0x" << (void*)dst - << " data = 0x" << (void*)(ws->_data) - << " len = " << ws->_len << endl; - return; - } + + // The Intel compiler dumps core if we attempt to protect this in a + // try .. catch block. We probably shouldn't be using exception + // handling anyway. + + // try { + memcpy(dst, ws->_data, ws->_len); + // } + // catch (...) { + // _channel = NULL; + // if (audio_cat->is_debug()) + // audio_cat->debug() << "memcpy failed. dst = 0x" << (void*)dst + // << " data = 0x" << (void*)(ws->_data) + // << " len = " << ws->_len << endl; + // return; + // } this->unlock(); } diff --git a/panda/src/net/datagramQueue.cxx b/panda/src/net/datagramQueue.cxx index 423caaab57..c1fc37fcce 100644 --- a/panda/src/net/datagramQueue.cxx +++ b/panda/src/net/datagramQueue.cxx @@ -69,7 +69,11 @@ insert(const NetDatagram &data) { PR_Lock(_cvlock); bool enqueue_ok = ((int)_queue.size() < _max_queue_size); if (enqueue_ok) { +#ifdef __ICL + _queue.push_back(new NetDatagram(data)); +#else _queue.push_back(data); +#endif } PR_NotifyCondVar(_cv); PR_Unlock(_cvlock); @@ -112,7 +116,13 @@ extract(NetDatagram &result) { } nassertr(!_queue.empty(), false); +#ifdef __ICL + NetDatagram *ptr = _queue.front(); + result = *ptr; + delete ptr; +#else result = _queue.front(); +#endif _queue.pop_front(); PR_Unlock(_cvlock); diff --git a/panda/src/net/datagramQueue.h b/panda/src/net/datagramQueue.h index aaad259b65..bc7e42716b 100644 --- a/panda/src/net/datagramQueue.h +++ b/panda/src/net/datagramQueue.h @@ -36,7 +36,16 @@ public: private: PRLock *_cvlock; PRCondVar *_cv; - deque _queue; + +#ifdef __ICL + // The Intel compiler for some reason dumps core on a queue of + // NetDatagrams. + typedef deque QueueType; +#else + typedef deque QueueType; +#endif + + QueueType _queue; bool _shutdown; int _max_queue_size; }; diff --git a/panda/src/particlesystem/config_particlesystem.cxx b/panda/src/particlesystem/config_particlesystem.cxx index 7297a181e2..c3fe20559a 100644 --- a/panda/src/particlesystem/config_particlesystem.cxx +++ b/panda/src/particlesystem/config_particlesystem.cxx @@ -11,5 +11,24 @@ ConfigureDef(config_particlesystem); NotifyCategoryDef(particlesystem, ""); ConfigureFn(config_particlesystem) { + init_libparticlesystem(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libparticlesystem +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libparticlesystem() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + } diff --git a/panda/src/particlesystem/config_particlesystem.h b/panda/src/particlesystem/config_particlesystem.h index 63acae7cc7..f9ff43ad29 100644 --- a/panda/src/particlesystem/config_particlesystem.h +++ b/panda/src/particlesystem/config_particlesystem.h @@ -13,4 +13,6 @@ ConfigureDecl(config_particlesystem, EXPCL_PANDAPHYSICS, EXPTP_PANDAPHYSICS); NotifyCategoryDecl(particlesystem, EXPCL_PANDAPHYSICS, EXPTP_PANDAPHYSICS); +extern EXPCL_PANDAPHYSICS void init_libparticlesystem(); + #endif // CONFIG_PARTICLESYSTEM_H diff --git a/panda/src/physics/config_physics.cxx b/panda/src/physics/config_physics.cxx index 9d5cdf377c..f47b641ebe 100644 --- a/panda/src/physics/config_physics.cxx +++ b/panda/src/physics/config_physics.cxx @@ -16,6 +16,37 @@ ConfigureDef(config_physics); NotifyCategoryDef(physics, ""); ConfigureFn(config_physics) { + init_libphysics(); +} + +const float LinearIntegrator::_max_linear_dt = + config_physics.GetFloat("default_max_linear_dt", 1.0f / 30.0f); + +const float AngularIntegrator::_max_angular_dt = + config_physics.GetFloat("default_max_angular_dt", 1.0f / 30.0f); + +int LinearNoiseForce::_random_seed = + config_physics.GetInt("default_noise_force_seed", 665); + +const float PhysicsObject::_default_terminal_velocity = + config_physics.GetFloat("default_terminal_velocity", 400.0f); + +//////////////////////////////////////////////////////////////////// +// Function: init_libphysics +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libphysics() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + PhysicsObject::init_type(); Physical::init_type(); PhysicalNode::init_type(); @@ -33,15 +64,3 @@ ConfigureFn(config_physics) { LinearUserDefinedForce::init_type(); LinearCylinderVortexForce::init_type(); } - -const float LinearIntegrator::_max_linear_dt = - config_physics.GetFloat("default_max_linear_dt", 1.0f / 30.0f); - -const float AngularIntegrator::_max_angular_dt = - config_physics.GetFloat("default_max_angular_dt", 1.0f / 30.0f); - -int LinearNoiseForce::_random_seed = - config_physics.GetInt("default_noise_force_seed", 665); - -const float PhysicsObject::_default_terminal_velocity = - config_physics.GetFloat("default_terminal_velocity", 400.0f); diff --git a/panda/src/physics/config_physics.h b/panda/src/physics/config_physics.h index 93bef55e56..8154435654 100644 --- a/panda/src/physics/config_physics.h +++ b/panda/src/physics/config_physics.h @@ -13,4 +13,6 @@ ConfigureDecl(config_physics, EXPCL_PANDAPHYSICS, EXPTP_PANDAPHYSICS); NotifyCategoryDecl(physics, EXPCL_PANDAPHYSICS, EXPTP_PANDAPHYSICS); +extern EXPCL_PANDAPHYSICS void init_libphysics(); + #endif // CONFIG_PHYSICS_H