general: Fix a variety of ABI incompatibility issues with opt4 builds

This commit is contained in:
rdb 2019-10-08 19:41:23 +02:00
parent 099be1f652
commit 08572f3c38
13 changed files with 188 additions and 40 deletions

View File

@ -351,7 +351,7 @@ traverse(const NodePath &root) {
CollisionBox::flush_level();
}
#ifdef DO_COLLISION_RECORDING
#if defined(DO_COLLISION_RECORDING) || !defined(CPPPARSER)
/**
* Uses the indicated CollisionRecorder object to start recording the
* intersection tests made by each subsequent call to traverse() on this
@ -370,6 +370,7 @@ traverse(const NodePath &root) {
*/
void CollisionTraverser::
set_recorder(CollisionRecorder *recorder) {
#ifdef DO_COLLISION_RECORDING
if (recorder != _recorder) {
// Remove the old recorder, if any.
if (_recorder != nullptr) {
@ -389,6 +390,7 @@ set_recorder(CollisionRecorder *recorder) {
_recorder->_trav = this;
}
}
#endif
}
/**
@ -399,11 +401,15 @@ set_recorder(CollisionRecorder *recorder) {
*/
CollisionVisualizer *CollisionTraverser::
show_collisions(const NodePath &root) {
#ifdef DO_COLLISION_RECORDING
hide_collisions();
CollisionVisualizer *viz = new CollisionVisualizer("show_collisions");
_collision_visualizer_np = root.attach_new_node(viz);
set_recorder(viz);
return viz;
#else
return nullptr;
#endif
}
/**
@ -411,10 +417,12 @@ show_collisions(const NodePath &root) {
*/
void CollisionTraverser::
hide_collisions() {
#ifdef DO_COLLISION_RECORDING
if (!_collision_visualizer_np.is_empty()) {
_collision_visualizer_np.remove_node();
}
clear_recorder();
#endif
}
#endif // DO_COLLISION_RECORDING

View File

@ -66,7 +66,7 @@ PUBLISHED:
void traverse(const NodePath &root);
#ifdef DO_COLLISION_RECORDING
#if defined(DO_COLLISION_RECORDING) || !defined(CPPPARSER)
void set_recorder(CollisionRecorder *recorder);
INLINE bool has_recorder() const;
INLINE CollisionRecorder *get_recorder() const;
@ -134,6 +134,9 @@ private:
#ifdef DO_COLLISION_RECORDING
CollisionRecorder *_recorder;
NodePath _collision_visualizer_np;
#else
CollisionRecorder *_recorder_disabled = nullptr;
NodePath _collision_visualizer_np_disabled;
#endif // DO_COLLISION_RECORDING
// Statistics

View File

@ -13,11 +13,9 @@
#include "pStatCollectorForwardBase.h"
#ifdef DO_PSTATS
/**
*
*/
PStatCollectorForwardBase::
~PStatCollectorForwardBase() {
}
#endif // DO_PSTATS

View File

@ -27,10 +27,13 @@
*/
class EXPCL_PANDA_EXPRESS PStatCollectorForwardBase : public ReferenceCount {
PUBLISHED:
#ifdef DO_PSTATS
virtual ~PStatCollectorForwardBase();
#ifdef DO_PSTATS
virtual void add_level(double level)=0;
#else
// We still need to declare a virtual destructor for ABI compatibility, so
// that a vtable is created.
INLINE void add_level(double level) { }
#endif
};

View File

@ -85,9 +85,7 @@ private:
typedef pvector< PT(CullBin) > Bins;
Bins _bins;
#ifndef NDEBUG
bool _show_transparency;
#endif
bool _show_transparency = false;
public:
static TypeHandle get_class_type() {

View File

@ -82,9 +82,6 @@ PandaNode(const string &name) :
pgraph_cat.debug()
<< "Constructing " << (void *)this << ", " << get_name() << "\n";
}
#ifndef NDEBUG
_unexpected_change_flags = 0;
#endif // !NDEBUG
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, this);
@ -135,7 +132,8 @@ PandaNode(const PandaNode &copy) :
Namable(copy),
_paths_lock("PandaNode::_paths_lock"),
_dirty_prev_transform(false),
_python_tag_data(copy._python_tag_data)
_python_tag_data(copy._python_tag_data),
_unexpected_change_flags(0)
{
if (pgraph_cat.is_debug()) {
pgraph_cat.debug()
@ -144,10 +142,6 @@ PandaNode(const PandaNode &copy) :
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, this);
#endif
// Copying a node does not copy its children.
#ifndef NDEBUG
_unexpected_change_flags = 0;
#endif // !NDEBUG
// Need to have this held before we grab any other locks.
LightMutexHolder holder(_dirty_prev_transforms._lock);

View File

@ -532,9 +532,7 @@ private:
};
PT(PythonTagData) _python_tag_data;
#ifndef NDEBUG
unsigned int _unexpected_change_flags;
#endif // !NDEBUG
unsigned int _unexpected_change_flags = 0;
// This is the data that must be cycled between pipeline stages.

View File

@ -1224,6 +1224,48 @@ InternalThread(const string &name, const string &sync_name) :
#else // DO_PSTATS
void PStatClient::
set_client_name(const std::string &name) {
}
std::string PStatClient::
get_client_name() const {
return std::string();
}
void PStatClient::
set_max_rate(double rate) {
}
double PStatClient::
get_max_rate() const {
return 0.0;
}
PStatCollector PStatClient::
get_collector(int index) const {
return PStatCollector();
}
std::string PStatClient::
get_collector_name(int index) const {
return std::string();
}
std::string PStatClient::
get_collector_fullname(int index) const {
return std::string();
}
PStatThread PStatClient::
get_thread(int index) const {
return PStatThread((PStatClient *)this, 0);
}
double PStatClient::
get_real_time() const {
}
PStatThread PStatClient::
get_main_thread() const {
return PStatThread((PStatClient *)this, 0);
@ -1239,12 +1281,63 @@ make_collector_with_relname(int parent_index, std::string relname) {
return PStatCollector();
}
PStatThread PStatClient::
make_thread(Thread *thread) {
return PStatThread((PStatClient *)this, 0);
}
void PStatClient::
main_tick() {
}
void PStatClient::
thread_tick(const std::string &) {
}
void PStatClient::
client_main_tick() {
}
void PStatClient::
client_thread_tick(const std::string &sync_name) {
}
bool PStatClient::
client_connect(std::string hostname, int port) {
return false;
}
void PStatClient::
client_disconnect() {
return;
}
bool PStatClient::
client_is_connected() const {
return false;
}
void PStatClient::
client_resume_after_pause() {
return;
}
PStatClient *PStatClient::
get_global_pstats() {
static PStatClient global_pstats;
return &global_pstats;
}
bool PStatClient::
is_active(int collector_index, int thread_index) const {
return false;
}
bool PStatClient::
is_started(int collector_index, int thread_index) const {
return false;
}
void PStatClient::
start(int collector_index, int thread_index) {
}
@ -1261,5 +1354,21 @@ void PStatClient::
stop(int collector_index, int thread_index, double as_of) {
}
void PStatClient::
clear_level(int collector_index, int thread_index) {
}
void PStatClient::
set_level(int collector_index, int thread_index, double level) {
}
void PStatClient::
add_level(int collector_index, int thread_index, double increment) {
}
double PStatClient::
get_level(int collector_index, int thread_index) const {
return 0.0;
}
#endif // DO_PSTATS

View File

@ -265,20 +265,43 @@ public:
PStatClient() { }
~PStatClient() { }
PUBLISHED:
std::string get_collector_name(int index) const { return std::string(); }
std::string get_collector_fullname(int index) const { return std::string(); }
void set_client_name(const std::string &name);
std::string get_client_name() const;
void set_max_rate(double rate);
double get_max_rate() const;
PStatCollector get_collector(int index) const;
std::string get_collector_name(int index) const;
std::string get_collector_fullname(int index) const;
INLINE int get_num_threads() const { return 0; }
PStatThread get_thread(int index) const;
INLINE std::string get_thread_name(int index) const { return ""; }
INLINE std::string get_thread_sync_name(int index) const { return ""; }
INLINE PT(Thread) get_thread_object(int index) const { return nullptr; }
PStatThread get_main_thread() const;
PStatThread get_current_thread() const;
double get_real_time() const;
PUBLISHED:
INLINE static bool connect(const std::string & = std::string(), int = -1) { return false; }
INLINE static void disconnect() { }
INLINE static bool is_connected() { return false; }
INLINE static void resume_after_pause() { }
INLINE static void main_tick() { }
INLINE static void thread_tick(const std::string &) { }
static void main_tick();
static void thread_tick(const std::string &);
public:
void client_main_tick();
void client_thread_tick(const std::string &sync_name);
bool client_connect(std::string hostname, int port);
void client_disconnect();
bool client_is_connected() const;
void client_resume_after_pause();
static PStatClient *get_global_pstats();
@ -286,19 +309,20 @@ private:
// These are used by inline PStatCollector methods, so they need to be
// stubbed out for ABI compatibility.
PStatCollector make_collector_with_relname(int parent_index, std::string relname);
PStatThread make_thread(Thread *thread);
bool is_active(int collector_index, int thread_index) const { return false; }
bool is_started(int collector_index, int thread_index) const { return false; }
bool is_active(int collector_index, int thread_index) const;
bool is_started(int collector_index, int thread_index) const;
void start(int collector_index, int thread_index);
void start(int collector_index, int thread_index, double as_of);
void stop(int collector_index, int thread_index);
void stop(int collector_index, int thread_index, double as_of);
void clear_level(int collector_index, int thread_index) { }
void set_level(int collector_index, int thread_index, double level) { }
void add_level(int collector_index, int thread_index, double increment) { }
double get_level(int collector_index, int thread_index) const { return 0.0; }
void clear_level(int collector_index, int thread_index);
void set_level(int collector_index, int thread_index, double level);
void add_level(int collector_index, int thread_index, double increment);
double get_level(int collector_index, int thread_index) const;
};
#endif // DO_PSTATS

View File

@ -13,12 +13,12 @@
#include "pStatCollectorForward.h"
#ifdef DO_PSTATS
/**
*
*/
void PStatCollectorForward::
add_level(double increment) {
#ifdef DO_PSTATS
_col.add_level_now(increment);
}
#endif // DO_PSTATS
}

View File

@ -27,9 +27,9 @@ class EXPCL_PANDA_PSTATCLIENT PStatCollectorForward : public PStatCollectorForwa
PUBLISHED:
INLINE PStatCollectorForward(const PStatCollector &col);
#ifdef DO_PSTATS
virtual void add_level(double level);
#ifdef DO_PSTATS
private:
PStatCollector _col;
#endif

View File

@ -185,7 +185,7 @@ write(std::ostream &out, int indent_level) const {
}
}
#ifndef NDEBUG
#if !defined(NDEBUG) || !defined(CPPPARSER)
/**
* Enables the visualization of all of the regions handled by this
* MouseWatcherBase. The supplied NodePath should be the root of the 2-d
@ -193,44 +193,52 @@ write(std::ostream &out, int indent_level) const {
*/
void MouseWatcherBase::
show_regions(const NodePath &render2d, const std::string &bin_name, int draw_order) {
#ifndef NDEBUG
LightMutexHolder holder(_lock);
do_show_regions(render2d, bin_name, draw_order);
#endif
}
#endif // NDEBUG
#ifndef NDEBUG
#if !defined(NDEBUG) || !defined(CPPPARSER)
/**
* Specifies the color used to draw the region rectangles for the regions
* visualized by show_regions().
*/
void MouseWatcherBase::
set_color(const LColor &color) {
#ifndef NDEBUG
LightMutexHolder holder(_lock);
_color = color;
do_update_regions();
#endif
}
#endif // NDEBUG
#ifndef NDEBUG
#if !defined(NDEBUG) || !defined(CPPPARSER)
/**
* Stops the visualization created by a previous call to show_regions().
*/
void MouseWatcherBase::
hide_regions() {
#ifndef NDEBUG
LightMutexHolder holder(_lock);
do_hide_regions();
#endif
}
#endif // NDEBUG
#ifndef NDEBUG
#if !defined(NDEBUG) || !defined(CPPPARSER)
/**
* Refreshes the visualization created by show_regions().
*/
void MouseWatcherBase::
update_regions() {
#ifndef NDEBUG
LightMutexHolder holder(_lock);
do_update_regions();
#endif
}
#endif // NDEBUG

View File

@ -53,7 +53,7 @@ PUBLISHED:
void output(std::ostream &out) const;
void write(std::ostream &out, int indent_level = 0) const;
#ifndef NDEBUG
#if !defined(NDEBUG) || !defined(CPPPARSER)
void show_regions(const NodePath &render2d,
const std::string &bin_name, int draw_order);
void set_color(const LColor &color);
@ -84,15 +84,20 @@ protected:
LightMutex _lock;
private:
typedef pvector< PT(PandaNode) > Vizzes;
#ifndef NDEBUG
PandaNode *make_viz_region(MouseWatcherRegion *region);
typedef pvector< PT(PandaNode) > Vizzes;
Vizzes _vizzes;
bool _show_regions;
NodePath _show_regions_root;
LColor _color;
#else
Vizzes _vizzes_disabled;
bool _show_regions_disabled = false;
NodePath _show_regions_root_disabled;
LColor _color_disabled;
#endif // NDEBUG
public: