15 #include "eggBinner.h"
16 #include "eggRenderState.h"
17 #include "eggPrimitive.h"
18 #include "eggNurbsSurface.h"
19 #include "eggNurbsCurve.h"
21 #include "eggSwitchCondition.h"
45 if (node->
is_of_type(EggPrimitive::get_class_type())) {
48 render_state->fill_state(egg_prim);
59 get_bin_number(
const EggNode *node) {
60 if (node->
is_of_type(EggNurbsSurface::get_class_type())) {
61 return (
int)BN_nurbs_surface;
63 }
else if (node->
is_of_type(EggNurbsCurve::get_class_type())) {
64 return (
int)BN_nurbs_curve;
66 }
else if (node->
is_of_type(EggPatch::get_class_type())) {
67 return (
int)BN_patches;
69 }
else if (node->
is_of_type(EggPrimitive::get_class_type())) {
70 return (
int)BN_polyset;
72 }
else if (node->
is_of_type(EggGroup::get_class_type())) {
74 if (group->has_lod()) {
91 if (bin_number == BN_polyset || bin_number == BN_patches) {
105 switch (bin_number) {
110 DCAST_INTO_R(pa, a,
false);
111 DCAST_INTO_R(pb, b,
false);
115 DCAST_INTO_R(rsa, pa->
get_user_data(EggRenderState::get_class_type()),
false);
116 DCAST_INTO_R(rsb, pb->
get_user_data(EggRenderState::get_class_type()),
false);
119 return (compare < 0);
122 if (bin_number == BN_patches) {
125 DCAST_INTO_R(patch_a, a,
false);
126 DCAST_INTO_R(patch_b, b,
false);
127 if (patch_a->size() != patch_b->size()) {
128 return patch_a->size() < patch_b->size();
152 return (swda._center.
compare_to(swdb._center) < 0);
155 case BN_nurbs_surface:
A base class for any of a number of kinds of geometry primitives: polygons, point lights...
EggUserData * get_user_data() const
Returns the user data pointer most recently stored on this object, or NULL if nothing was previously ...
virtual bool sorts_less(int bin_number, const EggNode *a, const EggNode *b)
May be overridden in derived classes to create additional bins within a particular bin number...
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
This class is used within this package only to record the render state that should be assigned to eac...
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
A single "patch", a special primitive to be rendered only with a tessellation shader.
string get_sort_name() const
Returns the name of the primitive for the purposes of sorting primitives into different groups...
void set_user_data(EggUserData *user_data)
Sets the user data associated with this object.
int compare_to(const EggRenderState &other) const
Provides a unique ordering for different EggRenderState objects, so that primitives of similar state ...
virtual void prepare_node(EggNode *node)
May be overridden in derived classes to perform some setup work as each node is encountered.
int compare_to(const LVecBase3d &other) const
This flavor of compare_to uses a default threshold value based on the numeric type.
A base class for things that may be directly added into the egg hierarchy.
This corresponds to a <SwitchCondition> entry within a group.
virtual string get_bin_name(int bin_number, const EggNode *child)
May be overridden in derived classes to define a name for each new bin, based on its bin number...
A SwitchCondition that switches the levels-of-detail based on distance from the camera's eyepoint...
Converts an egg data structure, possibly read from an egg file but not necessarily, into a scene graph suitable for rendering.