This commit is contained in:
David Rose 2007-06-13 16:40:16 +00:00
parent ffb1940915
commit 140def8f38

View File

@ -2127,7 +2127,7 @@ get_bounds(Thread *current_thread) const {
CPT(BoundingVolume) result; CPT(BoundingVolume) result;
{ {
CDStageWriter cdataw = CDStageWriter cdataw =
((PandaNode *)this)->update_bounds(pipeline_stage, cdata); ((PandaNode *)this)->update_bounds(pipeline_stage, cdata);
result = cdataw->_external_bounds; result = cdataw->_external_bounds;
} }
return result; return result;
@ -2160,7 +2160,7 @@ get_bounds(UpdateSeq &seq, Thread *current_thread) const {
CPT(BoundingVolume) result; CPT(BoundingVolume) result;
{ {
CDStageWriter cdataw = CDStageWriter cdataw =
((PandaNode *)this)->update_bounds(pipeline_stage, cdata); ((PandaNode *)this)->update_bounds(pipeline_stage, cdata);
result = cdataw->_external_bounds; result = cdataw->_external_bounds;
seq = cdataw->_last_update; seq = cdataw->_last_update;
} }
@ -2192,7 +2192,7 @@ get_nested_vertices(Thread *current_thread) const {
int result; int result;
{ {
CDStageWriter cdataw = CDStageWriter cdataw =
((PandaNode *)this)->update_bounds(pipeline_stage, cdata); ((PandaNode *)this)->update_bounds(pipeline_stage, cdata);
result = cdataw->_nested_vertices; result = cdataw->_nested_vertices;
} }
return result; return result;
@ -2672,17 +2672,17 @@ stage_replace_child(PandaNode *orig_child, PandaNode *new_child,
PT(Down) stashed = cdata->modify_stashed(); PT(Down) stashed = cdata->modify_stashed();
int stashed_index = do_find_child(orig_child, stashed); int stashed_index = do_find_child(orig_child, stashed);
if (stashed_index >= 0) { if (stashed_index >= 0) {
// The child has been stashed; remove it. // The child has been stashed; remove it.
DownConnection &dc = (*stashed)[stashed_index]; DownConnection &dc = (*stashed)[stashed_index];
nassertr(dc.get_child() == orig_child, false); nassertr(dc.get_child() == orig_child, false);
dc.set_child(new_child); dc.set_child(new_child);
} else { } else {
// Never heard of this child. This shouldn't be possible, because // Never heard of this child. This shouldn't be possible, because
// the parent was in the child's up list, above. Must be some // the parent was in the child's up list, above. Must be some
// internal error. // internal error.
nassertr(false, false); nassertr(false, false);
return false; return false;
} }
} }
@ -2783,7 +2783,7 @@ attach(NodePathComponent *parent, PandaNode *child_node, int sort,
// attachments, and no questions asked. // attachments, and no questions asked.
PT(NodePathComponent) child = PT(NodePathComponent) child =
new NodePathComponent(child_node, (NodePathComponent *)NULL, new NodePathComponent(child_node, (NodePathComponent *)NULL,
pipeline_stage, current_thread); pipeline_stage, current_thread);
MutexHolder holder(child_node->_paths_lock); MutexHolder holder(child_node->_paths_lock);
child_node->_paths.insert(child); child_node->_paths.insert(child);
return child; return child;
@ -2864,8 +2864,8 @@ detach_one_stage(NodePathComponent *child, int pipeline_stage,
PT(Down) down = cdata_parent->modify_down(); PT(Down) down = cdata_parent->modify_down();
for (di = down->begin(); di != down->end(); ++di) { for (di = down->begin(); di != down->end(); ++di) {
if ((*di).get_child() == child_node) { if ((*di).get_child() == child_node) {
down->erase(di); down->erase(di);
found = true; found = true;
break; break;
} }
} }
@ -2917,7 +2917,7 @@ reparent(NodePathComponent *new_parent, NodePathComponent *child, int sort,
pipeline_stage_i >= 0; pipeline_stage_i >= 0;
--pipeline_stage_i) { --pipeline_stage_i) {
if (reparent_one_stage(new_parent, child, sort, as_stashed, if (reparent_one_stage(new_parent, child, sort, as_stashed,
pipeline_stage_i, current_thread)) { pipeline_stage_i, current_thread)) {
any_ok = true; any_ok = true;
} }
} }
@ -2945,7 +2945,7 @@ reparent(NodePathComponent *new_parent, NodePathComponent *child, int sort,
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool PandaNode:: bool PandaNode::
reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child, reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child,
int sort, bool as_stashed, int pipeline_stage, int sort, bool as_stashed, int pipeline_stage,
Thread *current_thread) { Thread *current_thread) {
nassertr(child != (NodePathComponent *)NULL, false); nassertr(child != (NodePathComponent *)NULL, false);
@ -2966,8 +2966,8 @@ reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child,
int parent_index = child_node->do_find_parent(parent_node, cdata_child); int parent_index = child_node->do_find_parent(parent_node, cdata_child);
if (parent_index >= 0) { if (parent_index >= 0) {
// Whoops, there's already another instance of the child there. // Whoops, there's already another instance of the child there.
return false; return false;
} }
} }
@ -2989,8 +2989,8 @@ reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child,
#ifndef NDEBUG #ifndef NDEBUG
// The NodePathComponent should already be in the set. // The NodePathComponent should already be in the set.
{ {
MutexHolder holder(child_node->_paths_lock); MutexHolder holder(child_node->_paths_lock);
nassertr(child_node->_paths.find(child) != child_node->_paths.end(), false); nassertr(child_node->_paths.find(child) != child_node->_paths.end(), false);
} }
#endif // NDEBUG #endif // NDEBUG
} }
@ -3011,7 +3011,7 @@ reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child,
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
PT(NodePathComponent) PandaNode:: PT(NodePathComponent) PandaNode::
get_component(NodePathComponent *parent, PandaNode *child_node, get_component(NodePathComponent *parent, PandaNode *child_node,
int pipeline_stage, Thread *current_thread) { int pipeline_stage, Thread *current_thread) {
nassertr(parent != (NodePathComponent *)NULL, (NodePathComponent *)NULL); nassertr(parent != (NodePathComponent *)NULL, (NodePathComponent *)NULL);
PandaNode *parent_node = parent->get_node(); PandaNode *parent_node = parent->get_node();
@ -3084,7 +3084,7 @@ get_top_component(PandaNode *child_node, bool force, int pipeline_stage,
// return a new one. // return a new one.
PT(NodePathComponent) child = PT(NodePathComponent) child =
new NodePathComponent(child_node, (NodePathComponent *)NULL, new NodePathComponent(child_node, (NodePathComponent *)NULL,
pipeline_stage, current_thread); pipeline_stage, current_thread);
child_node->_paths.insert(child); child_node->_paths.insert(child);
return child; return child;
@ -3107,7 +3107,7 @@ get_generic_component(bool accept_ambiguity, int pipeline_stage,
bool ambiguity_detected = false; bool ambiguity_detected = false;
PT(NodePathComponent) result = PT(NodePathComponent) result =
r_get_generic_component(accept_ambiguity, ambiguity_detected, r_get_generic_component(accept_ambiguity, ambiguity_detected,
pipeline_stage, current_thread); pipeline_stage, current_thread);
if (!accept_ambiguity && ambiguity_detected) { if (!accept_ambiguity && ambiguity_detected) {
pgraph_cat.warning() pgraph_cat.warning()
@ -3128,7 +3128,7 @@ get_generic_component(bool accept_ambiguity, int pipeline_stage,
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
PT(NodePathComponent) PandaNode:: PT(NodePathComponent) PandaNode::
r_get_generic_component(bool accept_ambiguity, bool &ambiguity_detected, r_get_generic_component(bool accept_ambiguity, bool &ambiguity_detected,
int pipeline_stage, Thread *current_thread) { int pipeline_stage, Thread *current_thread) {
PT(PandaNode) parent_node; PT(PandaNode) parent_node;
{ {
@ -3144,7 +3144,7 @@ r_get_generic_component(bool accept_ambiguity, bool &ambiguity_detected,
if (num_parents == 1) { if (num_parents == 1) {
// Only one parent; no ambiguity. // Only one parent; no ambiguity.
PT(NodePathComponent) parent = PT(NodePathComponent) parent =
get_parent(0)->r_get_generic_component(accept_ambiguity, ambiguity_detected, pipeline_stage, current_thread); get_parent(0)->r_get_generic_component(accept_ambiguity, ambiguity_detected, pipeline_stage, current_thread);
return get_component(parent, this, pipeline_stage, current_thread); return get_component(parent, this, pipeline_stage, current_thread);
} }
@ -3205,9 +3205,9 @@ sever_connection(PandaNode *parent_node, PandaNode *child_node,
Paths::iterator pi; Paths::iterator pi;
for (pi = child_node->_paths.begin(); pi != child_node->_paths.end(); ++pi) { for (pi = child_node->_paths.begin(); pi != child_node->_paths.end(); ++pi) {
if (!(*pi)->is_top_node(pipeline_stage, current_thread) && if (!(*pi)->is_top_node(pipeline_stage, current_thread) &&
(*pi)->get_next(pipeline_stage, current_thread)->get_node() == parent_node) { (*pi)->get_next(pipeline_stage, current_thread)->get_node() == parent_node) {
// Sever the component here. // Sever the component here.
(*pi)->set_top_node(pipeline_stage, current_thread); (*pi)->set_top_node(pipeline_stage, current_thread);
} }
} }
} }
@ -3238,7 +3238,7 @@ new_connection(PandaNode *parent_node, PandaNode *child_node,
Paths::iterator pi; Paths::iterator pi;
for (pi = child_node->_paths.begin(); pi != child_node->_paths.end(); ++pi) { for (pi = child_node->_paths.begin(); pi != child_node->_paths.end(); ++pi) {
if ((*pi)->is_top_node(pipeline_stage, current_thread)) { if ((*pi)->is_top_node(pipeline_stage, current_thread)) {
(*pi)->set_next(parent_node->get_generic_component(false, pipeline_stage, current_thread), pipeline_stage, current_thread); (*pi)->set_next(parent_node->get_generic_component(false, pipeline_stage, current_thread), pipeline_stage, current_thread);
} }
} }
} }
@ -3439,10 +3439,10 @@ update_bounds(int pipeline_stage, PandaNode::CDLockedStageReader &cdata) {
CDLockedStageReader child_cdata(child->_cycler, pipeline_stage, current_thread); CDLockedStageReader child_cdata(child->_cycler, pipeline_stage, current_thread);
if (child_cdata->_last_update != child_cdata->_next_update) { if (child_cdata->_last_update != child_cdata->_next_update) {
// Child needs update. // Child needs update.
CDStageWriter child_cdataw = child->update_bounds(pipeline_stage, child_cdata); CDStageWriter child_cdataw = child->update_bounds(pipeline_stage, child_cdata);
net_collide_mask |= child_cdataw->_net_collide_mask; net_collide_mask |= child_cdataw->_net_collide_mask;
DrawMask child_control_mask = child_cdataw->_net_draw_control_mask; DrawMask child_control_mask = child_cdataw->_net_draw_control_mask;
DrawMask child_show_mask = child_cdataw->_net_draw_show_mask; DrawMask child_show_mask = child_cdataw->_net_draw_show_mask;
@ -3474,7 +3474,7 @@ update_bounds(int pipeline_stage, PandaNode::CDLockedStageReader &cdata) {
<< "\n"; << "\n";
} }
off_clip_planes = orig_cp->compose_off(child_cdataw->_off_clip_planes); off_clip_planes = orig_cp->compose_off(child_cdataw->_off_clip_planes);
if (!child_cdataw->_external_bounds->is_empty()) { if (!child_cdataw->_external_bounds->is_empty()) {
child_volumes_ref.push_back(child_cdataw->_external_bounds); child_volumes_ref.push_back(child_cdataw->_external_bounds);
child_volumes.push_back(child_cdataw->_external_bounds); child_volumes.push_back(child_cdataw->_external_bounds);
@ -3485,8 +3485,8 @@ update_bounds(int pipeline_stage, PandaNode::CDLockedStageReader &cdata) {
num_vertices += child_cdataw->_nested_vertices; num_vertices += child_cdataw->_nested_vertices;
} else { } else {
// Child is good. // Child is good.
net_collide_mask |= child_cdata->_net_collide_mask; net_collide_mask |= child_cdata->_net_collide_mask;
// See comments in similar block above. // See comments in similar block above.
DrawMask child_control_mask = child_cdata->_net_draw_control_mask; DrawMask child_control_mask = child_cdata->_net_draw_control_mask;
@ -3511,7 +3511,7 @@ update_bounds(int pipeline_stage, PandaNode::CDLockedStageReader &cdata) {
<< "\n"; << "\n";
} }
off_clip_planes = orig_cp->compose_off(child_cdata->_off_clip_planes); off_clip_planes = orig_cp->compose_off(child_cdata->_off_clip_planes);
if (!child_cdata->_external_bounds->is_empty()) { if (!child_cdata->_external_bounds->is_empty()) {
child_volumes_ref.push_back(child_cdata->_external_bounds); child_volumes_ref.push_back(child_cdata->_external_bounds);
child_volumes.push_back(child_cdata->_external_bounds); child_volumes.push_back(child_cdata->_external_bounds);
@ -3534,10 +3534,10 @@ update_bounds(int pipeline_stage, PandaNode::CDLockedStageReader &cdata) {
// Now grab the write lock on this node. // Now grab the write lock on this node.
CDStageWriter cdataw(_cycler, pipeline_stage, current_thread); CDStageWriter cdataw(_cycler, pipeline_stage, current_thread);
if (last_update == cdataw->_last_update && if (last_update == cdataw->_last_update &&
next_update == cdataw->_next_update) { next_update == cdataw->_next_update) {
// Great, no one has monkeyed with these while we were computing // Great, no one has monkeyed with these while we were computing
// the cache. Safe to store the computed values and return. // the cache. Safe to store the computed values and return.
cdataw->_net_collide_mask = net_collide_mask; cdataw->_net_collide_mask = net_collide_mask;
if (renderable) { if (renderable) {
// There are renderable nodes below, so the implicit draw // There are renderable nodes below, so the implicit draw
@ -3559,10 +3559,10 @@ update_bounds(int pipeline_stage, PandaNode::CDLockedStageReader &cdata) {
} }
} }
cdataw->_off_clip_planes = off_clip_planes; cdataw->_off_clip_planes = off_clip_planes;
cdataw->_nested_vertices = num_vertices; cdataw->_nested_vertices = num_vertices;
CPT(TransformState) transform = get_transform(current_thread); CPT(TransformState) transform = get_transform(current_thread);
PT(GeometricBoundingVolume) gbv; PT(GeometricBoundingVolume) gbv;
if (bounds_type == BoundingVolume::BT_box || if (bounds_type == BoundingVolume::BT_box ||
@ -3589,19 +3589,19 @@ update_bounds(int pipeline_stage, PandaNode::CDLockedStageReader &cdata) {
gbv->xform(transform->get_mat()); gbv->xform(transform->get_mat());
} }
cdataw->_external_bounds = gbv; cdataw->_external_bounds = gbv;
cdataw->_last_update = next_update; cdataw->_last_update = next_update;
if (drawmask_cat.is_debug()) { if (drawmask_cat.is_debug()) {
drawmask_cat.debug(false) drawmask_cat.debug(false)
<< "} " << *this << "::update_bounds();\n"; << "} " << *this << "::update_bounds();\n";
} }
return cdataw; return cdataw;
} }
if (cdataw->_last_update == cdataw->_next_update) { if (cdataw->_last_update == cdataw->_next_update) {
// Someone else has computed the cache for us. OK. // Someone else has computed the cache for us. OK.
return cdataw; return cdataw;
} }
} }