37 |
|
|
38 |
namespace Vob { |
namespace Vob { |
39 |
namespace Primitives { |
namespace Primitives { |
40 |
|
|
41 |
/** A tag interface, implying for a primitive |
/** Base class for... */ |
42 |
* transform that there are parameters. |
class DisablableIdentity : |
43 |
*/ |
public PrimitiveTransform, |
44 |
class DisablablePrimitiveTransform { |
public DisablablePrimitiveTransform { |
45 |
public: |
public: |
46 |
bool disabled; |
bool enabled; |
47 |
|
|
48 |
|
typedef DisablableIdentity InverseType; |
49 |
|
void inverse(InverseType &into) const { } |
50 |
}; |
}; |
51 |
|
|
52 |
/** Culling transform can decide not to be drawn when its |
/** Culling transform can decide not to be drawn when its |
53 |
* parents' boxes do not intersect. |
* parents' boxes do not intersect. |
54 |
*/ |
*/ |
55 |
class Cull : |
class Cull : |
56 |
public PrimitiveTransform, |
public DisablableIdentity |
|
public DisablablePrimitiveTransform |
|
57 |
{ |
{ |
58 |
public: |
public: |
|
const Transform *parent; |
|
|
const Transform *test; |
|
|
const Transform *clip; |
|
|
|
|
59 |
enum { NDepends = 3 }; |
enum { NDepends = 3 }; |
|
template<class SPtr> void setParams(SPtr depends) { |
|
|
parent = depends[0]; |
|
|
test = depends[1]; |
|
|
clip = depends[2]; |
|
60 |
|
|
61 |
if (shouldBeDrawn()) disabled = false; |
template<class SPtr> void setParams(SPtr depends) { |
62 |
else disabled = true; |
if (shouldBeDrawn(depends[1], depends[2])) enabled = false; |
63 |
} |
else enabled = true; |
|
|
|
|
virtual ZPt transform(const ZPt &p) const { |
|
|
return parent->transform(p); |
|
|
} |
|
|
|
|
|
virtual void vertex(const ZPt &p) const { |
|
|
parent->vertex(p); |
|
|
} |
|
|
|
|
|
virtual bool canPerformGL() const { |
|
|
return parent->canPerformGL(); |
|
|
} |
|
|
|
|
|
virtual bool performGL() const { |
|
|
return parent->performGL(); |
|
|
} |
|
|
|
|
|
virtual float nonlinearity(const ZPt &p, float radius) const { |
|
|
float n1 = parent->nonlinearity(p, radius); |
|
|
float n2 = clip->nonlinearity(parent->transform(p), radius); |
|
|
return (n1 > n2 ? n1 : n2); |
|
|
} |
|
|
|
|
|
typedef Cull InverseType; |
|
|
void inverse(InverseType &into) const { |
|
|
into.parent = parent; |
|
|
into.test = test; |
|
|
into.clip = clip; |
|
|
into.disabled = disabled; |
|
|
} |
|
|
|
|
|
virtual void dump(std::ostream &out) const { |
|
|
out << " CULL "; |
|
64 |
} |
} |
65 |
|
|
66 |
virtual Pt getSqSize() const { |
bool shouldBeDrawn() const { return enabled; } |
|
return parent->getSqSize(); |
|
|
} |
|
67 |
|
|
68 |
/** Cull transforms' shouldBeDrawn() returns true always when boxes |
/** Cull transforms' shouldBeDrawn() returns true always when boxes |
69 |
* of its test and clip coordinate systems do intersect. When |
* of its test and clip coordinate systems do intersect. When |
70 |
* the boxes don't intersect, it should retun false. |
* the boxes don't intersect, it should retun false. |
71 |
*/ |
*/ |
72 |
virtual bool shouldBeDrawn() const { |
bool shouldBeDrawn(const Transform *test, const Transform *clip) const { |
73 |
Pt box; |
Pt box; |
74 |
float hyp; |
float hyp; |
75 |
/** Lower left and upper right points of bounding boxes for |
/** Lower left and upper right points of bounding boxes for |