diff --git a/.travis.yml b/.travis.yml index 9de0326d78..728367f785 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ install: script: - $PYTHONV makepanda/makepanda.py --everything --git-commit $TRAVIS_COMMIT $FLAGS --threads 4 - LD_LIBRARY_PATH=built/lib PYTHONPATH=built $PYTHONV makepanda/test_imports.py - - LD_LIBRARY_PATH=built/lib PYTHONPATH=built $PYTHONV -m pytest tests + - LD_LIBRARY_PATH=built/lib PYTHONPATH=built $PYTHONV -m pytest -v tests notifications: irc: channels: diff --git a/direct/src/deadrec/config_deadrec.cxx b/direct/src/deadrec/config_deadrec.cxx index eb1c43a9c6..87e1cffe68 100644 --- a/direct/src/deadrec/config_deadrec.cxx +++ b/direct/src/deadrec/config_deadrec.cxx @@ -15,7 +15,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_DEADREC) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DIRECT_DEADREC) #error Buildsystem error: BUILDING_DIRECT_DEADREC not defined #endif diff --git a/direct/src/directd/directd.cxx b/direct/src/directd/directd.cxx index 817706acb5..93a4df905c 100644 --- a/direct/src/directd/directd.cxx +++ b/direct/src/directd/directd.cxx @@ -30,7 +30,7 @@ #include "pset.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_DIRECTD) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DIRECT_DIRECTD) #error Buildsystem error: BUILDING_DIRECT_DIRECTD not defined #endif diff --git a/direct/src/distributed/config_distributed.cxx b/direct/src/distributed/config_distributed.cxx index 312964568f..0160f5f1bf 100644 --- a/direct/src/distributed/config_distributed.cxx +++ b/direct/src/distributed/config_distributed.cxx @@ -14,7 +14,7 @@ #include "config_distributed.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_DISTRIBUTED) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DIRECT_DISTRIBUTED) #error Buildsystem error: BUILDING_DIRECT_DISTRIBUTED not defined #endif diff --git a/direct/src/gui/DirectFrame.py b/direct/src/gui/DirectFrame.py index e078b28021..684fda005c 100644 --- a/direct/src/gui/DirectFrame.py +++ b/direct/src/gui/DirectFrame.py @@ -61,7 +61,14 @@ class DirectFrame(DirectGuiWidget): def destroy(self): DirectGuiWidget.destroy(self) - def setText(self): + def clearText(self): + self['text'] = None + self.setText() + + def setText(self, text=None): + if text is not None: + self['text'] = text + # Determine if user passed in single string or a sequence if self['text'] == None: textList = (None,) * self['numStates'] @@ -100,7 +107,14 @@ class DirectFrame(DirectGuiWidget): sort = DGG.TEXT_SORT_INDEX, ) - def setGeom(self): + def clearGeom(self): + self['geom'] = None + self.setGeom() + + def setGeom(self, geom=None): + if geom is not None: + self['geom'] = geom + # Determine argument type geom = self['geom'] @@ -142,7 +156,14 @@ class DirectFrame(DirectGuiWidget): geom = geom, scale = 1, sort = DGG.GEOM_SORT_INDEX) - def setImage(self): + def clearImage(self): + self['image'] = None + self.setImage() + + def setImage(self, image=None): + if image is not None: + self['image'] = image + # Determine argument type arg = self['image'] if arg == None: diff --git a/direct/src/interval/config_interval.cxx b/direct/src/interval/config_interval.cxx index f56ce67e17..767ad32695 100644 --- a/direct/src/interval/config_interval.cxx +++ b/direct/src/interval/config_interval.cxx @@ -29,7 +29,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_INTERVAL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DIRECT_INTERVAL) #error Buildsystem error: BUILDING_DIRECT_INTERVAL not defined #endif diff --git a/direct/src/motiontrail/config_motiontrail.cxx b/direct/src/motiontrail/config_motiontrail.cxx index 997a1a3059..c60a67f95c 100644 --- a/direct/src/motiontrail/config_motiontrail.cxx +++ b/direct/src/motiontrail/config_motiontrail.cxx @@ -14,7 +14,7 @@ #include "config_motiontrail.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_MOTIONTRAIL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DIRECT_MOTIONTRAIL) #error Buildsystem error: BUILDING_DIRECT_MOTIONTRAIL not defined #endif diff --git a/direct/src/showbase/Loader.py b/direct/src/showbase/Loader.py index 17c9cea25e..924b396616 100644 --- a/direct/src/showbase/Loader.py +++ b/direct/src/showbase/Loader.py @@ -934,8 +934,8 @@ class Loader(DirectObject): just as in loadModel(); otherwise, the loading happens before loadSound() returns.""" - if not isinstance(soundPath, (MovieAudio, tuple, list, set)): - # We were given a single sound pathname. + if not isinstance(soundPath, (tuple, list, set)): + # We were given a single sound pathname or a MovieAudio instance. soundList = [soundPath] gotList = False else: diff --git a/direct/src/showbase/showBase.cxx b/direct/src/showbase/showBase.cxx index f14d9610a4..7d8973996f 100644 --- a/direct/src/showbase/showBase.cxx +++ b/direct/src/showbase/showBase.cxx @@ -37,7 +37,7 @@ FILTERKEYS g_StartupFilterKeys = {sizeof(FILTERKEYS), 0}; using std::max; using std::min; -#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_SHOWBASE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DIRECT_SHOWBASE) #error Buildsystem error: BUILDING_DIRECT_SHOWBASE not defined #endif diff --git a/dtool/src/dconfig/config_dconfig.cxx b/dtool/src/dconfig/config_dconfig.cxx index d0800084ca..f828fc8f7d 100644 --- a/dtool/src/dconfig/config_dconfig.cxx +++ b/dtool/src/dconfig/config_dconfig.cxx @@ -13,7 +13,7 @@ #include "config_dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DTOOL_DCONFIG) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DTOOL_DCONFIG) #error Buildsystem error: BUILDING_DTOOL_DCONFIG not defined #endif diff --git a/dtool/src/dtoolbase/dtoolbase.cxx b/dtool/src/dtoolbase/dtoolbase.cxx index 10d1790ccf..a45a1de4e0 100644 --- a/dtool/src/dtoolbase/dtoolbase.cxx +++ b/dtool/src/dtoolbase/dtoolbase.cxx @@ -14,7 +14,7 @@ #include "dtoolbase.h" #include "memoryHook.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DTOOL_DTOOLBASE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DTOOL_DTOOLBASE) #error Buildsystem error: BUILDING_DTOOL_DTOOLBASE not defined #endif diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index ff52c6291a..36da6b2b0b 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -49,6 +49,8 @@ // interrogate pass (CPPPARSER isn't defined), this maps to public. #define PUBLISHED __published +#define PHAVE_ATOMIC 1 + typedef int ios_openmode; typedef int ios_fmtflags; typedef int ios_iostate; @@ -93,6 +95,23 @@ typedef std::ios::iostate ios_iostate; typedef std::ios::seekdir ios_seekdir; #endif +#ifdef _MSC_VER +#define ALWAYS_INLINE __forceinline +#elif defined(__GNUC__) +#define ALWAYS_INLINE __attribute__((always_inline)) inline +#else +#define ALWAYS_INLINE inline +#endif + +#ifdef FORCE_INLINING +// If FORCE_INLINING is defined, we use the keyword __forceinline, which tells +// MS VC++ to override its internal benefit heuristic and inline the fn if it +// is technically possible to do so. +#define INLINE ALWAYS_INLINE +#else +#define INLINE inline +#endif + // Apple has an outdated libstdc++. Not all is lost, though, as we can fill // in some important missing functions. #if defined(__GLIBCXX__) && __GLIBCXX__ <= 20070719 @@ -115,24 +134,38 @@ namespace std { } template struct owner_less; + + typedef enum memory_order { + memory_order_relaxed, + memory_order_consume, + memory_order_acquire, + memory_order_release, + memory_order_acq_rel, + memory_order_seq_cst, + } memory_order; + + #define ATOMIC_FLAG_INIT { 0 } + class atomic_flag { + bool _flag; + + public: + atomic_flag() noexcept = default; + ALWAYS_INLINE constexpr atomic_flag(bool flag) noexcept : _flag(flag) {} + atomic_flag(const atomic_flag &) = delete; + ~atomic_flag() noexcept = default; + atomic_flag &operator = (const atomic_flag&) = delete; + + ALWAYS_INLINE bool test_and_set(memory_order order = memory_order_seq_cst) noexcept { + return __atomic_test_and_set(&_flag, order); + } + ALWAYS_INLINE void clear(memory_order order = memory_order_seq_cst) noexcept { + __atomic_clear(&_flag, order); + } + }; }; -#endif - -#ifdef _MSC_VER -#define ALWAYS_INLINE __forceinline -#elif defined(__GNUC__) -#define ALWAYS_INLINE __attribute__((always_inline)) inline #else -#define ALWAYS_INLINE inline -#endif - -#ifdef FORCE_INLINING -// If FORCE_INLINING is defined, we use the keyword __forceinline, which tells -// MS VC++ to override its internal benefit heuristic and inline the fn if it -// is technically possible to do so. -#define INLINE ALWAYS_INLINE -#else -#define INLINE inline +// Expect that we have access to the header. +#define PHAVE_ATOMIC 1 #endif // Determine the availability of C++11 features. diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.I b/dtool/src/dtoolbase/mutexSpinlockImpl.I index b3eb084181..53ce89445f 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.I +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.I @@ -11,13 +11,6 @@ * @date 2006-04-11 */ -/** - * - */ -constexpr MutexSpinlockImpl:: -MutexSpinlockImpl() : _lock(0) { -} - /** * */ @@ -33,7 +26,7 @@ lock() { */ INLINE bool MutexSpinlockImpl:: try_lock() { - return (AtomicAdjust::compare_and_exchange(_lock, 0, 1) == 0); + return !_flag.test_and_set(std::memory_order_acquire); } /** @@ -41,5 +34,5 @@ try_lock() { */ INLINE void MutexSpinlockImpl:: unlock() { - AtomicAdjust::set(_lock, 0); + _flag.clear(std::memory_order_release); } diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.cxx b/dtool/src/dtoolbase/mutexSpinlockImpl.cxx index 32a84fa28f..73f2683ff2 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.cxx +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.cxx @@ -17,12 +17,21 @@ #include "mutexSpinlockImpl.h" +#if defined(__i386__) || defined(__x86_64) || defined(_M_IX86) || defined(_M_X64) +#include +#define PAUSE() _mm_pause() +#else +#define PAUSE() +#endif + /** * */ void MutexSpinlockImpl:: do_lock() { - while (AtomicAdjust::compare_and_exchange(_lock, 0, 1) != 0) { + // Loop until we changed the flag from 0 to 1 (and it wasn't already 1). + while (_flag.test_and_set(std::memory_order_acquire)) { + PAUSE(); } } diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.h b/dtool/src/dtoolbase/mutexSpinlockImpl.h index c7dfb72cf2..cd858f5551 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.h +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.h @@ -19,7 +19,9 @@ #ifdef MUTEX_SPINLOCK -#include "atomicAdjust.h" +#ifdef PHAVE_ATOMIC +#include +#endif /** * Uses a simple user-space spinlock to implement a mutex. It is usually not @@ -29,7 +31,7 @@ */ class EXPCL_DTOOL_DTOOLBASE MutexSpinlockImpl { public: - constexpr MutexSpinlockImpl(); + constexpr MutexSpinlockImpl() noexcept = default; MutexSpinlockImpl(const MutexSpinlockImpl ©) = delete; MutexSpinlockImpl &operator = (const MutexSpinlockImpl ©) = delete; @@ -42,7 +44,7 @@ public: private: void do_lock(); - TVOLATILE AtomicAdjust::Integer _lock; + std::atomic_flag _flag = ATOMIC_FLAG_INIT; }; #include "mutexSpinlockImpl.I" diff --git a/dtool/src/dtoolutil/config_dtoolutil.cxx b/dtool/src/dtoolutil/config_dtoolutil.cxx index 98b3c42760..b7b6505d28 100644 --- a/dtool/src/dtoolutil/config_dtoolutil.cxx +++ b/dtool/src/dtoolutil/config_dtoolutil.cxx @@ -16,7 +16,7 @@ #include "filename.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DTOOL_DTOOLUTIL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DTOOL_DTOOLUTIL) #error Buildsystem error: BUILDING_DTOOL_DCTOOLUTIL not defined #endif diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index e7a2f828d9..9836a23bfc 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -254,14 +254,13 @@ call_function(ostream &out, int indent_level, bool convert_result, &parser); out << " = " << call << ";\n"; - // MOVE() expands to std::move() when we are compiling with a compiler - // that supports rvalue references. It basically turns an lvalue into + // Use of the C++11 std::move function basically turns an lvalue into // an rvalue, allowing a move constructor to be called instead of a // copy constructor (since we won't be using the return value any // more), which is usually more efficient if it exists. If it // doesn't, it shouldn't do any harm. string new_str = - _return_type->prepare_return_expr(out, indent_level, "MOVE(result)"); + _return_type->prepare_return_expr(out, indent_level, "std::move(result)"); return_expr = _return_type->get_return_expr(new_str); } else { diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 5752fe126b..8d2b0f2288 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -5491,7 +5491,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, // Use move constructor when available for functions that take an // actual PointerTo. This eliminates an unref()ref() pair. - pexpr_string = "MOVE(" + param_name + "_this)"; + pexpr_string = "std::move(" + param_name + "_this)"; } else { // This is a move-assignable type, such as TypeHandle or LVecBase4. @@ -6156,7 +6156,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, indent(out, indent_level) << "return true;\n"; } else if (TypeManager::is_reference_count(remap->_cpptype)) { - indent(out, indent_level) << "coerced = MOVE(" << return_expr << ");\n"; + indent(out, indent_level) << "coerced = std::move(" << return_expr << ");\n"; indent(out, indent_level) << "return true;\n"; } else { diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index d11bd22ff6..964d38020c 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -516,7 +516,7 @@ main(int argc, char **argv) { cerr << "Error parsing file: '" << argv[i] << "'\n"; exit(1); } - builder.add_source_file(filename); + builder.add_source_file(filename.to_os_generic()); } // Now that we've parsed all the source code, change the way things are diff --git a/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx b/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx index f5e7c35b39..9f217076cb 100644 --- a/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx @@ -40,7 +40,7 @@ pass_parameter(std::ostream &out, const std::string &variable_name) { if (variable_name.size() > 1 && variable_name[0] == '&') { // Prevent generating something like *¶m Also, if this is really some // local type, we can presumably just move it? - out << "MOVE(" << variable_name.substr(1) << ")"; + out << "std::move(" << variable_name.substr(1) << ")"; } else { out << "*" << variable_name; } diff --git a/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx b/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx index 6c8e8b05a9..4e8d1fad90 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx @@ -42,7 +42,7 @@ pass_parameter(std::ostream &out, const std::string &variable_name) { // this parameter is an rvalue reference, but CPPParser can't know that, // and it might have an overload that takes an rvalue reference. It // shouldn't hurt either way. - out << "MOVE(" << variable_name.substr(1) << ")"; + out << "std::move(" << variable_name.substr(1) << ")"; } else { out << "*" << variable_name; } diff --git a/dtool/src/prc/config_prc.cxx b/dtool/src/prc/config_prc.cxx index 2728e642bd..65b7c77265 100644 --- a/dtool/src/prc/config_prc.cxx +++ b/dtool/src/prc/config_prc.cxx @@ -16,7 +16,7 @@ #include "configVariableEnum.h" #include "pandaFileStreamBuf.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DTOOL_PRC) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DTOOL_PRC) #error Buildsystem error: BUILDING_DTOOL_PRC not defined #endif diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index e02053d346..a7eb0900ba 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2272,6 +2272,7 @@ DTOOL_CONFIG=[ ("OS_SIMPLE_THREADS", '1', '1'), ("DEBUG_THREADS", 'UNDEF', 'UNDEF'), ("HAVE_POSIX_THREADS", 'UNDEF', '1'), + ("MUTEX_SPINLOCK", 'UNDEF', 'UNDEF'), ("HAVE_AUDIO", '1', '1'), ("NOTIFY_DEBUG", 'UNDEF', 'UNDEF'), ("DO_PSTATS", 'UNDEF', 'UNDEF'), diff --git a/panda/metalibs/panda/panda.cxx b/panda/metalibs/panda/panda.cxx index 9c9cb8bb60..99da6b4f5b 100644 --- a/panda/metalibs/panda/panda.cxx +++ b/panda/metalibs/panda/panda.cxx @@ -14,7 +14,7 @@ #include "config_pstatclient.h" #endif -#if !defined(CPPPARSER) && !defined(BUILDING_LIBPANDA) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_LIBPANDA) #error Buildsystem error: BUILDING_LIBPANDA not defined #endif diff --git a/panda/src/audio/audioManager.h b/panda/src/audio/audioManager.h index 2ee14f10cb..62d9a5d090 100644 --- a/panda/src/audio/audioManager.h +++ b/panda/src/audio/audioManager.h @@ -86,7 +86,7 @@ PUBLISHED: virtual bool is_valid() = 0; // Get a sound: - virtual PT(AudioSound) get_sound(const std::string& file_name, bool positional = false, int mode=SM_heuristic) = 0; + virtual PT(AudioSound) get_sound(const Filename &file_name, bool positional = false, int mode=SM_heuristic) = 0; virtual PT(AudioSound) get_sound(MovieAudio *source, bool positional = false, int mode=SM_heuristic) = 0; PT(AudioSound) get_null_sound(); @@ -95,7 +95,7 @@ PUBLISHED: // doesn't break any connection between AudioSounds that have already given // by get_sound() from this manager. It's only affecting whether the // AudioManager keeps a copy of the sound in its poolcache. - virtual void uncache_sound(const std::string& file_name) = 0; + virtual void uncache_sound(const Filename &file_name) = 0; virtual void clear_cache() = 0; virtual void set_cache_limit(unsigned int count) = 0; virtual unsigned int get_cache_limit() const = 0; diff --git a/panda/src/audio/config_audio.cxx b/panda/src/audio/config_audio.cxx index 1ea8053eb6..ce9b1413d3 100644 --- a/panda/src/audio/config_audio.cxx +++ b/panda/src/audio/config_audio.cxx @@ -21,7 +21,7 @@ #include "nullAudioSound.h" #include "string_utils.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_AUDIO) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_AUDIO) #error Buildsystem error: BUILDING_PANDA_AUDIO not defined #endif diff --git a/panda/src/audio/nullAudioManager.cxx b/panda/src/audio/nullAudioManager.cxx index dabeb8c825..c9f490e54f 100644 --- a/panda/src/audio/nullAudioManager.cxx +++ b/panda/src/audio/nullAudioManager.cxx @@ -49,7 +49,7 @@ is_valid() { * */ PT(AudioSound) NullAudioManager:: -get_sound(const std::string&, bool positional, int mode) { +get_sound(const Filename &, bool positional, int mode) { return get_null_sound(); } @@ -65,7 +65,7 @@ get_sound(MovieAudio *sound, bool positional, int mode) { * */ void NullAudioManager:: -uncache_sound(const std::string&) { +uncache_sound(const Filename &) { // intentionally blank. } diff --git a/panda/src/audio/nullAudioManager.h b/panda/src/audio/nullAudioManager.h index 9a8ff921e4..a4e2c47511 100644 --- a/panda/src/audio/nullAudioManager.h +++ b/panda/src/audio/nullAudioManager.h @@ -29,9 +29,9 @@ public: virtual bool is_valid(); - virtual PT(AudioSound) get_sound(const std::string&, bool positional = false, int mode=SM_heuristic); + virtual PT(AudioSound) get_sound(const Filename &, bool positional = false, int mode=SM_heuristic); virtual PT(AudioSound) get_sound(MovieAudio *sound, bool positional = false, int mode=SM_heuristic); - virtual void uncache_sound(const std::string&); + virtual void uncache_sound(const Filename &); virtual void clear_cache(); virtual void set_cache_limit(unsigned int); virtual unsigned int get_cache_limit() const; diff --git a/panda/src/audiotraits/config_fmodAudio.cxx b/panda/src/audiotraits/config_fmodAudio.cxx index f0a188fbc5..c49b54f730 100644 --- a/panda/src/audiotraits/config_fmodAudio.cxx +++ b/panda/src/audiotraits/config_fmodAudio.cxx @@ -19,7 +19,7 @@ #include "pandaSystem.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_FMOD_AUDIO) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_FMOD_AUDIO) #error Buildsystem error: BUILDING_FMOD_AUDIO not defined #endif diff --git a/panda/src/audiotraits/config_milesAudio.cxx b/panda/src/audiotraits/config_milesAudio.cxx index 6877b3700e..87cd36321c 100644 --- a/panda/src/audiotraits/config_milesAudio.cxx +++ b/panda/src/audiotraits/config_milesAudio.cxx @@ -22,7 +22,7 @@ #include "pandaSystem.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_MILES_AUDIO) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_MILES_AUDIO) #error Buildsystem error: BUILDING_MILES_AUDIO not defined #endif diff --git a/panda/src/audiotraits/config_openalAudio.cxx b/panda/src/audiotraits/config_openalAudio.cxx index ad51368d75..72b6923928 100644 --- a/panda/src/audiotraits/config_openalAudio.cxx +++ b/panda/src/audiotraits/config_openalAudio.cxx @@ -18,7 +18,7 @@ #include "pandaSystem.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_OPENAL_AUDIO) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_OPENAL_AUDIO) #error Buildsystem error: BUILDING_OPENAL_AUDIO not defined #endif diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index 42fd08c536..cdccbfbd0e 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -409,7 +409,7 @@ configure_filters(FilterProperties *config) { * This is what creates a sound instance. */ PT(AudioSound) FmodAudioManager:: -get_sound(const std::string &file_name, bool positional, int) { +get_sound(const Filename &file_name, bool positional, int) { ReMutexHolder holder(_lock); // Needed so People use Panda's Generic UNIX Style Paths for Filename. // path.to_os_specific() converts it back to the proper OS version later on. @@ -772,7 +772,7 @@ reduce_sounds_playing_to(unsigned int count) { * NOT USED FOR FMOD-EX!!! Clears a sound out of the sound cache. */ void FmodAudioManager:: -uncache_sound(const std::string& file_name) { +uncache_sound(const Filename &file_name) { audio_debug("FmodAudioManager::uncache_sound(\""<= 285 static const btVector3 up_vectors[3] = {btVector3(1.0f, 0.0f, 0.0f), btVector3(0.0f, 1.0f, 0.0f), btVector3(0.0f, 0.0f, 1.0f)}; #endif diff --git a/panda/src/bullet/bulletConeShape.cxx b/panda/src/bullet/bulletConeShape.cxx index c4c554ba2f..f9c952402d 100644 --- a/panda/src/bullet/bulletConeShape.cxx +++ b/panda/src/bullet/bulletConeShape.cxx @@ -13,6 +13,10 @@ #include "bulletConeShape.h" +#include "config_bullet.h" + +#include "bulletWorld.h" + TypeHandle BulletConeShape::_type_handle; /** diff --git a/panda/src/bullet/bulletConeTwistConstraint.cxx b/panda/src/bullet/bulletConeTwistConstraint.cxx index 9b60ab31ce..b5ccc17d05 100644 --- a/panda/src/bullet/bulletConeTwistConstraint.cxx +++ b/panda/src/bullet/bulletConeTwistConstraint.cxx @@ -12,7 +12,9 @@ */ #include "bulletConeTwistConstraint.h" + #include "bulletRigidBodyNode.h" +#include "bulletWorld.h" #include "deg_2_rad.h" diff --git a/panda/src/bullet/bulletConstraint.cxx b/panda/src/bullet/bulletConstraint.cxx index 28efe703ff..44eddc37e5 100644 --- a/panda/src/bullet/bulletConstraint.cxx +++ b/panda/src/bullet/bulletConstraint.cxx @@ -12,7 +12,9 @@ */ #include "bulletConstraint.h" + #include "bulletRigidBodyNode.h" +#include "bulletShape.h" TypeHandle BulletConstraint::_type_handle; diff --git a/panda/src/bullet/bulletConvexHullShape.cxx b/panda/src/bullet/bulletConvexHullShape.cxx index 487219c7fd..b61722e773 100644 --- a/panda/src/bullet/bulletConvexHullShape.cxx +++ b/panda/src/bullet/bulletConvexHullShape.cxx @@ -13,6 +13,8 @@ #include "bulletConvexHullShape.h" +#include "bulletWorld.h" + #include "nodePathCollection.h" #include "geomNode.h" #include "geomVertexReader.h" diff --git a/panda/src/bullet/bulletConvexHullShape.h b/panda/src/bullet/bulletConvexHullShape.h index 78485ed12c..27e006f1d0 100644 --- a/panda/src/bullet/bulletConvexHullShape.h +++ b/panda/src/bullet/bulletConvexHullShape.h @@ -22,6 +22,7 @@ #include "luse.h" #include "geom.h" #include "pta_LVecBase3.h" +#include "transformState.h" /** * diff --git a/panda/src/bullet/bulletConvexPointCloudShape.cxx b/panda/src/bullet/bulletConvexPointCloudShape.cxx index 1a4cb6e16c..8b7ca82f79 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.cxx +++ b/panda/src/bullet/bulletConvexPointCloudShape.cxx @@ -13,6 +13,10 @@ #include "bulletConvexPointCloudShape.h" +#include "bulletWorld.h" + +#include "bullet_utils.h" + #include "geomVertexReader.h" TypeHandle BulletConvexPointCloudShape::_type_handle; diff --git a/panda/src/bullet/bulletCylinderShape.cxx b/panda/src/bullet/bulletCylinderShape.cxx index 976daac96e..8b2d7986a3 100644 --- a/panda/src/bullet/bulletCylinderShape.cxx +++ b/panda/src/bullet/bulletCylinderShape.cxx @@ -13,6 +13,8 @@ #include "bulletCylinderShape.h" +#include "config_bullet.h" + using std::endl; TypeHandle BulletCylinderShape::_type_handle; diff --git a/panda/src/bullet/bulletDebugNode.cxx b/panda/src/bullet/bulletDebugNode.cxx index ce0c044758..2f221eb447 100644 --- a/panda/src/bullet/bulletDebugNode.cxx +++ b/panda/src/bullet/bulletDebugNode.cxx @@ -13,6 +13,10 @@ #include "bulletDebugNode.h" +#include "config_bullet.h" + +#include "bulletWorld.h" + #include "cullHandler.h" #include "cullTraverser.h" #include "cullableObject.h" diff --git a/panda/src/bullet/bulletDebugNode.h b/panda/src/bullet/bulletDebugNode.h index c780429a79..f42bd4722d 100644 --- a/panda/src/bullet/bulletDebugNode.h +++ b/panda/src/bullet/bulletDebugNode.h @@ -16,8 +16,13 @@ #include "pandabase.h" +#include "pandaNode.h" + #include "bullet_includes.h" +class CullTraverser; +class CullTraverserData; + /** * */ diff --git a/panda/src/bullet/bulletGenericConstraint.cxx b/panda/src/bullet/bulletGenericConstraint.cxx index de98b5d40b..dfd1fe5b68 100644 --- a/panda/src/bullet/bulletGenericConstraint.cxx +++ b/panda/src/bullet/bulletGenericConstraint.cxx @@ -12,7 +12,9 @@ */ #include "bulletGenericConstraint.h" + #include "bulletRigidBodyNode.h" +#include "bulletWorld.h" TypeHandle BulletGenericConstraint::_type_handle; diff --git a/panda/src/bullet/bulletGhostNode.cxx b/panda/src/bullet/bulletGhostNode.cxx index b4008820a1..d3dcb7aaf5 100644 --- a/panda/src/bullet/bulletGhostNode.cxx +++ b/panda/src/bullet/bulletGhostNode.cxx @@ -12,7 +12,9 @@ */ #include "bulletGhostNode.h" + #include "bulletShape.h" +#include "bulletWorld.h" TypeHandle BulletGhostNode::_type_handle; diff --git a/panda/src/bullet/bulletHeightfieldShape.cxx b/panda/src/bullet/bulletHeightfieldShape.cxx index 15e8d6f75f..08f91bd036 100644 --- a/panda/src/bullet/bulletHeightfieldShape.cxx +++ b/panda/src/bullet/bulletHeightfieldShape.cxx @@ -13,6 +13,10 @@ #include "bulletHeightfieldShape.h" +#include "config_bullet.h" + +#include "bulletWorld.h" + TypeHandle BulletHeightfieldShape::_type_handle; /** diff --git a/panda/src/bullet/bulletHelper.cxx b/panda/src/bullet/bulletHelper.cxx index e786e34d40..fcf0678f1a 100644 --- a/panda/src/bullet/bulletHelper.cxx +++ b/panda/src/bullet/bulletHelper.cxx @@ -12,13 +12,17 @@ */ #include "bulletHelper.h" + #include "bulletRigidBodyNode.h" +#include "bulletSoftBodyNode.h" #include "bulletGhostNode.h" #include "geomLines.h" #include "geomTriangles.h" #include "geomVertexRewriter.h" +#include "bullet_utils.h" + PT(InternalName) BulletHelper::_sb_index; PT(InternalName) BulletHelper::_sb_flip; diff --git a/panda/src/bullet/bulletHelper.h b/panda/src/bullet/bulletHelper.h index f2195d4d92..4633c40928 100644 --- a/panda/src/bullet/bulletHelper.h +++ b/panda/src/bullet/bulletHelper.h @@ -23,6 +23,8 @@ #include "nodePath.h" #include "nodePathCollection.h" +class BulletSoftBodyNode; + /** * */ diff --git a/panda/src/bullet/bulletHingeConstraint.cxx b/panda/src/bullet/bulletHingeConstraint.cxx index 5cbfa44d94..9e96c82cf4 100644 --- a/panda/src/bullet/bulletHingeConstraint.cxx +++ b/panda/src/bullet/bulletHingeConstraint.cxx @@ -12,7 +12,9 @@ */ #include "bulletHingeConstraint.h" + #include "bulletRigidBodyNode.h" +#include "bulletWorld.h" #include "deg_2_rad.h" diff --git a/panda/src/bullet/bulletManifoldPoint.cxx b/panda/src/bullet/bulletManifoldPoint.cxx index b56244ed29..c32a437ac2 100644 --- a/panda/src/bullet/bulletManifoldPoint.cxx +++ b/panda/src/bullet/bulletManifoldPoint.cxx @@ -13,6 +13,8 @@ #include "bulletManifoldPoint.h" +#include "bulletWorld.h" + /** * */ diff --git a/panda/src/bullet/bulletMinkowskiSumShape.cxx b/panda/src/bullet/bulletMinkowskiSumShape.cxx index d750e22244..586968ae6d 100644 --- a/panda/src/bullet/bulletMinkowskiSumShape.cxx +++ b/panda/src/bullet/bulletMinkowskiSumShape.cxx @@ -13,6 +13,8 @@ #include "bulletMinkowskiSumShape.h" +#include "bulletWorld.h" + TypeHandle BulletMinkowskiSumShape::_type_handle; /** diff --git a/panda/src/bullet/bulletMultiSphereShape.cxx b/panda/src/bullet/bulletMultiSphereShape.cxx index 52d1edc42f..2cbf63fcfd 100644 --- a/panda/src/bullet/bulletMultiSphereShape.cxx +++ b/panda/src/bullet/bulletMultiSphereShape.cxx @@ -13,6 +13,8 @@ #include "bulletMultiSphereShape.h" +#include "bulletWorld.h" + #include "geomVertexReader.h" TypeHandle BulletMultiSphereShape::_type_handle; diff --git a/panda/src/bullet/bulletMultiSphereShape.h b/panda/src/bullet/bulletMultiSphereShape.h index d6fd7af7b7..2beb123bf5 100644 --- a/panda/src/bullet/bulletMultiSphereShape.h +++ b/panda/src/bullet/bulletMultiSphereShape.h @@ -19,6 +19,7 @@ #include "bullet_includes.h" #include "bulletShape.h" +#include "factoryParams.h" #include "pta_LVecBase3.h" #include "pta_stdfloat.h" diff --git a/panda/src/bullet/bulletPersistentManifold.cxx b/panda/src/bullet/bulletPersistentManifold.cxx index 67d760e8df..9876ff35ee 100644 --- a/panda/src/bullet/bulletPersistentManifold.cxx +++ b/panda/src/bullet/bulletPersistentManifold.cxx @@ -12,7 +12,9 @@ */ #include "bulletPersistentManifold.h" + #include "bulletManifoldPoint.h" +#include "bulletWorld.h" /** * diff --git a/panda/src/bullet/bulletPlaneShape.cxx b/panda/src/bullet/bulletPlaneShape.cxx index 98dce53577..f5dc9f9514 100644 --- a/panda/src/bullet/bulletPlaneShape.cxx +++ b/panda/src/bullet/bulletPlaneShape.cxx @@ -13,6 +13,8 @@ #include "bulletPlaneShape.h" +#include "bulletWorld.h" + TypeHandle BulletPlaneShape::_type_handle; /** diff --git a/panda/src/bullet/bulletRigidBodyNode.cxx b/panda/src/bullet/bulletRigidBodyNode.cxx index b0d36f705e..6f5bff0d46 100644 --- a/panda/src/bullet/bulletRigidBodyNode.cxx +++ b/panda/src/bullet/bulletRigidBodyNode.cxx @@ -12,7 +12,11 @@ */ #include "bulletRigidBodyNode.h" + +#include "config_bullet.h" + #include "bulletShape.h" +#include "bulletWorld.h" TypeHandle BulletRigidBodyNode::_type_handle; diff --git a/panda/src/bullet/bulletRotationalLimitMotor.cxx b/panda/src/bullet/bulletRotationalLimitMotor.cxx index d521b7ad94..3fed47f4f7 100644 --- a/panda/src/bullet/bulletRotationalLimitMotor.cxx +++ b/panda/src/bullet/bulletRotationalLimitMotor.cxx @@ -13,6 +13,8 @@ #include "bulletRotationalLimitMotor.h" +#include "bulletWorld.h" + /** * */ diff --git a/panda/src/bullet/bulletShape.cxx b/panda/src/bullet/bulletShape.cxx index 49bd6e4f92..dcc41f1243 100644 --- a/panda/src/bullet/bulletShape.cxx +++ b/panda/src/bullet/bulletShape.cxx @@ -12,6 +12,9 @@ */ #include "bulletShape.h" + +#include "bulletWorld.h" + #include "bullet_utils.h" TypeHandle BulletShape::_type_handle; diff --git a/panda/src/bullet/bulletShape.h b/panda/src/bullet/bulletShape.h index e9dd08bf14..7b368c987c 100644 --- a/panda/src/bullet/bulletShape.h +++ b/panda/src/bullet/bulletShape.h @@ -18,7 +18,7 @@ #include "bullet_includes.h" -#include "typedReferenceCount.h" +#include "typedWritableReferenceCount.h" #include "boundingSphere.h" /** diff --git a/panda/src/bullet/bulletSliderConstraint.cxx b/panda/src/bullet/bulletSliderConstraint.cxx index c803f509cd..6712120cd8 100644 --- a/panda/src/bullet/bulletSliderConstraint.cxx +++ b/panda/src/bullet/bulletSliderConstraint.cxx @@ -12,7 +12,9 @@ */ #include "bulletSliderConstraint.h" + #include "bulletRigidBodyNode.h" +#include "bulletWorld.h" #include "deg_2_rad.h" diff --git a/panda/src/bullet/bulletSoftBodyConfig.cxx b/panda/src/bullet/bulletSoftBodyConfig.cxx index a6db77cb96..861387a397 100644 --- a/panda/src/bullet/bulletSoftBodyConfig.cxx +++ b/panda/src/bullet/bulletSoftBodyConfig.cxx @@ -13,6 +13,10 @@ #include "bulletSoftBodyConfig.h" +#include "bulletWorld.h" + +#include "lightMutexHolder.h" + /** * */ diff --git a/panda/src/bullet/bulletSoftBodyConfig.h b/panda/src/bullet/bulletSoftBodyConfig.h index 18bbd49dfa..3d2bf30e42 100644 --- a/panda/src/bullet/bulletSoftBodyConfig.h +++ b/panda/src/bullet/bulletSoftBodyConfig.h @@ -18,6 +18,8 @@ #include "bullet_includes.h" +#include "numeric_types.h" + /** * */ diff --git a/panda/src/bullet/bulletSoftBodyMaterial.I b/panda/src/bullet/bulletSoftBodyMaterial.I index 7514fc7cbf..13326a54d9 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.I +++ b/panda/src/bullet/bulletSoftBodyMaterial.I @@ -30,3 +30,12 @@ empty() { return BulletSoftBodyMaterial(material); } + +/** + * + */ +INLINE btSoftBody::Material &BulletSoftBodyMaterial:: +get_material() const { + + return _material; +} diff --git a/panda/src/bullet/bulletSoftBodyMaterial.cxx b/panda/src/bullet/bulletSoftBodyMaterial.cxx index d40a7bd984..052cd5a8aa 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.cxx +++ b/panda/src/bullet/bulletSoftBodyMaterial.cxx @@ -13,6 +13,8 @@ #include "bulletSoftBodyMaterial.h" +#include "bulletWorld.h" + /** * */ @@ -21,15 +23,6 @@ BulletSoftBodyMaterial(btSoftBody::Material &material) : _material(material) { } -/** - * - */ -btSoftBody::Material &BulletSoftBodyMaterial:: -get_material() const { - - return _material; -} - /** * Getter for the property m_kLST. */ diff --git a/panda/src/bullet/bulletSoftBodyMaterial.h b/panda/src/bullet/bulletSoftBodyMaterial.h index bf8c8589a9..3df77904d8 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.h +++ b/panda/src/bullet/bulletSoftBodyMaterial.h @@ -18,6 +18,8 @@ #include "bullet_includes.h" +#include "numeric_types.h" + /** * */ diff --git a/panda/src/bullet/bulletSoftBodyNode.cxx b/panda/src/bullet/bulletSoftBodyNode.cxx index cf027f208d..f4ae8d2120 100644 --- a/panda/src/bullet/bulletSoftBodyNode.cxx +++ b/panda/src/bullet/bulletSoftBodyNode.cxx @@ -12,12 +12,14 @@ */ #include "bulletSoftBodyNode.h" + #include "bulletSoftBodyConfig.h" #include "bulletSoftBodyControl.h" #include "bulletSoftBodyMaterial.h" #include "bulletSoftBodyShape.h" #include "bulletSoftBodyWorldInfo.h" #include "bulletHelper.h" +#include "bulletWorld.h" #include "geomVertexRewriter.h" #include "geomVertexReader.h" diff --git a/panda/src/bullet/bulletSoftBodyNode.h b/panda/src/bullet/bulletSoftBodyNode.h index 26d7cc6fce..e19b6c730f 100644 --- a/panda/src/bullet/bulletSoftBodyNode.h +++ b/panda/src/bullet/bulletSoftBodyNode.h @@ -29,6 +29,7 @@ #include "nurbsSurfaceEvaluator.h" #include "pta_LVecBase3.h" +class BulletRigidBodyNode; class BulletSoftBodyConfig; class BulletSoftBodyControl; class BulletSoftBodyMaterial; diff --git a/panda/src/bullet/bulletSoftBodyShape.cxx b/panda/src/bullet/bulletSoftBodyShape.cxx index c6df128687..0f47e470e0 100644 --- a/panda/src/bullet/bulletSoftBodyShape.cxx +++ b/panda/src/bullet/bulletSoftBodyShape.cxx @@ -12,7 +12,9 @@ */ #include "bulletSoftBodyShape.h" + #include "bulletSoftBodyNode.h" +#include "bulletWorld.h" TypeHandle BulletSoftBodyShape::_type_handle; diff --git a/panda/src/bullet/bulletSoftBodyWorldInfo.cxx b/panda/src/bullet/bulletSoftBodyWorldInfo.cxx index 2fb6957c29..eb18b9d6fc 100644 --- a/panda/src/bullet/bulletSoftBodyWorldInfo.cxx +++ b/panda/src/bullet/bulletSoftBodyWorldInfo.cxx @@ -13,6 +13,8 @@ #include "bulletSoftBodyWorldInfo.h" +#include "bulletWorld.h" + /** * */ diff --git a/panda/src/bullet/bulletSphereShape.cxx b/panda/src/bullet/bulletSphereShape.cxx index b05e09e418..a2965bb16a 100644 --- a/panda/src/bullet/bulletSphereShape.cxx +++ b/panda/src/bullet/bulletSphereShape.cxx @@ -13,6 +13,8 @@ #include "bulletSphereShape.h" +#include "bulletWorld.h" + TypeHandle BulletSphereShape::_type_handle; /** diff --git a/panda/src/bullet/bulletSphericalConstraint.cxx b/panda/src/bullet/bulletSphericalConstraint.cxx index 8686e1d546..b07d96c649 100644 --- a/panda/src/bullet/bulletSphericalConstraint.cxx +++ b/panda/src/bullet/bulletSphericalConstraint.cxx @@ -12,7 +12,9 @@ */ #include "bulletSphericalConstraint.h" + #include "bulletRigidBodyNode.h" +#include "bulletWorld.h" TypeHandle BulletSphericalConstraint::_type_handle; diff --git a/panda/src/bullet/bulletTranslationalLimitMotor.cxx b/panda/src/bullet/bulletTranslationalLimitMotor.cxx index 48dd7ae3e8..fb5e6b93a4 100644 --- a/panda/src/bullet/bulletTranslationalLimitMotor.cxx +++ b/panda/src/bullet/bulletTranslationalLimitMotor.cxx @@ -13,6 +13,8 @@ #include "bulletTranslationalLimitMotor.h" +#include "bulletWorld.h" + /** * */ diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index 368aa22fac..ac487be61e 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/panda/src/bullet/bulletTriangleMesh.cxx @@ -13,7 +13,10 @@ #include "bulletTriangleMesh.h" +#include "bulletWorld.h" + #include "pvector.h" +#include "geomTriangles.h" #include "geomVertexData.h" #include "geomVertexReader.h" diff --git a/panda/src/bullet/bulletTriangleMeshShape.cxx b/panda/src/bullet/bulletTriangleMeshShape.cxx index 8416c52cbc..688bccd478 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.cxx +++ b/panda/src/bullet/bulletTriangleMeshShape.cxx @@ -12,7 +12,11 @@ */ #include "bulletTriangleMeshShape.h" + +#include "config_bullet.h" + #include "bulletTriangleMesh.h" +#include "bulletWorld.h" #include "nodePathCollection.h" #include "geomNode.h" diff --git a/panda/src/bullet/bulletTriangleMeshShape.h b/panda/src/bullet/bulletTriangleMeshShape.h index 199efb75d1..fcfb9281a0 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.h +++ b/panda/src/bullet/bulletTriangleMeshShape.h @@ -19,6 +19,7 @@ #include "bullet_includes.h" #include "bulletShape.h" +#include "factoryParams.h" #include "luse.h" class BulletTriangleMesh; diff --git a/panda/src/bullet/bulletVehicle.cxx b/panda/src/bullet/bulletVehicle.cxx index 5dbb70cc7f..f4321cd911 100644 --- a/panda/src/bullet/bulletVehicle.cxx +++ b/panda/src/bullet/bulletVehicle.cxx @@ -12,6 +12,9 @@ */ #include "bulletVehicle.h" + +#include "config_bullet.h" + #include "bulletWorld.h" #include "bulletRigidBodyNode.h" #include "bulletWheel.h" diff --git a/panda/src/bullet/bulletWheel.cxx b/panda/src/bullet/bulletWheel.cxx index c24369546b..21a6eefd76 100644 --- a/panda/src/bullet/bulletWheel.cxx +++ b/panda/src/bullet/bulletWheel.cxx @@ -13,6 +13,8 @@ #include "bulletWheel.h" +#include "bulletWorld.h" + /** * */ diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index e1e416a2bb..930fe10111 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -12,9 +12,14 @@ */ #include "bulletWorld.h" + +#include "config_bullet.h" + +#include "bulletFilterCallbackData.h" #include "bulletPersistentManifold.h" #include "bulletShape.h" #include "bulletSoftBodyWorldInfo.h" +#include "bulletTickCallbackData.h" #include "collideMask.h" #include "lightMutexHolder.h" diff --git a/panda/src/bullet/bullet_utils.h b/panda/src/bullet/bullet_utils.h index b1577ede5e..080c70986a 100644 --- a/panda/src/bullet/bullet_utils.h +++ b/panda/src/bullet/bullet_utils.h @@ -44,6 +44,8 @@ EXPCL_PANDABULLET CPT(TransformState) btTrans_to_TransformState( EXPCL_PANDABULLET btTransform TransformState_to_btTrans( CPT(TransformState) ts); +EXPCL_PANDABULLET void get_node_transform(btTransform &trans, PandaNode *node); + // UpAxis BEGIN_PUBLISH diff --git a/panda/src/bullet/config_bullet.cxx b/panda/src/bullet/config_bullet.cxx index 5997bf575b..f9eed1b6b8 100644 --- a/panda/src/bullet/config_bullet.cxx +++ b/panda/src/bullet/config_bullet.cxx @@ -56,7 +56,7 @@ extern ContactDestroyedCallback gContactDestroyedCallback; #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDABULLET) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDABULLET) #error Buildsystem error: BUILDING_PANDABULLET not defined #endif diff --git a/panda/src/chan/config_chan.cxx b/panda/src/chan/config_chan.cxx index 8992cfbbf9..3a049d67f6 100644 --- a/panda/src/chan/config_chan.cxx +++ b/panda/src/chan/config_chan.cxx @@ -34,7 +34,7 @@ #include "luse.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_CHAN) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_CHAN) #error Buildsystem error: BUILDING_PANDA_CHAN not defined #endif diff --git a/panda/src/char/config_char.cxx b/panda/src/char/config_char.cxx index 5d536bfc4c..25ab775316 100644 --- a/panda/src/char/config_char.cxx +++ b/panda/src/char/config_char.cxx @@ -21,7 +21,7 @@ #include "jointVertexTransform.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_CHAR) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_CHAR) #error Buildsystem error: BUILDING_PANDA_CHAR not defined #endif diff --git a/panda/src/cocoadisplay/config_cocoadisplay.mm b/panda/src/cocoadisplay/config_cocoadisplay.mm index a41e5bc579..96662d6c9c 100644 --- a/panda/src/cocoadisplay/config_cocoadisplay.mm +++ b/panda/src/cocoadisplay/config_cocoadisplay.mm @@ -20,7 +20,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_COCOADISPLAY) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_COCOADISPLAY) #error Buildsystem error: BUILDING_PANDA_COCOADISPLAY not defined #endif diff --git a/panda/src/collada/config_collada.cxx b/panda/src/collada/config_collada.cxx index fa97023656..1fec2da68e 100644 --- a/panda/src/collada/config_collada.cxx +++ b/panda/src/collada/config_collada.cxx @@ -17,7 +17,7 @@ #include "loaderFileTypeDae.h" #include "loaderFileTypeRegistry.h" -#if !defined(CPPPARSER) && !defined(BUILDING_COLLADA) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_COLLADA) #error Buildsystem error: BUILDING_COLLADA not defined #endif diff --git a/panda/src/collide/config_collide.cxx b/panda/src/collide/config_collide.cxx index 01d517df04..38c821ed05 100644 --- a/panda/src/collide/config_collide.cxx +++ b/panda/src/collide/config_collide.cxx @@ -42,7 +42,7 @@ #include "collisionVisualizer.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_COLLIDE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_COLLIDE) #error Buildsystem error: BUILDING_PANDA_COLLIDE not defined #endif diff --git a/panda/src/cull/config_cull.cxx b/panda/src/cull/config_cull.cxx index 452c69ea0c..04ce4ca63c 100644 --- a/panda/src/cull/config_cull.cxx +++ b/panda/src/cull/config_cull.cxx @@ -22,7 +22,7 @@ #include "cullBinManager.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_CULL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_CULL) #error Buildsystem error: BUILDING_PANDA_CULL not defined #endif diff --git a/panda/src/device/config_device.cxx b/panda/src/device/config_device.cxx index c04f6e9b26..73993e3931 100644 --- a/panda/src/device/config_device.cxx +++ b/panda/src/device/config_device.cxx @@ -30,7 +30,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DEVICE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_DEVICE) #error Buildsystem error: BUILDING_PANDA_DEVICE not defined #endif diff --git a/panda/src/dgraph/config_dgraph.cxx b/panda/src/dgraph/config_dgraph.cxx index 3c91aeea18..5a107635b7 100644 --- a/panda/src/dgraph/config_dgraph.cxx +++ b/panda/src/dgraph/config_dgraph.cxx @@ -17,7 +17,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DGRAPH) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_DGRAPH) #error Buildsystem error: BUILDING_PANDA_DGRAPH not defined #endif diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index 4d6399c216..78c0b17418 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -33,7 +33,7 @@ #include "subprocessWindow.h" #include "windowHandle.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DISPLAY) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_DISPLAY) #error Buildsystem error: BUILDING_PANDA_DISPLAY not defined #endif diff --git a/panda/src/distort/config_distort.cxx b/panda/src/distort/config_distort.cxx index eaa0147dae..b14f9aae45 100644 --- a/panda/src/distort/config_distort.cxx +++ b/panda/src/distort/config_distort.cxx @@ -20,7 +20,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAFX) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAFX) #error Buildsystem error: BUILDING_PANDAFX not defined #endif diff --git a/panda/src/downloader/config_downloader.cxx b/panda/src/downloader/config_downloader.cxx index 4e60b4028c..cd8f1de723 100644 --- a/panda/src/downloader/config_downloader.cxx +++ b/panda/src/downloader/config_downloader.cxx @@ -19,7 +19,7 @@ #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DOWNLOADER) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_DOWNLOADER) #error Buildsystem error: BUILDING_PANDA_DOWNLOADER not defined #endif diff --git a/panda/src/dxgsg9/config_dxgsg9.cxx b/panda/src/dxgsg9/config_dxgsg9.cxx index d5777602db..07ebca58a0 100644 --- a/panda/src/dxgsg9/config_dxgsg9.cxx +++ b/panda/src/dxgsg9/config_dxgsg9.cxx @@ -27,7 +27,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDADX) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDADX) #error Buildsystem error: BUILDING_PANDADX not defined #endif diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 0e5687d490..0921350629 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -3463,7 +3463,7 @@ do_issue_material() { cur_material.Emissive = *(D3DCOLORVALUE *)(color.get_data()); cur_material.Power = material->get_shininess(); - if (material->has_diffuse()) { + if (material->has_diffuse() || material->has_base_color()) { // If the material specifies an diffuse color, use it. set_render_state(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL); } else { @@ -3476,7 +3476,7 @@ do_issue_material() { set_render_state(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1); } } - if (material->has_ambient()) { + if (material->has_ambient() || material->has_base_color()) { // If the material specifies an ambient color, use it. set_render_state(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL); } else { @@ -3490,7 +3490,7 @@ do_issue_material() { } } - if (material->has_specular()) { + if (material->has_specular() || material->has_base_color()) { set_render_state(D3DRS_SPECULARENABLE, TRUE); } else { set_render_state(D3DRS_SPECULARENABLE, FALSE); diff --git a/panda/src/dxml/config_dxml.cxx b/panda/src/dxml/config_dxml.cxx index 0441f1fdc5..bbc119cb14 100644 --- a/panda/src/dxml/config_dxml.cxx +++ b/panda/src/dxml/config_dxml.cxx @@ -19,7 +19,7 @@ BEGIN_PUBLISH #include "tinyxml.h" END_PUBLISH -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DXML) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_DXML) #error Buildsystem error: BUILDING_PANDA_DXML not defined #endif diff --git a/panda/src/egg/config_egg.cxx b/panda/src/egg/config_egg.cxx index ec0009819f..cbcc00d32f 100644 --- a/panda/src/egg/config_egg.cxx +++ b/panda/src/egg/config_egg.cxx @@ -58,7 +58,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_EGG) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_EGG) #error Buildsystem error: BUILDING_PANDA_EGG not defined #endif diff --git a/panda/src/egg/eggVertexPool.cxx b/panda/src/egg/eggVertexPool.cxx index 8fa3b5e637..6f2768599e 100644 --- a/panda/src/egg/eggVertexPool.cxx +++ b/panda/src/egg/eggVertexPool.cxx @@ -677,7 +677,15 @@ transform(const LMatrix4d &mat) { typedef pvector Verts; Verts verts; verts.reserve(size()); + + // Work around MSVC 2017 compiler bug, see GitHub issue #379 +#ifdef _MSC_VER + for (const IndexVertices::value_type &v : _index_vertices) { + verts.push_back(v.second); + } +#else std::copy(begin(), end(), std::back_inserter(verts)); +#endif Verts::const_iterator vi; for (vi = verts.begin(); vi != verts.end(); ++vi) { diff --git a/panda/src/egg2pg/config_egg2pg.cxx b/panda/src/egg2pg/config_egg2pg.cxx index 36247ad2c4..e32aa19914 100644 --- a/panda/src/egg2pg/config_egg2pg.cxx +++ b/panda/src/egg2pg/config_egg2pg.cxx @@ -20,7 +20,7 @@ #include "configVariableCore.h" #include "eggRenderState.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_EGG2PG) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_EGG2PG) #error Buildsystem error: BUILDING_PANDA_EGG2PG not defined #endif diff --git a/panda/src/egldisplay/config_egldisplay.cxx b/panda/src/egldisplay/config_egldisplay.cxx index f76b1b9d1f..2f8e99cc0f 100644 --- a/panda/src/egldisplay/config_egldisplay.cxx +++ b/panda/src/egldisplay/config_egldisplay.cxx @@ -19,7 +19,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGLES) && !defined(BUILDING_PANDAGLES2) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAGLES) && !defined(BUILDING_PANDAGLES2) #error Buildsystem error: BUILDING_PANDAGLES(2) not defined #endif diff --git a/panda/src/event/asyncTaskManager.cxx b/panda/src/event/asyncTaskManager.cxx index b80908ddc5..a570609f8a 100644 --- a/panda/src/event/asyncTaskManager.cxx +++ b/panda/src/event/asyncTaskManager.cxx @@ -643,6 +643,7 @@ void AsyncTaskManager:: make_global_ptr() { nassertv(_global_ptr == nullptr); + init_memory_hook(); _global_ptr = new AsyncTaskManager("TaskManager"); _global_ptr->ref(); } diff --git a/panda/src/event/config_event.cxx b/panda/src/event/config_event.cxx index c7f1c8eecc..ccae0d95ae 100644 --- a/panda/src/event/config_event.cxx +++ b/panda/src/event/config_event.cxx @@ -27,7 +27,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_EVENT) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_EVENT) #error Buildsystem error: BUILDING_PANDA_EVENT not defined #endif diff --git a/panda/src/event/eventHandler.cxx b/panda/src/event/eventHandler.cxx index f74bd8c519..e3e389e1bf 100644 --- a/panda/src/event/eventHandler.cxx +++ b/panda/src/event/eventHandler.cxx @@ -351,6 +351,7 @@ remove_all_hooks() { */ void EventHandler:: make_global_event_handler() { + init_memory_hook(); _global_event_handler = new EventHandler(EventQueue::get_global_event_queue()); } diff --git a/panda/src/event/eventQueue.cxx b/panda/src/event/eventQueue.cxx index bbd07a3725..69c025734c 100644 --- a/panda/src/event/eventQueue.cxx +++ b/panda/src/event/eventQueue.cxx @@ -106,5 +106,6 @@ dequeue_event() { */ void EventQueue:: make_global_event_queue() { + init_memory_hook(); _global_event_queue = new EventQueue; } diff --git a/panda/src/express/config_express.cxx b/panda/src/express/config_express.cxx index 3a4343ac32..c9e664db34 100644 --- a/panda/src/express/config_express.cxx +++ b/panda/src/express/config_express.cxx @@ -36,7 +36,7 @@ #include "dconfig.h" #include "streamWrapper.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_EXPRESS) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_EXPRESS) #error Buildsystem error: BUILDING_PANDA_EXPRESS not defined #endif diff --git a/panda/src/ffmpeg/config_ffmpeg.cxx b/panda/src/ffmpeg/config_ffmpeg.cxx index 850cf62937..27270757a8 100644 --- a/panda/src/ffmpeg/config_ffmpeg.cxx +++ b/panda/src/ffmpeg/config_ffmpeg.cxx @@ -26,7 +26,7 @@ extern "C" { #include "libavutil/avutil.h" } -#if !defined(CPPPARSER) && !defined(BUILDING_FFMPEG) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_FFMPEG) #error Buildsystem error: BUILDING_FFMPEG not defined #endif diff --git a/panda/src/framework/config_framework.cxx b/panda/src/framework/config_framework.cxx index 4ddc4b553a..febf588dd8 100644 --- a/panda/src/framework/config_framework.cxx +++ b/panda/src/framework/config_framework.cxx @@ -16,7 +16,7 @@ #include "dconfig.h" #include "windowFramework.h" -#if !defined(CPPPARSER) && !defined(BUILDING_FRAMEWORK) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_FRAMEWORK) #error Buildsystem error: BUILDING_FRAMEWORK not defined #endif diff --git a/panda/src/gles2gsg/config_gles2gsg.cxx b/panda/src/gles2gsg/config_gles2gsg.cxx index aee9c925fb..0e5a71aadb 100644 --- a/panda/src/gles2gsg/config_gles2gsg.cxx +++ b/panda/src/gles2gsg/config_gles2gsg.cxx @@ -16,7 +16,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGLES2) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAGLES2) #error Buildsystem error: BUILDING_PANDAGLES2 not defined #endif diff --git a/panda/src/glesgsg/config_glesgsg.cxx b/panda/src/glesgsg/config_glesgsg.cxx index b30cf23322..77d711f1f5 100644 --- a/panda/src/glesgsg/config_glesgsg.cxx +++ b/panda/src/glesgsg/config_glesgsg.cxx @@ -16,7 +16,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGLES) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAGLES) #error Buildsystem error: BUILDING_PANDAGLES not defined #endif diff --git a/panda/src/glgsg/config_glgsg.cxx b/panda/src/glgsg/config_glgsg.cxx index 1c7ddcbfd5..21a3a2ec61 100644 --- a/panda/src/glgsg/config_glgsg.cxx +++ b/panda/src/glgsg/config_glgsg.cxx @@ -16,7 +16,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GLGSG) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_GLGSG) #error Buildsystem error: BUILDING_PANDA_GLGSG not defined #endif diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index fb22fdb644..48b9112387 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -7627,7 +7627,7 @@ do_issue_material() { call_glMaterialfv(face, GL_EMISSION, material->get_emission()); glMaterialf(face, GL_SHININESS, max(min(material->get_shininess(), (PN_stdfloat)128), (PN_stdfloat)0)); - if (material->has_ambient() && material->has_diffuse()) { + if ((material->has_ambient() && material->has_diffuse()) || material->has_base_color()) { // The material has both an ambient and diffuse specified. This means we // do not need glMaterialColor(). glDisable(GL_COLOR_MATERIAL); diff --git a/panda/src/glxdisplay/config_glxdisplay.cxx b/panda/src/glxdisplay/config_glxdisplay.cxx index 23b8aef8fa..c7a66644d9 100644 --- a/panda/src/glxdisplay/config_glxdisplay.cxx +++ b/panda/src/glxdisplay/config_glxdisplay.cxx @@ -23,7 +23,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GLXDISPLAY) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_GLXDISPLAY) #error Buildsystem error: BUILDING_PANDA_GLXDISPLAY not defined #endif diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index 7da3b1d31e..12840f7d04 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -70,7 +70,7 @@ #include "dconfig.h" #include "string_utils.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GOBJ) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_GOBJ) #error Buildsystem error: BUILDING_PANDA_GOBJ not defined #endif diff --git a/panda/src/gobj/material.cxx b/panda/src/gobj/material.cxx index 24bc0fb590..091c7eff2f 100644 --- a/panda/src/gobj/material.cxx +++ b/panda/src/gobj/material.cxx @@ -422,7 +422,7 @@ void Material:: write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "Material " << get_name() << "\n"; if (has_base_color()) { - indent(out, indent_level + 2) << "base_color = " << get_ambient() << "\n"; + indent(out, indent_level + 2) << "base_color = " << get_base_color() << "\n"; } if (has_ambient()) { indent(out, indent_level + 2) << "ambient = " << get_ambient() << "\n"; diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 99b8d45e53..67906210f6 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -53,6 +53,7 @@ PUBLISHED: SL_Cg, SL_GLSL, SL_HLSL, + SL_SPIR_V, }; enum ShaderType { diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index 4abb480348..7d859dbda8 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -2390,8 +2390,13 @@ get_half_float(const unsigned char *&p) { uint32_t t3 = in & 0x7c00; // Exponent t1 <<= 13; // Align mantissa on MSB t2 <<= 16; // Shift sign bit into position - t1 += 0x38000000; // Adjust bias - t1 = (t3 == 0 ? 0 : t1); // Denormals-as-zero + if (t3 != 0x7c00) { + t1 += 0x38000000; // Adjust bias + t1 = (t3 == 0 ? 0 : t1); // Denormals-as-zero + } else { + // Infinity / NaN + t1 |= 0x7f800000; + } t1 |= t2; // Re-insert sign bit v.ui = t1; return v.uf; diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index c538391018..c0cd14db0a 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -5594,180 +5594,114 @@ do_set_ram_mipmap_image(CData *cdata, int n, CPTA_uchar image, size_t page_size) size_t Texture:: do_get_clear_data(const CData *cdata, unsigned char *into) const { nassertr(cdata->_has_clear_color, 0); - nassertr(cdata->_num_components <= 4, 0); + + int num_components = cdata->_num_components; + nassertr(num_components > 0, 0); + nassertr(num_components <= 4, 0); + + LVecBase4 clear_value = cdata->_clear_color; + + // Swap red and blue components. + if (num_components >= 3) { + std::swap(clear_value[0], clear_value[2]); + } switch (cdata->_component_type) { case T_unsigned_byte: if (is_srgb(cdata->_format)) { xel color; xelval alpha; - encode_sRGB_uchar(cdata->_clear_color, color, alpha); - switch (cdata->_num_components) { - case 2: - into[1] = (unsigned char)color.g; - case 1: - into[0] = (unsigned char)color.r; - break; - case 4: - into[3] = (unsigned char)alpha; - case 3: // BGR <-> RGB - into[0] = (unsigned char)color.b; - into[1] = (unsigned char)color.g; - into[2] = (unsigned char)color.r; - break; + encode_sRGB_uchar(clear_value, color, alpha); + switch (num_components) { + case 4: into[3] = (unsigned char)alpha; + case 3: into[2] = (unsigned char)color.b; + case 2: into[1] = (unsigned char)color.g; + case 1: into[0] = (unsigned char)color.r; } - break; } else { - LColor scaled = cdata->_clear_color.fmin(LColor(1)).fmax(LColor::zero()); + LColor scaled = clear_value.fmin(LColor(1)).fmax(LColor::zero()); scaled *= 255; - switch (cdata->_num_components) { - case 2: - into[1] = (unsigned char)scaled[1]; - case 1: - into[0] = (unsigned char)scaled[0]; - break; - case 4: - into[3] = (unsigned char)scaled[3]; - case 3: // BGR <-> RGB - into[0] = (unsigned char)scaled[2]; - into[1] = (unsigned char)scaled[1]; - into[2] = (unsigned char)scaled[0]; - break; + for (int i = 0; i < num_components; ++i) { + into[i] = (unsigned char)scaled[i]; } - break; } + break; case T_unsigned_short: { - LColor scaled = cdata->_clear_color.fmin(LColor(1)).fmax(LColor::zero()); + LColor scaled = clear_value.fmin(LColor(1)).fmax(LColor::zero()); scaled *= 65535; - switch (cdata->_num_components) { - case 2: - ((unsigned short *)into)[1] = (unsigned short)scaled[1]; - case 1: - ((unsigned short *)into)[0] = (unsigned short)scaled[0]; - break; - case 4: - ((unsigned short *)into)[3] = (unsigned short)scaled[3]; - case 3: // BGR <-> RGB - ((unsigned short *)into)[0] = (unsigned short)scaled[2]; - ((unsigned short *)into)[1] = (unsigned short)scaled[1]; - ((unsigned short *)into)[2] = (unsigned short)scaled[0]; - break; + for (int i = 0; i < num_components; ++i) { + ((unsigned short *)into)[i] = (unsigned short)scaled[i]; } break; } case T_float: - switch (cdata->_num_components) { - case 2: - ((float *)into)[1] = cdata->_clear_color[1]; - case 1: - ((float *)into)[0] = cdata->_clear_color[0]; - break; - case 4: - ((float *)into)[3] = cdata->_clear_color[3]; - case 3: // BGR <-> RGB - ((float *)into)[0] = cdata->_clear_color[2]; - ((float *)into)[1] = cdata->_clear_color[1]; - ((float *)into)[2] = cdata->_clear_color[0]; - break; + for (int i = 0; i < num_components; ++i) { + ((float *)into)[i] = clear_value[i]; } break; case T_unsigned_int_24_8: - nassertr(cdata->_num_components == 1, 0); + nassertr(num_components == 1, 0); *((unsigned int *)into) = - ((unsigned int)(cdata->_clear_color[0] * 16777215) << 8) + - (unsigned int)max(min(cdata->_clear_color[1], (PN_stdfloat)255), (PN_stdfloat)0); + ((unsigned int)(clear_value[0] * 16777215) << 8) + + (unsigned int)max(min(clear_value[1], (PN_stdfloat)255), (PN_stdfloat)0); break; case T_int: - { - // Note: there are no 32-bit UNORM textures. Therefore, we don't do any - // normalization here, either. - switch (cdata->_num_components) { - case 2: - ((int *)into)[1] = (int)cdata->_clear_color[1]; - case 1: - ((int *)into)[0] = (int)cdata->_clear_color[0]; - break; - case 4: - ((int *)into)[3] = (int)cdata->_clear_color[3]; - case 3: // BGR <-> RGB - ((int *)into)[0] = (int)cdata->_clear_color[2]; - ((int *)into)[1] = (int)cdata->_clear_color[1]; - ((int *)into)[2] = (int)cdata->_clear_color[0]; - break; - } - break; + // Note: there are no 32-bit UNORM textures. Therefore, we don't do any + // normalization here, either. + for (int i = 0; i < num_components; ++i) { + ((int *)into)[i] = (int)clear_value[i]; } + break; case T_byte: { - LColor scaled = cdata->_clear_color.fmin(LColor(1)).fmax(LColor(-1)); + LColor scaled = clear_value.fmin(LColor(1)).fmax(LColor(-1)); scaled *= 127; - switch (cdata->_num_components) { - case 2: - into[1] = (char)scaled[1]; - case 1: - into[0] = (char)scaled[0]; - break; - case 4: - into[3] = (char)scaled[3]; - case 3: // BGR <-> RGB - into[0] = (char)scaled[2]; - into[1] = (char)scaled[1]; - into[2] = (char)scaled[0]; - break; + for (int i = 0; i < num_components; ++i) { + ((signed char *)into)[i] = (signed char)scaled[i]; } break; } case T_short: { - LColor scaled = cdata->_clear_color.fmin(LColor(1)).fmax(LColor(-1)); + LColor scaled = clear_value.fmin(LColor(1)).fmax(LColor(-1)); scaled *= 32767; - switch (cdata->_num_components) { - case 2: - ((short *)into)[1] = (short)scaled[1]; - case 1: - ((short *)into)[0] = (short)scaled[0]; - break; - case 4: - ((short *)into)[3] = (short)scaled[3]; - case 3: // BGR <-> RGB - ((short *)into)[0] = (short)scaled[2]; - ((short *)into)[1] = (short)scaled[1]; - ((short *)into)[2] = (short)scaled[0]; - break; + for (int i = 0; i < num_components; ++i) { + ((short *)into)[i] = (short)scaled[i]; } break; } + case T_half_float: + for (int i = 0; i < num_components; ++i) { + union { + uint32_t ui; + float uf; + } v; + v.uf = clear_value[i]; + uint16_t sign = ((v.ui & 0x80000000u) >> 16u); + uint32_t mantissa = (v.ui & 0x007fffffu); + uint16_t exponent = (uint16_t)std::min(std::max((int)((v.ui & 0x7f800000u) >> 23u) - 112, 0), 31); + mantissa += (mantissa & 0x00001000u) << 1u; + ((uint16_t *)into)[i] = (uint16_t)(sign | ((exponent << 10u) | (mantissa >> 13u))); + } + break; + case T_unsigned_int: - { - // Note: there are no 32-bit UNORM textures. Therefore, we don't do any - // normalization here, either. - switch (cdata->_num_components) { - case 2: - ((unsigned int *)into)[1] = (unsigned int)cdata->_clear_color[1]; - case 1: - ((unsigned int *)into)[0] = (unsigned int)cdata->_clear_color[0]; - break; - case 4: - ((unsigned int *)into)[3] = (unsigned int)cdata->_clear_color[3]; - case 3: // BGR <-> RGB - ((unsigned int *)into)[0] = (unsigned int)cdata->_clear_color[2]; - ((unsigned int *)into)[1] = (unsigned int)cdata->_clear_color[1]; - ((unsigned int *)into)[2] = (unsigned int)cdata->_clear_color[0]; - break; - } - break; + // Note: there are no 32-bit UNORM textures. Therefore, we don't do any + // normalization here, either. + for (int i = 0; i < num_components; ++i) { + ((unsigned int *)into)[i] = (unsigned int)clear_value[i]; } } - return cdata->_num_components * cdata->_component_width; + return num_components * cdata->_component_width; } /** diff --git a/panda/src/grutil/config_grutil.cxx b/panda/src/grutil/config_grutil.cxx index 337abd11bb..6f74fd5e1b 100644 --- a/panda/src/grutil/config_grutil.cxx +++ b/panda/src/grutil/config_grutil.cxx @@ -27,7 +27,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GRUTIL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_GRUTIL) #error Buildsystem error: BUILDING_PANDA_GRUTIL not defined #endif diff --git a/panda/src/gsgbase/config_gsgbase.cxx b/panda/src/gsgbase/config_gsgbase.cxx index 52da83f9c8..bb60e50533 100644 --- a/panda/src/gsgbase/config_gsgbase.cxx +++ b/panda/src/gsgbase/config_gsgbase.cxx @@ -17,7 +17,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GSGBASE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_GSGBASE) #error Buildsystem error: BUILDING_PANDA_GSGBASE not defined #endif diff --git a/panda/src/linmath/config_linmath.cxx b/panda/src/linmath/config_linmath.cxx index fb0942aa55..c93eb8caac 100644 --- a/panda/src/linmath/config_linmath.cxx +++ b/panda/src/linmath/config_linmath.cxx @@ -17,7 +17,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_LINMATH) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_LINMATH) #error Buildsystem error: BUILDING_PANDA_LINMATH not defined #endif diff --git a/panda/src/mathutil/config_mathutil.cxx b/panda/src/mathutil/config_mathutil.cxx index 2084b2b670..bb10014f0c 100644 --- a/panda/src/mathutil/config_mathutil.cxx +++ b/panda/src/mathutil/config_mathutil.cxx @@ -26,7 +26,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_MATHUTIL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_MATHUTIL) #error Buildsystem error: BUILDING_PANDA_MATHUTIL not defined #endif diff --git a/panda/src/movies/config_movies.cxx b/panda/src/movies/config_movies.cxx index 93448cfe8d..f6e889b6e8 100644 --- a/panda/src/movies/config_movies.cxx +++ b/panda/src/movies/config_movies.cxx @@ -32,7 +32,7 @@ #include "wavAudio.h" #include "wavAudioCursor.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_MOVIES) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_MOVIES) #error Buildsystem error: BUILDING_PANDA_MOVIES not defined #endif diff --git a/panda/src/movies/movieAudio.h b/panda/src/movies/movieAudio.h index cce8eb3465..819f501e35 100644 --- a/panda/src/movies/movieAudio.h +++ b/panda/src/movies/movieAudio.h @@ -43,7 +43,7 @@ class MovieAudioCursor; */ class EXPCL_PANDA_MOVIES MovieAudio : public TypedWritableReferenceCount, public Namable { PUBLISHED: - MovieAudio(const std::string &name = "Blank Audio"); + explicit MovieAudio(const std::string &name = "Blank Audio"); virtual ~MovieAudio(); virtual PT(MovieAudioCursor) open(); static PT(MovieAudio) get(const Filename &name); diff --git a/panda/src/nativenet/config_nativenet.cxx b/panda/src/nativenet/config_nativenet.cxx index 172e56afa8..f90e106e81 100644 --- a/panda/src/nativenet/config_nativenet.cxx +++ b/panda/src/nativenet/config_nativenet.cxx @@ -26,7 +26,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_NATIVENET) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_NATIVENET) #error Buildsystem error: BUILDING_PANDA_NATIVENET not defined #endif diff --git a/panda/src/net/config_net.cxx b/panda/src/net/config_net.cxx index 80af80147a..753a5beb53 100644 --- a/panda/src/net/config_net.cxx +++ b/panda/src/net/config_net.cxx @@ -18,7 +18,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_NET) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_NET) #error Buildsystem error: BUILDING_PANDA_NET not defined #endif diff --git a/panda/src/ode/config_ode.cxx b/panda/src/ode/config_ode.cxx index 214281d579..a87bb6922e 100644 --- a/panda/src/ode/config_ode.cxx +++ b/panda/src/ode/config_ode.cxx @@ -47,7 +47,7 @@ #include "odeCollisionEntry.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAODE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAODE) #error Buildsystem error: BUILDING_PANDAODE not defined #endif diff --git a/panda/src/osxdisplay/config_osxdisplay.cxx b/panda/src/osxdisplay/config_osxdisplay.cxx index 43f897b862..0ebc9454bd 100644 --- a/panda/src/osxdisplay/config_osxdisplay.cxx +++ b/panda/src/osxdisplay/config_osxdisplay.cxx @@ -20,7 +20,7 @@ #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_OSXDISPLAY) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_OSXDISPLAY) #error Buildsystem error: BUILDING_PANDA_OSXDISPLAY not defined #endif diff --git a/panda/src/parametrics/config_parametrics.cxx b/panda/src/parametrics/config_parametrics.cxx index 2b07e493bd..0ab86efcf7 100644 --- a/panda/src/parametrics/config_parametrics.cxx +++ b/panda/src/parametrics/config_parametrics.cxx @@ -22,7 +22,7 @@ #include "ropeNode.h" #include "sheetNode.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PARAMETRICS) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PARAMETRICS) #error Buildsystem error: BUILDING_PANDA_PARAMETRICS not defined #endif diff --git a/panda/src/particlesystem/config_particlesystem.cxx b/panda/src/particlesystem/config_particlesystem.cxx index 61f1224ea4..92f19c8f15 100644 --- a/panda/src/particlesystem/config_particlesystem.cxx +++ b/panda/src/particlesystem/config_particlesystem.cxx @@ -16,7 +16,7 @@ #include "geomParticleRenderer.h" #include "geomNode.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PARTICLESYSTEM) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PARTICLESYSTEM) #error Buildsystem error: BUILDING_PANDA_PARTICLESYSTEM not defined #endif diff --git a/panda/src/pgraph/config_pgraph.cxx b/panda/src/pgraph/config_pgraph.cxx index 54fa621f7b..e969dee72f 100644 --- a/panda/src/pgraph/config_pgraph.cxx +++ b/panda/src/pgraph/config_pgraph.cxx @@ -92,7 +92,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PGRAPH) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PGRAPH) #error Buildsystem error: BUILDING_PANDA_PGRAPH not defined #endif diff --git a/panda/src/pgraph/cullableObject.cxx b/panda/src/pgraph/cullableObject.cxx index dae73b00ed..920e524659 100644 --- a/panda/src/pgraph/cullableObject.cxx +++ b/panda/src/pgraph/cullableObject.cxx @@ -90,6 +90,15 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger, geom_rendering = _internal_transform->get_geom_rendering(geom_rendering); unsupported_bits = geom_rendering & ~gsg_bits; + if (unsupported_bits & Geom::GR_per_point_size) { + // If we have a shader that processes the point size, we can assume it + // does the right thing. + const ShaderAttrib *sattr; + if (_state->get_attrib(sattr) && sattr->get_flag(ShaderAttrib::F_shader_point_size)) { + unsupported_bits &= ~Geom::GR_per_point_size; + } + } + if (geom_rendering & Geom::GR_point_bits) { if (geom_reader.get_primitive_type() != Geom::PT_points) { if (singular_points || diff --git a/panda/src/pgraphnodes/config_pgraphnodes.cxx b/panda/src/pgraphnodes/config_pgraphnodes.cxx index 3879a980b3..309605b201 100644 --- a/panda/src/pgraphnodes/config_pgraphnodes.cxx +++ b/panda/src/pgraphnodes/config_pgraphnodes.cxx @@ -37,7 +37,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PGRAPHNODES) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PGRAPHNODES) #error Buildsystem error: BUILDING_PANDA_PGRAPHNODES not defined #endif diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index f52d0f4579..d954ddcafc 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -258,6 +258,11 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { // states to be rehashed. mat->mark_used_by_auto_shader(); key._material_flags = mat->get_flags(); + + if ((key._material_flags & Material::F_base_color) != 0) { + key._material_flags |= (Material::F_diffuse | Material::F_specular | Material::F_ambient); + key._material_flags &= ~Material::F_base_color; + } } // Break out the lights by type. diff --git a/panda/src/pgui/config_pgui.cxx b/panda/src/pgui/config_pgui.cxx index c2c3e72405..bb334756e3 100644 --- a/panda/src/pgui/config_pgui.cxx +++ b/panda/src/pgui/config_pgui.cxx @@ -28,7 +28,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PGUI) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PGUI) #error Buildsystem error: BUILDING_PANDA_PGUI not defined #endif diff --git a/panda/src/pgui/pgItem.cxx b/panda/src/pgui/pgItem.cxx index a266547ced..aeff5bff25 100644 --- a/panda/src/pgui/pgItem.cxx +++ b/panda/src/pgui/pgItem.cxx @@ -147,8 +147,8 @@ void PGItem:: transform_changed() { LightReMutexHolder holder(_lock); PandaNode::transform_changed(); - if (has_notify()) { - get_notify()->item_transform_changed(this); + if (_notify != nullptr) { + _notify->item_transform_changed(this); } } @@ -161,8 +161,8 @@ void PGItem:: draw_mask_changed() { LightReMutexHolder holder(_lock); PandaNode::draw_mask_changed(); - if (has_notify()) { - get_notify()->item_draw_mask_changed(this); + if (_notify != nullptr) { + _notify->item_draw_mask_changed(this); } } @@ -530,8 +530,8 @@ enter_region(const MouseWatcherParameter ¶m) { play_sound(event); throw_event(event, EventParameter(ep)); - if (has_notify()) { - get_notify()->item_enter(this, param); + if (_notify != nullptr) { + _notify->item_enter(this, param); } } @@ -554,8 +554,8 @@ exit_region(const MouseWatcherParameter ¶m) { play_sound(event); throw_event(event, EventParameter(ep)); - if (has_notify()) { - get_notify()->item_exit(this, param); + if (_notify != nullptr) { + _notify->item_exit(this, param); } // pgui_cat.info() << get_name() << "::exit()" << endl; @@ -580,8 +580,8 @@ within_region(const MouseWatcherParameter ¶m) { play_sound(event); throw_event(event, EventParameter(ep)); - if (has_notify()) { - get_notify()->item_within(this, param); + if (_notify != nullptr) { + _notify->item_within(this, param); } } @@ -602,8 +602,8 @@ without_region(const MouseWatcherParameter ¶m) { play_sound(event); throw_event(event, EventParameter(ep)); - if (has_notify()) { - get_notify()->item_without(this, param); + if (_notify != nullptr) { + _notify->item_without(this, param); } } @@ -623,8 +623,8 @@ focus_in() { play_sound(event); throw_event(event); - if (has_notify()) { - get_notify()->item_focus_in(this); + if (_notify != nullptr) { + _notify->item_focus_in(this); } } @@ -644,8 +644,8 @@ focus_out() { play_sound(event); throw_event(event); - if (has_notify()) { - get_notify()->item_focus_out(this); + if (_notify != nullptr) { + _notify->item_focus_out(this); } } @@ -673,8 +673,8 @@ press(const MouseWatcherParameter ¶m, bool background) { throw_event(event, EventParameter(ep)); } - if (has_notify()) { - get_notify()->item_press(this, param); + if (_notify != nullptr) { + _notify->item_press(this, param); } } @@ -697,8 +697,8 @@ release(const MouseWatcherParameter ¶m, bool background) { throw_event(event, EventParameter(ep)); } - if (has_notify()) { - get_notify()->item_release(this, param); + if (_notify != nullptr) { + _notify->item_release(this, param); } } @@ -757,8 +757,8 @@ move(const MouseWatcherParameter ¶m) { << *this << "::move(" << param << ")\n"; } - if (has_notify()) { - get_notify()->item_move(this, param); + if (_notify != nullptr) { + _notify->item_move(this, param); } } @@ -1169,9 +1169,10 @@ mouse_to_local(const LPoint2 &mouse_point) const { */ void PGItem:: frame_changed() { + LightReMutexHolder holder(_lock); mark_frames_stale(); - if (has_notify()) { - get_notify()->item_frame_changed(this); + if (_notify != nullptr) { + _notify->item_frame_changed(this); } } diff --git a/panda/src/pgui/pgScrollFrame.cxx b/panda/src/pgui/pgScrollFrame.cxx index a41916d3c9..9631f66685 100644 --- a/panda/src/pgui/pgScrollFrame.cxx +++ b/panda/src/pgui/pgScrollFrame.cxx @@ -19,19 +19,18 @@ TypeHandle PGScrollFrame::_type_handle; * */ PGScrollFrame:: -PGScrollFrame(const std::string &name) : PGVirtualFrame(name) +PGScrollFrame(const std::string &name) : + PGVirtualFrame(name), + _needs_remanage(false), + _needs_recompute_clip(false), + _has_virtual_frame(false), + _virtual_frame(0.0f, 0.0f, 0.0f, 0.0f), + _manage_pieces(false), + _auto_hide(false) { - set_cull_callback(); + _canvas_computed.test_and_set(); - _needs_remanage = false; - _needs_recompute_canvas = false; - _needs_recompute_clip = false; - _has_virtual_frame = false; - _virtual_frame.set(0.0f, 0.0f, 0.0f, 0.0f); - _manage_pieces = false; - _auto_hide = false; - _horizontal_slider = nullptr; - _vertical_slider = nullptr; + set_cull_callback(); } /** @@ -55,8 +54,8 @@ PGScrollFrame(const PGScrollFrame ©) : _auto_hide(copy._auto_hide) { _needs_remanage = false; - _needs_recompute_canvas = true; _needs_recompute_clip = true; + _canvas_computed.clear(); } /** @@ -97,7 +96,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (_needs_recompute_clip) { recompute_clip(); } - if (_needs_recompute_canvas) { + if (!_canvas_computed.test_and_set()) { recompute_canvas(); } return PGVirtualFrame::cull_callback(trav, data); @@ -257,7 +256,7 @@ remanage() { // Showing or hiding one of the scroll bars might have set this flag again // indirectly; we clear it again to avoid a feedback loop. _needs_remanage = false; -} + } // Are either or both of the scroll bars hidden? if (got_horizontal && _horizontal_slider->is_overall_hidden()) { @@ -329,19 +328,20 @@ item_draw_mask_changed(PGItem *) { */ void PGScrollFrame:: slider_bar_adjust(PGSliderBar *) { - LightReMutexHolder holder(_lock); - _needs_recompute_canvas = true; + // Indicate that recompute_canvas() needs to be called. + _canvas_computed.clear(); } /** * Recomputes the clipping window of the PGScrollFrame, based on the position * of the slider bars. + * + * Assumes the lock is held. */ void PGScrollFrame:: recompute_clip() { - LightReMutexHolder holder(_lock); _needs_recompute_clip = false; - _needs_recompute_canvas = true; + _canvas_computed.clear(); // Figure out how to remove the scroll bars from the clip region. LVecBase4 clip = get_frame_style(get_state()).get_internal_frame(get_frame()); @@ -361,34 +361,40 @@ recompute_clip() { /** * Recomputes the portion of the virtual canvas that is visible within the * PGScrollFrame, based on the values of the slider bars. + * + * Assumes the lock is held. */ void PGScrollFrame:: recompute_canvas() { - LightReMutexHolder holder(_lock); - _needs_recompute_canvas = false; + const LVecBase4 &clip = _has_clip_frame ? _clip_frame : get_frame(); - const LVecBase4 &clip = get_clip_frame(); + // Set this to true before we sample the slider bar ratios. + // If slider_bar_adjust happens to get called while we do this, no big deal, + // this method will just be called again next frame. + _canvas_computed.test_and_set(); - PN_stdfloat x = interpolate_canvas(clip[0], clip[1], - _virtual_frame[0], _virtual_frame[1], - _horizontal_slider); + PN_stdfloat cx, cy; + cx = interpolate_canvas(clip[0], clip[1], + _virtual_frame[0], _virtual_frame[1], + _horizontal_slider); - PN_stdfloat y = interpolate_canvas(clip[3], clip[2], - _virtual_frame[3], _virtual_frame[2], - _vertical_slider); + cy = interpolate_canvas(clip[3], clip[2], + _virtual_frame[3], _virtual_frame[2], + _vertical_slider); - get_canvas_node()->set_transform(TransformState::make_pos(LVector3::rfu(x, 0, y))); + _canvas_node->set_transform(TransformState::make_pos(LVector3::rfu(cx, 0, cy))); } /** * Computes the linear translation that should be applied to the virtual * canvas node, based on the corresponding slider bar's position. + * + * Assumes the lock is held. */ PN_stdfloat PGScrollFrame:: interpolate_canvas(PN_stdfloat clip_min, PN_stdfloat clip_max, PN_stdfloat canvas_min, PN_stdfloat canvas_max, PGSliderBar *slider_bar) { - LightReMutexHolder holder(_lock); PN_stdfloat t = 0.0f; if (slider_bar != nullptr) { t = slider_bar->get_ratio(); diff --git a/panda/src/pgui/pgScrollFrame.h b/panda/src/pgui/pgScrollFrame.h index de01954e0d..bb8b3a3af3 100644 --- a/panda/src/pgui/pgScrollFrame.h +++ b/panda/src/pgui/pgScrollFrame.h @@ -20,6 +20,10 @@ #include "pgSliderBarNotify.h" #include "pgSliderBar.h" +#ifdef PHAVE_ATOMIC +#include +#endif + /** * This is a special kind of frame that pretends to be much larger than it * actually is. You can scroll through the frame, as if you're looking @@ -92,7 +96,7 @@ private: private: bool _needs_remanage; bool _needs_recompute_clip; - bool _needs_recompute_canvas; + std::atomic_flag _canvas_computed; bool _has_virtual_frame; LVecBase4 _virtual_frame; diff --git a/panda/src/pgui/pgVirtualFrame.h b/panda/src/pgui/pgVirtualFrame.h index c8aff4fca6..d284b08ab0 100644 --- a/panda/src/pgui/pgVirtualFrame.h +++ b/panda/src/pgui/pgVirtualFrame.h @@ -72,7 +72,7 @@ protected: private: void setup_child_nodes(); -private: +protected: bool _has_clip_frame; LVecBase4 _clip_frame; diff --git a/panda/src/physics/config_physics.cxx b/panda/src/physics/config_physics.cxx index b4ad867f66..b952dae04f 100644 --- a/panda/src/physics/config_physics.cxx +++ b/panda/src/physics/config_physics.cxx @@ -26,7 +26,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PHYSICS) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PHYSICS) #error Buildsystem error: BUILDING_PANDA_PHYSICS not defined #endif diff --git a/panda/src/physx/config_physx.cxx b/panda/src/physx/config_physx.cxx index 4880e37e88..6a1b421eaf 100644 --- a/panda/src/physx/config_physx.cxx +++ b/panda/src/physx/config_physx.cxx @@ -67,7 +67,7 @@ #include "physxWheel.h" #include "physxWheelShape.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAPHYSX) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAPHYSX) #error Buildsystem error: BUILDING_PANDAPHYSX not defined #endif diff --git a/panda/src/pipeline/conditionVarSpinlockImpl.cxx b/panda/src/pipeline/conditionVarSpinlockImpl.cxx index f36bc83125..d35d8cd1f7 100644 --- a/panda/src/pipeline/conditionVarSpinlockImpl.cxx +++ b/panda/src/pipeline/conditionVarSpinlockImpl.cxx @@ -16,6 +16,14 @@ #ifdef MUTEX_SPINLOCK #include "conditionVarSpinlockImpl.h" +#include "trueClock.h" + +#if defined(__i386__) || defined(__x86_64) || defined(_M_IX86) || defined(_M_X64) +#include +#define PAUSE() _mm_pause() +#else +#define PAUSE() +#endif /** * @@ -23,12 +31,31 @@ void ConditionVarSpinlockImpl:: wait() { AtomicAdjust::Integer current = _event; - _mutex.release(); + _mutex.unlock(); while (AtomicAdjust::get(_event) == current) { + PAUSE(); } - _mutex.acquire(); + _mutex.lock(); +} + +/** + * + */ +void ConditionVarSpinlockImpl:: +wait(double timeout) { + TrueClock *clock = TrueClock::get_global_ptr(); + double end_time = clock->get_short_time() + timeout; + + AtomicAdjust::Integer current = _event; + _mutex.unlock(); + + while (AtomicAdjust::get(_event) == current && clock->get_short_time() < end_time) { + PAUSE(); + } + + _mutex.lock(); } #endif // MUTEX_SPINLOCK diff --git a/panda/src/pipeline/conditionVarSpinlockImpl.h b/panda/src/pipeline/conditionVarSpinlockImpl.h index 5d8da7bbf7..34b61645f8 100644 --- a/panda/src/pipeline/conditionVarSpinlockImpl.h +++ b/panda/src/pipeline/conditionVarSpinlockImpl.h @@ -37,6 +37,7 @@ public: INLINE ~ConditionVarSpinlockImpl(); void wait(); + void wait(double timeout); INLINE void notify(); INLINE void notify_all(); diff --git a/panda/src/pipeline/config_pipeline.cxx b/panda/src/pipeline/config_pipeline.cxx index 60f077688f..2e7bf6487e 100644 --- a/panda/src/pipeline/config_pipeline.cxx +++ b/panda/src/pipeline/config_pipeline.cxx @@ -21,7 +21,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PIPELINE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PIPELINE) #error Buildsystem error: BUILDING_PANDA_PIPELINE not defined #endif diff --git a/panda/src/pipeline/lightReMutexDirect.I b/panda/src/pipeline/lightReMutexDirect.I index 08bb0daa67..8484092ecc 100644 --- a/panda/src/pipeline/lightReMutexDirect.I +++ b/panda/src/pipeline/lightReMutexDirect.I @@ -11,21 +11,6 @@ * @date 2008-10-08 */ -/** - * - */ -INLINE LightReMutexDirect:: -LightReMutexDirect() -#ifndef HAVE_REMUTEXIMPL - : _cvar_impl(_lock_impl) -#endif -{ -#ifndef HAVE_REMUTEXIMPL - _locking_thread = nullptr; - _lock_count = 0; -#endif -} - /** * Alias for acquire() to match C++11 semantics. * @see acquire() diff --git a/panda/src/pipeline/lightReMutexDirect.h b/panda/src/pipeline/lightReMutexDirect.h index 56371cc443..d1bc022740 100644 --- a/panda/src/pipeline/lightReMutexDirect.h +++ b/panda/src/pipeline/lightReMutexDirect.h @@ -29,7 +29,7 @@ class Thread; */ class EXPCL_PANDA_PIPELINE LightReMutexDirect { protected: - INLINE LightReMutexDirect(); + LightReMutexDirect() = default; LightReMutexDirect(const LightReMutexDirect ©) = delete; ~LightReMutexDirect() = default; @@ -57,7 +57,7 @@ PUBLISHED: private: #ifdef HAVE_REMUTEXTRUEIMPL - mutable ReMutexImpl _impl; + mutable ReMutexTrueImpl _impl; #else // If we don't have a reentrant mutex, use the one we hand-rolled in diff --git a/panda/src/pipeline/mutexTrueImpl.h b/panda/src/pipeline/mutexTrueImpl.h index 2366159a38..5a4850a4a0 100644 --- a/panda/src/pipeline/mutexTrueImpl.h +++ b/panda/src/pipeline/mutexTrueImpl.h @@ -43,6 +43,13 @@ typedef MutexImpl MutexTrueImpl; #if HAVE_REMUTEXIMPL typedef ReMutexImpl ReMutexTrueImpl; #define HAVE_REMUTEXTRUEIMPL 1 + +#elif MUTEX_SPINLOCK +// This is defined here because it needs code from pipeline. +#include "reMutexSpinlockImpl.h" +typedef ReMutexSpinlockImpl ReMutexTrueImpl; +#define HAVE_REMUTEXTRUEIMPL 1 + #else #undef HAVE_REMUTEXTRUEIMPL #endif // HAVE_REMUTEXIMPL diff --git a/panda/src/pipeline/p3pipeline_composite2.cxx b/panda/src/pipeline/p3pipeline_composite2.cxx index e6607a6ebf..e9e928ee4c 100644 --- a/panda/src/pipeline/p3pipeline_composite2.cxx +++ b/panda/src/pipeline/p3pipeline_composite2.cxx @@ -13,6 +13,7 @@ #include "reMutex.cxx" #include "reMutexDirect.cxx" #include "reMutexHolder.cxx" +#include "reMutexSpinlockImpl.cxx" #include "thread.cxx" #include "threadDummyImpl.cxx" #include "threadPosixImpl.cxx" diff --git a/panda/src/pipeline/reMutexDirect.I b/panda/src/pipeline/reMutexDirect.I index 0785473e7c..e7fa3a6fce 100644 --- a/panda/src/pipeline/reMutexDirect.I +++ b/panda/src/pipeline/reMutexDirect.I @@ -33,7 +33,11 @@ ReMutexDirect() INLINE void ReMutexDirect:: lock() { TAU_PROFILE("void ReMutexDirect::acquire()", " ", TAU_USER); +#ifdef HAVE_REMUTEXTRUEIMPL _impl.lock(); +#else + ((ReMutexDirect *)this)->do_lock(); +#endif // HAVE_REMUTEXTRUEIMPL } /** @@ -43,7 +47,11 @@ lock() { INLINE bool ReMutexDirect:: try_lock() { TAU_PROFILE("void ReMutexDirect::try_acquire()", " ", TAU_USER); +#ifdef HAVE_REMUTEXTRUEIMPL return _impl.try_lock(); +#else + return ((ReMutexDirect *)this)->do_try_lock(); +#endif // HAVE_REMUTEXTRUEIMPL } /** @@ -53,7 +61,11 @@ try_lock() { INLINE void ReMutexDirect:: unlock() { TAU_PROFILE("void ReMutexDirect::unlock()", " ", TAU_USER); +#ifdef HAVE_REMUTEXTRUEIMPL _impl.unlock(); +#else + ((ReMutexDirect *)this)->do_unlock(); +#endif // HAVE_REMUTEXTRUEIMPL } /** diff --git a/panda/src/pipeline/reMutexDirect.cxx b/panda/src/pipeline/reMutexDirect.cxx index 7bfdcb8f8d..f6cd59e4de 100644 --- a/panda/src/pipeline/reMutexDirect.cxx +++ b/panda/src/pipeline/reMutexDirect.cxx @@ -141,11 +141,11 @@ do_elevate_lock() { * mutex). */ void ReMutexDirect:: -do_unlock() { +do_unlock(Thread *current_thread) { _lock_impl.lock(); #ifdef _DEBUG - if (_locking_thread != Thread::get_current_thread()) { + if (_locking_thread != current_thread) { std::ostringstream ostr; ostr << *_locking_thread << " attempted to release " << *this << " which it does not own"; diff --git a/panda/src/pipeline/reMutexDirect.h b/panda/src/pipeline/reMutexDirect.h index b6f5215319..faf46d0fb0 100644 --- a/panda/src/pipeline/reMutexDirect.h +++ b/panda/src/pipeline/reMutexDirect.h @@ -59,7 +59,7 @@ PUBLISHED: private: #ifdef HAVE_REMUTEXTRUEIMPL - mutable ReMutexImpl _impl; + mutable ReMutexTrueImpl _impl; #else // If we don't have a reentrant mutex, we have to hand-roll one. @@ -68,7 +68,7 @@ private: INLINE bool do_try_lock(); bool do_try_lock(Thread *current_thread); void do_elevate_lock(); - void do_unlock(); + void do_unlock(Thread *current_thread = Thread::get_current_thread()); Thread *_locking_thread; int _lock_count; diff --git a/panda/src/pipeline/reMutexSpinlockImpl.I b/panda/src/pipeline/reMutexSpinlockImpl.I new file mode 100644 index 0000000000..5f5e2d89c3 --- /dev/null +++ b/panda/src/pipeline/reMutexSpinlockImpl.I @@ -0,0 +1,23 @@ +/** + * 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." + * + * @file reMutexSpinlockImpl.I + * @author rdb + * @date 2018-09-03 + */ + +/** + * + */ +INLINE void ReMutexSpinlockImpl:: +unlock() { + assert(_counter > 0); + if (!--_counter) { + AtomicAdjust::set_ptr(_locking_thread, nullptr); + } +} diff --git a/panda/src/pipeline/reMutexSpinlockImpl.cxx b/panda/src/pipeline/reMutexSpinlockImpl.cxx new file mode 100644 index 0000000000..0de12f986f --- /dev/null +++ b/panda/src/pipeline/reMutexSpinlockImpl.cxx @@ -0,0 +1,57 @@ +/** + * 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." + * + * @file reMutexSpinlockImpl.cxx + * @author rdb + * @date 2018-09-03 + */ + +#include "selectThreadImpl.h" + +#ifdef MUTEX_SPINLOCK + +#include "reMutexSpinlockImpl.h" +#include "thread.h" + +#if defined(__i386__) || defined(__x86_64) || defined(_M_IX86) || defined(_M_X64) +#include +#define PAUSE() _mm_pause() +#else +#define PAUSE() +#endif + +/** + * + */ +void ReMutexSpinlockImpl:: +lock() { + Thread *current_thread = Thread::get_current_thread(); + Thread *locking_thread = (Thread *)AtomicAdjust::compare_and_exchange_ptr(_locking_thread, nullptr, current_thread); + while (locking_thread != nullptr && locking_thread != current_thread) { + PAUSE(); + locking_thread = (Thread *)AtomicAdjust::compare_and_exchange_ptr(_locking_thread, nullptr, current_thread); + } + ++_counter; +} + +/** + * + */ +bool ReMutexSpinlockImpl:: +try_lock() { + Thread *current_thread = Thread::get_current_thread(); + Thread *locking_thread = (Thread *)AtomicAdjust::compare_and_exchange_ptr(_locking_thread, nullptr, current_thread); + if (locking_thread == nullptr || locking_thread == current_thread) { + ++_counter; + return true; + } else { + return false; + } +} + +#endif // MUTEX_SPINLOCK diff --git a/panda/src/pipeline/reMutexSpinlockImpl.h b/panda/src/pipeline/reMutexSpinlockImpl.h new file mode 100644 index 0000000000..666ed832e3 --- /dev/null +++ b/panda/src/pipeline/reMutexSpinlockImpl.h @@ -0,0 +1,54 @@ +/** + * 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." + * + * @file reMutexSpinlockImpl.h + * @author rdb + * @date 2018-09-03 + */ + +#ifndef REMUTEXSPINLOCKIMPL_H +#define REMUTEXSPINLOCKIMPL_H + +#include "dtoolbase.h" +#include "selectThreadImpl.h" + +#ifdef MUTEX_SPINLOCK + +#include "atomicAdjust.h" + +class Thread; + +/** + * Uses a simple user-space spinlock to implement a mutex. It is usually not + * a good idea to use this implementation, unless you are building Panda for a + * specific application on a specific SMP machine, and you are confident that + * you have at least as many CPU's as you have threads. + */ +class EXPCL_PANDA_PIPELINE ReMutexSpinlockImpl { +public: + constexpr ReMutexSpinlockImpl() noexcept = default; + ReMutexSpinlockImpl(const ReMutexSpinlockImpl ©) = delete; + + ReMutexSpinlockImpl &operator = (const ReMutexSpinlockImpl ©) = delete; + +public: + void lock(); + bool try_lock(); + INLINE void unlock(); + +private: + AtomicAdjust::Pointer _locking_thread = nullptr; + unsigned int _counter = 0; +}; + + +#include "reMutexSpinlockImpl.I" + +#endif // MUTEX_SPINLOCK + +#endif diff --git a/panda/src/pipeline/thread.cxx b/panda/src/pipeline/thread.cxx index 351e316033..80c32fa7f5 100644 --- a/panda/src/pipeline/thread.cxx +++ b/panda/src/pipeline/thread.cxx @@ -211,6 +211,7 @@ init_main_thread() { static int count = 0; ++count; if (count == 1 && _main_thread == nullptr) { + init_memory_hook(); _main_thread = new MainThread; _main_thread->ref(); } @@ -222,6 +223,7 @@ init_main_thread() { void Thread:: init_external_thread() { if (_external_thread == nullptr) { + init_memory_hook(); _external_thread = new ExternalThread; _external_thread->ref(); } diff --git a/panda/src/pnmimage/config_pnmimage.cxx b/panda/src/pnmimage/config_pnmimage.cxx index 5bb734cf85..7bafe9fb09 100644 --- a/panda/src/pnmimage/config_pnmimage.cxx +++ b/panda/src/pnmimage/config_pnmimage.cxx @@ -17,7 +17,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PNMIMAGE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PNMIMAGE) #error Buildsystem error: BUILDING_PANDA_PNMIMAGE not defined #endif diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx index 551c351c43..bf70c56d1f 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx @@ -32,7 +32,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PNMIMAGETYPES) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PNMIMAGETYPES) #error Buildsystem error: BUILDING_PANDA_PNMIMAGETYPES not defined #endif diff --git a/panda/src/pnmtext/config_pnmtext.cxx b/panda/src/pnmtext/config_pnmtext.cxx index a0a627aca7..a653fac26f 100644 --- a/panda/src/pnmtext/config_pnmtext.cxx +++ b/panda/src/pnmtext/config_pnmtext.cxx @@ -16,7 +16,7 @@ #include "dconfig.h" #include "freetypeFace.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PNMTEXT) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PNMTEXT) #error Buildsystem error: BUILDING_PANDA_PNMTEXT not defined #endif diff --git a/panda/src/pstatclient/config_pstatclient.cxx b/panda/src/pstatclient/config_pstatclient.cxx index 4be7472441..1335254590 100644 --- a/panda/src/pstatclient/config_pstatclient.cxx +++ b/panda/src/pstatclient/config_pstatclient.cxx @@ -15,7 +15,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PSTATCLIENT) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PSTATCLIENT) #error Buildsystem error: BUILDING_PANDA_PSTATCLIENT not defined #endif diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index c69e1ea032..a0ddb2ae38 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -1056,7 +1056,9 @@ add_collector(PStatClient::Collector *collector) { // the lock. int new_collectors_size = (_collectors_size == 0) ? 128 : _collectors_size * 2; CollectorPointer *new_collectors = new CollectorPointer[new_collectors_size]; - memcpy(new_collectors, _collectors, _num_collectors * sizeof(CollectorPointer)); + if (_collectors != nullptr) { + memcpy(new_collectors, _collectors, _num_collectors * sizeof(CollectorPointer)); + } AtomicAdjust::set_ptr(_collectors, new_collectors); AtomicAdjust::set(_collectors_size, new_collectors_size); @@ -1091,7 +1093,9 @@ add_thread(PStatClient::InternalThread *thread) { // the lock. int new_threads_size = (_threads_size == 0) ? 128 : _threads_size * 2; ThreadPointer *new_threads = new ThreadPointer[new_threads_size]; - memcpy(new_threads, _threads, _num_threads * sizeof(ThreadPointer)); + if (_threads != nullptr) { + memcpy(new_threads, _threads, _num_threads * sizeof(ThreadPointer)); + } // We assume that assignment to a pointer and to an int are each atomic. AtomicAdjust::set_ptr(_threads, new_threads); AtomicAdjust::set(_threads_size, new_threads_size); diff --git a/panda/src/putil/buttonHandle.I b/panda/src/putil/buttonHandle.I index c45145dd40..55edc7f61a 100644 --- a/panda/src/putil/buttonHandle.I +++ b/panda/src/putil/buttonHandle.I @@ -137,15 +137,6 @@ output(std::ostream &out) const { out << get_name(); } -/** - * Returns a special zero-valued ButtonHandle that is used to indicate no - * button. - */ -INLINE ButtonHandle ButtonHandle:: -none() { - return _none; -} - /** * ButtonHandle::none() evaluates to false, everything else evaluates to true. */ diff --git a/panda/src/putil/buttonHandle.cxx b/panda/src/putil/buttonHandle.cxx index 831a3daddd..4ce3cd5a91 100644 --- a/panda/src/putil/buttonHandle.cxx +++ b/panda/src/putil/buttonHandle.cxx @@ -14,9 +14,6 @@ #include "buttonHandle.h" #include "buttonRegistry.h" -// This is initialized to zero by static initialization. -ButtonHandle ButtonHandle::_none; - TypeHandle ButtonHandle::_type_handle; /** diff --git a/panda/src/putil/buttonHandle.h b/panda/src/putil/buttonHandle.h index ad43ad2a86..6e9dd9a40f 100644 --- a/panda/src/putil/buttonHandle.h +++ b/panda/src/putil/buttonHandle.h @@ -53,7 +53,7 @@ PUBLISHED: constexpr int get_index() const; INLINE void output(std::ostream &out) const; - INLINE static ButtonHandle none(); + constexpr static ButtonHandle none() { return ButtonHandle(0); } INLINE operator bool () const; @@ -65,7 +65,6 @@ PUBLISHED: private: int _index; - static ButtonHandle _none; public: static TypeHandle get_class_type() { diff --git a/panda/src/putil/config_putil.cxx b/panda/src/putil/config_putil.cxx index 410cea01f4..93694b3d30 100644 --- a/panda/src/putil/config_putil.cxx +++ b/panda/src/putil/config_putil.cxx @@ -48,7 +48,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PUTIL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PUTIL) #error Buildsystem error: BUILDING_PANDA_PUTIL not defined #endif diff --git a/panda/src/recorder/config_recorder.cxx b/panda/src/recorder/config_recorder.cxx index 97335e17cd..c24e320391 100644 --- a/panda/src/recorder/config_recorder.cxx +++ b/panda/src/recorder/config_recorder.cxx @@ -22,7 +22,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_RECORDER) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_RECORDER) #error Buildsystem error: BUILDING_PANDA_RECORDER not defined #endif diff --git a/panda/src/rocket/config_rocket.cxx b/panda/src/rocket/config_rocket.cxx index 4de7bf3e28..61b5c634e2 100644 --- a/panda/src/rocket/config_rocket.cxx +++ b/panda/src/rocket/config_rocket.cxx @@ -26,7 +26,7 @@ #include #undef Factory -#if !defined(CPPPARSER) && !defined(BUILDING_ROCKET) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_ROCKET) #error Buildsystem error: BUILDING_ROCKET not defined #endif diff --git a/panda/src/skel/config_skel.cxx b/panda/src/skel/config_skel.cxx index 5fa6f6595c..dd6e808502 100644 --- a/panda/src/skel/config_skel.cxx +++ b/panda/src/skel/config_skel.cxx @@ -16,7 +16,7 @@ #include "typedSkel.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDASKEL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDASKEL) #error Buildsystem error: BUILDING_PANDASKEL not defined #endif diff --git a/panda/src/speedtree/config_speedtree.cxx b/panda/src/speedtree/config_speedtree.cxx index f820239665..dfc4d455c6 100644 --- a/panda/src/speedtree/config_speedtree.cxx +++ b/panda/src/speedtree/config_speedtree.cxx @@ -21,7 +21,7 @@ #include "loaderFileTypeRegistry.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDASPEEDTREE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDASPEEDTREE) #error Buildsystem error: BUILDING_PANDASPEEDTREE not defined #endif diff --git a/panda/src/text/config_text.cxx b/panda/src/text/config_text.cxx index 77dd27beba..dee79539ba 100644 --- a/panda/src/text/config_text.cxx +++ b/panda/src/text/config_text.cxx @@ -27,7 +27,7 @@ #include "dconfig.h" #include "config_express.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_TEXT) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_TEXT) #error Buildsystem error: BUILDING_PANDA_TEXT not defined #endif diff --git a/panda/src/tform/config_tform.cxx b/panda/src/tform/config_tform.cxx index b8a578d07c..6620e5724c 100644 --- a/panda/src/tform/config_tform.cxx +++ b/panda/src/tform/config_tform.cxx @@ -25,7 +25,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_TFORM) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_TFORM) #error Buildsystem error: BUILDING_PANDA_TFORM not defined #endif diff --git a/panda/src/tinydisplay/config_tinydisplay.cxx b/panda/src/tinydisplay/config_tinydisplay.cxx index 31ef112ee5..9740001c01 100644 --- a/panda/src/tinydisplay/config_tinydisplay.cxx +++ b/panda/src/tinydisplay/config_tinydisplay.cxx @@ -29,7 +29,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_TINYDISPLAY) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_TINYDISPLAY) #error Buildsystem error: BUILDING_TINYDISPLAY not defined #endif diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index 8f49433ebd..fd3c44c917 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -2951,7 +2951,7 @@ setup_material(GLMaterial *gl_material, const Material *material) { _color_material_flags = CMF_ambient | CMF_diffuse; - if (material->has_ambient()) { + if (material->has_ambient() || material->has_base_color()) { const LColor &ambient = material->get_ambient(); gl_material->ambient.v[0] = ambient[0]; gl_material->ambient.v[1] = ambient[1]; @@ -2961,7 +2961,7 @@ setup_material(GLMaterial *gl_material, const Material *material) { _color_material_flags &= ~CMF_ambient; } - if (material->has_diffuse()) { + if (material->has_diffuse() || material->has_base_color()) { const LColor &diffuse = material->get_diffuse(); gl_material->diffuse.v[0] = diffuse[0]; gl_material->diffuse.v[1] = diffuse[1]; diff --git a/panda/src/vision/config_vision.cxx b/panda/src/vision/config_vision.cxx index ffe3719962..4b4eee02f8 100644 --- a/panda/src/vision/config_vision.cxx +++ b/panda/src/vision/config_vision.cxx @@ -23,7 +23,7 @@ #include "texturePool.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_VISION) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_VISION) #error Buildsystem error: BUILDING_VISION not defined #endif diff --git a/panda/src/vrpn/config_vrpn.cxx b/panda/src/vrpn/config_vrpn.cxx index cc577bd328..54ac23f565 100644 --- a/panda/src/vrpn/config_vrpn.cxx +++ b/panda/src/vrpn/config_vrpn.cxx @@ -21,7 +21,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_VRPN) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_VRPN) #error Buildsystem error: BUILDING_VRPN not defined #endif diff --git a/panda/src/wgldisplay/config_wgldisplay.cxx b/panda/src/wgldisplay/config_wgldisplay.cxx index fa04606dca..63d40fdea8 100644 --- a/panda/src/wgldisplay/config_wgldisplay.cxx +++ b/panda/src/wgldisplay/config_wgldisplay.cxx @@ -20,7 +20,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_WGLDISPLAY) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_WGLDISPLAY) #error Buildsystem error: BUILDING_PANDA_WGLDISPLAY not defined #endif diff --git a/panda/src/windisplay/config_windisplay.cxx b/panda/src/windisplay/config_windisplay.cxx index 1af5cf95da..6e0ea2406d 100644 --- a/panda/src/windisplay/config_windisplay.cxx +++ b/panda/src/windisplay/config_windisplay.cxx @@ -16,7 +16,7 @@ #include "winGraphicsWindow.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAWIN) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAWIN) #error Buildsystem error: BUILDING_PANDAWIN not defined #endif diff --git a/panda/src/x11display/config_x11display.cxx b/panda/src/x11display/config_x11display.cxx index bca59d5a17..4a633303ba 100644 --- a/panda/src/x11display/config_x11display.cxx +++ b/panda/src/x11display/config_x11display.cxx @@ -18,7 +18,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAX11) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAX11) #error Buildsystem error: BUILDING_PANDAX11 not defined #endif diff --git a/tests/gobj/test_texture.py b/tests/gobj/test_texture.py index 8fa0ed27c8..4bf917a8c2 100644 --- a/tests/gobj/test_texture.py +++ b/tests/gobj/test_texture.py @@ -1,5 +1,6 @@ -from panda3d.core import Texture, PNMImage +from panda3d.core import Texture, PNMImage, LColor from array import array +import math def image_from_stored_pixel(component_type, format, data): @@ -15,6 +16,20 @@ def image_from_stored_pixel(component_type, format, data): return img +def peek_tex_with_clear_color(component_type, format, clear_color): + """ Creates a 1-pixel texture with the given settings and clear color, + then peeks the value at this pixel and returns it. """ + + tex = Texture("") + tex.setup_1d_texture(1, component_type, format) + tex.set_clear_color(clear_color) + tex.make_ram_image() + + col = LColor() + tex.peek().fetch_pixel(col, 0, 0) + return col + + def test_texture_store_unsigned_byte(): data = array('B', (2, 1, 0, 0xff)) img = image_from_stored_pixel(Texture.T_unsigned_byte, Texture.F_rgba, data) @@ -88,3 +103,34 @@ def test_texture_store_srgb_alpha(): assert img.maxval == 0xff col = img.get_xel_a(0, 0) assert col.almost_equal((0.5, 0.5, 0.5, 188 / 255.0), 1 / 255.0) + + +def test_texture_clear_unsigned_byte(): + col = peek_tex_with_clear_color(Texture.T_unsigned_byte, Texture.F_rgba, (0, 1 / 255.0, 254 / 255.0, 1.0)) + assert col == LColor(0, 1 / 255.0, 254 / 255.0, 1.0) + + +def test_texture_clear_float(): + col = peek_tex_with_clear_color(Texture.T_float, Texture.F_rgba, (0, 0.25, -0.5, 2)) + assert col == LColor(0, 0.25, -0.5, 2) + + +def test_texture_clear_half(): + col = peek_tex_with_clear_color(Texture.T_half_float, Texture.F_rgba, (0, 0.25, -0.5, 2)) + assert col == LColor(0, 0.25, -0.5, 2) + + # Test edge cases + inf = float('inf') + nan = float('nan') + col = peek_tex_with_clear_color(Texture.T_half_float, Texture.F_rgba, (65504, 65536, inf, nan)) + assert col.x == 65504 + assert col.y == inf + assert col.z == inf + assert math.isnan(col.w) + + # Negative edge case + col = peek_tex_with_clear_color(Texture.T_half_float, Texture.F_rgba, (-65504, -65536, -inf, -nan)) + assert col.x == -65504 + assert col.y == -inf + assert col.z == -inf + assert math.isnan(col.w) diff --git a/tests/pipeline/test_mutex.py b/tests/pipeline/test_mutex.py new file mode 100644 index 0000000000..2073c09efa --- /dev/null +++ b/tests/pipeline/test_mutex.py @@ -0,0 +1,60 @@ +from panda3d.core import Mutex, ReMutex + + +def test_mutex_acquire_release(): + m = Mutex() + m.acquire() + + # Assert that the lock is truly held now + assert m.debug_is_locked() + + # Release the lock + m.release() + + # Make sure the lock is properly released + assert m.try_acquire() + + # Clean up + m.release() + + +def test_mutex_try_acquire(): + m = Mutex() + + # Trying to acquire the lock should succeed + assert m.try_acquire() + + # Assert that the lock is truly held now + assert m.debug_is_locked() + + # Clean up + m.release() + + +def test_remutex_acquire_release(): + m = ReMutex() + m.acquire() + m.acquire() + m.release() + m.release() + + +def test_remutex_try_acquire(): + m = ReMutex() + + # Trying to acquire the lock should succeed + assert m.try_acquire() + + # Should report being locked + assert m.debug_is_locked() + + # Trying a second time should succeed + assert m.try_acquire() + + # Should still report being locked + assert m.debug_is_locked() + + # Clean up + m.release() + m.release() +