fix flatten in conjunction with billboards

This commit is contained in:
David Rose 2005-03-23 23:32:07 +00:00
parent 47e094a9da
commit 6912d2d48c
7 changed files with 53 additions and 0 deletions

View File

@ -61,6 +61,22 @@ safe_to_transform() const {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: BillboardEffect::prepare_flatten_transform
// Access: Public, Virtual
// Description: Preprocesses the accumulated transform that is about
// to be applied to (or through) this node due to a
// flatten operation. The returned value will be used
// instead.
////////////////////////////////////////////////////////////////////
CPT(TransformState) BillboardEffect::
prepare_flatten_transform(const TransformState *net_transform) const {
// We don't want any flatten operation to rotate the billboarded
// node, since the billboard effect should eat any rotation that
// comes in from above.
return net_transform->set_hpr(LVecBase3f(0, 0, 0));
}
////////////////////////////////////////////////////////////////////
// Function: BillboardEffect::output
// Access: Public, Virtual

View File

@ -56,6 +56,7 @@ PUBLISHED:
public:
virtual bool safe_to_transform() const;
virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const;
virtual void output(ostream &out) const;
virtual bool has_cull_callback() const;

View File

@ -102,6 +102,19 @@ safe_to_transform() const {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: RenderEffect::prepare_flatten_transform
// Access: Public, Virtual
// Description: Preprocesses the accumulated transform that is about
// to be applied to (or through) this node due to a
// flatten operation. The returned value will be used
// instead.
////////////////////////////////////////////////////////////////////
CPT(TransformState) RenderEffect::
prepare_flatten_transform(const TransformState *net_transform) const {
return net_transform;
}
////////////////////////////////////////////////////////////////////
// Function: RenderEffect::safe_to_combine
// Access: Public, Virtual

View File

@ -67,6 +67,7 @@ public:
virtual ~RenderEffect();
virtual bool safe_to_transform() const;
virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const;
virtual bool safe_to_combine() const;
virtual CPT(RenderEffect) xform(const LMatrix4f &mat) const;

View File

@ -109,6 +109,26 @@ safe_to_transform() const {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: RenderEffects::prepare_flatten_transform
// Access: Public, Virtual
// Description: Preprocesses the accumulated transform that is about
// to be applied to (or through) this node due to a
// flatten operation. The returned value will be used
// instead.
////////////////////////////////////////////////////////////////////
CPT(TransformState) RenderEffects::
prepare_flatten_transform(const TransformState *net_transform) const {
CPT(TransformState) result = net_transform;
Effects::const_iterator ai;
for (ai = _effects.begin(); ai != _effects.end(); ++ai) {
const Effect &effect = (*ai);
result = effect._effect->prepare_flatten_transform(result);
}
return result;
}
////////////////////////////////////////////////////////////////////
// Function: RenderEffects::safe_to_combine
// Access: Public

View File

@ -57,6 +57,7 @@ public:
virtual ~RenderEffects();
bool safe_to_transform() const;
virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const;
bool safe_to_combine() const;
CPT(RenderEffects) xform(const LMatrix4f &mat) const;

View File

@ -114,6 +114,7 @@ r_apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs,
<< "Node " << *node
<< " contains a non-transformable effect; leaving transform here.\n";
}
next_attribs._transform = effects->prepare_flatten_transform(next_attribs._transform);
apply_types |= TT_transform;
}
if (!node->safe_to_transform()) {