GeomEnum unification; FrameRateMeter use UH_client

This commit is contained in:
David Rose 2005-04-14 17:23:36 +00:00
parent 500f17c091
commit 00485bf6c8
95 changed files with 1028 additions and 800 deletions

View File

@ -380,8 +380,7 @@ copy_geom(const Geom *source, const Character *from) {
if (source->is_of_type(qpGeom::get_class_type())) {
CPT(qpGeom) qpsource = DCAST(qpGeom, source);
CPT(qpGeomVertexFormat) format = qpsource->get_vertex_data()->get_format();
if (format->get_animation().get_animation_type() ==
qpGeomVertexAnimationSpec::AT_none) {
if (format->get_animation().get_animation_type() == qpGeom::AT_none) {
// Not animated, so never mind.
return (Geom *)source;
}

View File

@ -311,10 +311,10 @@ fill_viz_geom() {
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("collision", qpGeomVertexFormat::get_v3(),
qpGeomUsageHint::UH_static);
qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_static);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_static);
for (int sl = 0; sl < num_slices; ++sl) {
float longitude0 = (float)sl / (float)num_slices;
float longitude1 = (float)(sl + 1) / (float)num_slices;

View File

@ -86,7 +86,7 @@ fill_viz_geom() {
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("collision", qpGeomVertexFormat::get_v3cp(),
qpGeomUsageHint::UH_static);
qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter color(vdata, InternalName::get_color());
@ -98,7 +98,7 @@ fill_viz_geom() {
fabs(t) * Colorf(0.0f, 0.0f, 0.0f, -1.0f));
}
PT(qpGeomLinestrips) line = new qpGeomLinestrips(qpGeomUsageHint::UH_static);
PT(qpGeomLinestrips) line = new qpGeomLinestrips(qpGeom::UH_static);
line->add_next_vertices(num_points);
line->close_primitive();

View File

@ -328,7 +328,7 @@ fill_viz_geom() {
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("collision", qpGeomVertexFormat::get_v3(),
qpGeomUsageHint::UH_static);
qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
vertex.add_data3f(cp + p1 * plane_scale);
@ -336,11 +336,11 @@ fill_viz_geom() {
vertex.add_data3f(cp + p3 * plane_scale);
vertex.add_data3f(cp + p4 * plane_scale);
PT(qpGeomTrifans) body = new qpGeomTrifans(qpGeomUsageHint::UH_static);
PT(qpGeomTrifans) body = new qpGeomTrifans(qpGeom::UH_static);
body->add_consecutive_vertices(0, 4);
body->close_primitive();
PT(qpGeomLinestrips) border = new qpGeomLinestrips(qpGeomUsageHint::UH_static);
PT(qpGeomLinestrips) border = new qpGeomLinestrips(qpGeom::UH_static);
border->add_consecutive_vertices(0, 4);
border->add_vertex(0);
border->close_primitive();

View File

@ -820,7 +820,7 @@ draw_polygon(GeomNode *viz_geom_node, GeomNode *bounds_viz_geom_node,
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("collision", qpGeomVertexFormat::get_v3(),
qpGeomUsageHint::UH_static);
qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
Points::const_iterator pi;
@ -828,11 +828,11 @@ draw_polygon(GeomNode *viz_geom_node, GeomNode *bounds_viz_geom_node,
vertex.add_data3f(to_3d((*pi)._p, to_3d_mat));
}
PT(qpGeomTrifans) body = new qpGeomTrifans(qpGeomUsageHint::UH_static);
PT(qpGeomTrifans) body = new qpGeomTrifans(qpGeom::UH_static);
body->add_consecutive_vertices(0, points.size());
body->close_primitive();
PT(qpGeomLinestrips) border = new qpGeomLinestrips(qpGeomUsageHint::UH_static);
PT(qpGeomLinestrips) border = new qpGeomLinestrips(qpGeom::UH_static);
border->add_consecutive_vertices(0, points.size());
border->add_vertex(0);
border->close_primitive();

View File

@ -158,7 +158,7 @@ fill_viz_geom() {
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("collision", qpGeomVertexFormat::get_v3cp(),
qpGeomUsageHint::UH_static);
qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter color(vdata, InternalName::get_color());
@ -170,7 +170,7 @@ fill_viz_geom() {
t * Colorf(0.0f, 0.0f, 0.0f, -1.0f));
}
PT(qpGeomLinestrips) line = new qpGeomLinestrips(qpGeomUsageHint::UH_static);
PT(qpGeomLinestrips) line = new qpGeomLinestrips(qpGeom::UH_static);
line->add_next_vertices(num_points);
line->close_primitive();

View File

@ -162,13 +162,13 @@ fill_viz_geom() {
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("collision", qpGeomVertexFormat::get_v3cp(),
qpGeomUsageHint::UH_static);
qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
vertex.add_data3f(_a);
vertex.add_data3f(_b);
PT(qpGeomLines) line = new qpGeomLines(qpGeomUsageHint::UH_static);
PT(qpGeomLines) line = new qpGeomLines(qpGeom::UH_static);
line->add_next_vertices(2);
line->close_primitive();

View File

@ -330,10 +330,10 @@ fill_viz_geom() {
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("collision", qpGeomVertexFormat::get_v3(),
qpGeomUsageHint::UH_static);
qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_static);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_static);
for (int sl = 0; sl < num_slices; ++sl) {
float longitude0 = (float)sl / (float)num_slices;
float longitude1 = (float)(sl + 1) / (float)num_slices;

View File

@ -394,10 +394,10 @@ fill_viz_geom() {
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("collision", qpGeomVertexFormat::get_v3(),
qpGeomUsageHint::UH_static);
qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_static);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_static);
// Generate the first endcap.
static const int num_slices = 8;
static const int num_rings = 4;

View File

@ -35,8 +35,8 @@ TypeHandle StandardMunger::_type_handle;
StandardMunger::
StandardMunger(const GraphicsStateGuardianBase *gsg, const RenderState *state,
int num_components,
qpGeomVertexColumn::NumericType numeric_type,
qpGeomVertexColumn::Contents contents) :
StandardMunger::NumericType numeric_type,
StandardMunger::Contents contents) :
qpGeomMunger(gsg, state),
_num_components(num_components),
_numeric_type(numeric_type),
@ -90,7 +90,7 @@ munge_data_impl(const qpGeomVertexData *data) {
qpGeomVertexAnimationSpec animation = new_data->get_format()->get_animation();
if (hardware_animated_vertices &&
animation.get_animation_type() == qpGeomVertexAnimationSpec::AT_panda &&
animation.get_animation_type() == AT_panda &&
new_data->get_slider_table() == (SliderTable *)NULL) {
// Maybe we can animate the vertices with hardware.
const TransformBlendPalette *palette = new_data->get_transform_blend_palette();

View File

@ -39,9 +39,8 @@
class EXPCL_PANDA StandardMunger : public qpGeomMunger {
public:
StandardMunger(const GraphicsStateGuardianBase *gsg, const RenderState *state,
int num_components,
qpGeomVertexColumn::NumericType numeric_type,
qpGeomVertexColumn::Contents contents);
int num_components, NumericType numeric_type,
Contents contents);
virtual ~StandardMunger();
protected:
@ -51,8 +50,8 @@ protected:
private:
int _num_components;
qpGeomVertexColumn::NumericType _numeric_type;
qpGeomVertexColumn::Contents _contents;
NumericType _numeric_type;
Contents _contents;
CPT(GraphicsStateGuardian) _gsg;
CPT(ColorAttrib) _color;
CPT(ColorScaleAttrib) _color_scale;

View File

@ -213,7 +213,7 @@ generate_screen(const NodePath &projector, const string &screen_name,
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("projectionScreen", qpGeomVertexFormat::get_v3n3(),
qpGeomUsageHint::UH_dynamic);
qpGeom::UH_dynamic);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter normal(vdata, InternalName::get_normal());
@ -242,7 +242,7 @@ generate_screen(const NodePath &projector, const string &screen_name,
// Now synthesize a triangle mesh. We run triangle strips
// horizontally across the grid.
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_static);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_static);
// Fill up the index array into the vertices. This lays out the
// order of the vertices in each tristrip.
int ti, si;
@ -609,15 +609,15 @@ recompute_geom(Geom *geom, const LMatrix4f &rel_mat) {
if (!vdata->has_column(_texcoord_name)) {
// We need to add a new column for the new texcoords.
vdata = vdata->replace_column
(_texcoord_name, 2, qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_texcoord, qpGeomUsageHint::UH_dynamic, true);
(_texcoord_name, 2, qpGeom::NT_float32,
qpGeom::C_texcoord, qpGeom::UH_dynamic, true);
qpgeom->set_vertex_data(vdata);
}
if (_vignette_on && !vdata->has_column(InternalName::get_color())) {
// We need to add a column for color.
vdata = vdata->replace_column
(InternalName::get_color(), 1, qpGeomVertexColumn::NT_packed_dabc,
qpGeomVertexColumn::C_color, qpGeomUsageHint::UH_dynamic, true);
(InternalName::get_color(), 1, qpGeom::NT_packed_dabc,
qpGeom::C_color, qpGeom::UH_dynamic, true);
qpgeom->set_vertex_data(vdata);
}

View File

@ -24,8 +24,7 @@
////////////////////////////////////////////////////////////////////
INLINE DXGeomMunger8::
DXGeomMunger8(GraphicsStateGuardian *gsg, const RenderState *state) :
StandardMunger(gsg, state, 1, qpGeomVertexColumn::NT_packed_dabc,
qpGeomVertexColumn::C_color)
StandardMunger(gsg, state, 1, NT_packed_dabc, C_color)
{
}

View File

@ -34,7 +34,7 @@ CPT(qpGeomVertexFormat) DXGeomMunger8::
munge_format_impl(const qpGeomVertexFormat *orig,
const qpGeomVertexAnimationSpec &animation) {
if (dxgsg8_cat.is_debug()) {
if (animation.get_animation_type() != qpGeomVertexAnimationSpec::AT_none) {
if (animation.get_animation_type() != AT_none) {
dxgsg8_cat.debug()
<< "preparing animation type " << animation << "\n";
}
@ -54,7 +54,7 @@ munge_format_impl(const qpGeomVertexFormat *orig,
if (vertex_type != (const qpGeomVertexColumn *)NULL) {
new_array_format->add_column
(InternalName::get_vertex(), 3, qpGeomVertexColumn::NT_float32,
(InternalName::get_vertex(), 3, NT_float32,
vertex_type->get_contents());
new_format->remove_column(vertex_type->get_name());
@ -63,14 +63,14 @@ munge_format_impl(const qpGeomVertexFormat *orig,
return orig;
}
if (animation.get_animation_type() == qpGeomVertexAnimationSpec::AT_hardware &&
if (animation.get_animation_type() == AT_hardware &&
animation.get_num_transforms() > 0) {
if (animation.get_num_transforms() > 1) {
// If we want hardware animation, we need to reserve space for the
// blend weights.
new_array_format->add_column
(InternalName::get_transform_weight(), animation.get_num_transforms() - 1,
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_other);
NT_float32, C_other);
}
if (animation.get_indexed_transforms()) {
@ -78,7 +78,7 @@ munge_format_impl(const qpGeomVertexFormat *orig,
// space for the index.
new_array_format->add_column
(InternalName::get_transform_index(), 1,
qpGeomVertexColumn::NT_packed_dcba, qpGeomVertexColumn::C_index);
NT_packed_dcba, C_index);
}
// Make sure the old weights and indices are removed, just in
@ -92,15 +92,13 @@ munge_format_impl(const qpGeomVertexFormat *orig,
if (normal_type != (const qpGeomVertexColumn *)NULL) {
new_array_format->add_column
(InternalName::get_normal(), 3, qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_vector);
(InternalName::get_normal(), 3, NT_float32, C_vector);
new_format->remove_column(normal_type->get_name());
}
if (color_type != (const qpGeomVertexColumn *)NULL) {
new_array_format->add_column
(InternalName::get_color(), 1, qpGeomVertexColumn::NT_packed_dabc,
qpGeomVertexColumn::C_color);
(InternalName::get_color(), 1, NT_packed_dabc, C_color);
new_format->remove_column(color_type->get_name());
}
@ -110,7 +108,7 @@ munge_format_impl(const qpGeomVertexFormat *orig,
if (texcoord_type != (const qpGeomVertexColumn *)NULL) {
new_array_format->add_column
(InternalName::get_texcoord(), texcoord_type->get_num_values(),
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_texcoord);
NT_float32, C_texcoord);
new_format->remove_column(texcoord_type->get_name());
}

View File

@ -2647,7 +2647,7 @@ begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
const qpGeomVertexAnimationSpec &animation =
vertex_data->get_format()->get_animation();
if (animation.get_animation_type() == qpGeomVertexAnimationSpec::AT_hardware) {
if (animation.get_animation_type() == qpGeom::AT_hardware) {
// Set up vertex blending.
switch (animation.get_num_transforms()) {
case 1:

View File

@ -1998,19 +1998,19 @@ make_vertex_data(const EggRenderState *render_state,
PT(qpGeomVertexArrayFormat) array_format = new qpGeomVertexArrayFormat;
array_format->add_column
(InternalName::get_vertex(), vertex_pool->get_num_dimensions(),
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_point);
qpGeom::NT_float32, qpGeom::C_point);
if (vertex_pool->has_normals()) {
array_format->add_column
(InternalName::get_normal(), 3,
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_vector);
qpGeom::NT_float32, qpGeom::C_vector);
}
bool has_colors = vertex_pool->has_nonwhite_colors();
if (has_colors) {
array_format->add_column
(InternalName::get_color(), 1,
qpGeomVertexColumn::NT_packed_dabc, qpGeomVertexColumn::C_color);
qpGeom::NT_packed_dabc, qpGeom::C_color);
}
vector_string uv_names;
@ -2024,7 +2024,7 @@ make_vertex_data(const EggRenderState *render_state,
PT(InternalName) iname = InternalName::get_texcoord_name(name);
array_format->add_column
(iname, 2,
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_texcoord);
qpGeom::NT_float32, qpGeom::C_texcoord);
}
PT(qpGeomVertexFormat) temp_format = new qpGeomVertexFormat(array_format);
@ -2050,7 +2050,7 @@ make_vertex_data(const EggRenderState *render_state,
PT(qpGeomVertexArrayFormat) anim_array_format = new qpGeomVertexArrayFormat;
anim_array_format->add_column
(InternalName::get_transform_blend(), 1,
qpGeomVertexColumn::NT_uint16, qpGeomVertexColumn::C_index);
qpGeom::NT_uint16, qpGeom::C_index);
temp_format->add_array(anim_array_format);
pset<string> slider_names;
@ -2124,7 +2124,7 @@ make_vertex_data(const EggRenderState *render_state,
// be changing--just the result of applying the animation is
// dynamic.
PT(qpGeomVertexData) vertex_data =
new qpGeomVertexData(name, format, qpGeomUsageHint::UH_static);
new qpGeomVertexData(name, format, qpGeom::UH_static);
vertex_data->set_transform_blend_palette(blend_palette);
if (slider_table != (SliderTable *)NULL) {
@ -2266,7 +2266,7 @@ record_morph(qpGeomVertexArrayFormat *array_format,
if (!array_format->has_column(delta_name)) {
array_format->add_column
(delta_name, num_components,
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_morph_delta);
qpGeom::NT_float32, qpGeom::C_morph_delta);
}
}
@ -2282,24 +2282,24 @@ make_primitive(const EggRenderState *render_state, EggPrimitive *egg_prim,
PT(qpGeomPrimitive) primitive;
if (egg_prim->is_of_type(EggPolygon::get_class_type())) {
if (egg_prim->size() == 3) {
primitive = new qpGeomTriangles(qpGeomUsageHint::UH_static);
primitive = new qpGeomTriangles(qpGeom::UH_static);
}
} else if (egg_prim->is_of_type(EggTriangleStrip::get_class_type())) {
primitive = new qpGeomTristrips(qpGeomUsageHint::UH_static);
primitive = new qpGeomTristrips(qpGeom::UH_static);
} else if (egg_prim->is_of_type(EggTriangleFan::get_class_type())) {
primitive = new qpGeomTrifans(qpGeomUsageHint::UH_static);
primitive = new qpGeomTrifans(qpGeom::UH_static);
} else if (egg_prim->is_of_type(EggLine::get_class_type())) {
if (egg_prim->size() == 2) {
primitive = new qpGeomLines(qpGeomUsageHint::UH_static);
primitive = new qpGeomLines(qpGeom::UH_static);
} else {
primitive = new qpGeomLinestrips(qpGeomUsageHint::UH_static);
primitive = new qpGeomLinestrips(qpGeom::UH_static);
}
} else if (egg_prim->is_of_type(EggPoint::get_class_type())) {
primitive = new qpGeomPoints(qpGeomUsageHint::UH_static);
primitive = new qpGeomPoints(qpGeom::UH_static);
}
if (primitive == (qpGeomPrimitive *)NULL) {

View File

@ -27,7 +27,7 @@ EggRenderState(EggLoader &loader) :
_state(RenderState::make_empty()),
_hidden(false),
_flat_shaded(false),
_primitive_type(qpGeomPrimitive::PT_none),
_primitive_type(qpGeom::PT_none),
_loader(loader)
{
}

View File

@ -353,14 +353,14 @@ fill_state(EggPrimitive *egg_prim) {
}
if (egg_prim->is_of_type(EggLine::get_class_type())) {
_primitive_type = qpGeomPrimitive::PT_lines;
_primitive_type = qpGeom::PT_lines;
EggLine *egg_line = DCAST(EggLine, egg_prim);
if (egg_line->get_thick() != 1.0) {
add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_unchanged,
egg_line->get_thick()));
}
} else if (egg_prim->is_of_type(EggPoint::get_class_type())) {
_primitive_type = qpGeomPrimitive::PT_points;
_primitive_type = qpGeom::PT_points;
EggPoint *egg_point = DCAST(EggPoint, egg_prim);
if (egg_point->get_thick() != 1.0 || egg_point->get_perspective()) {
add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_unchanged,
@ -368,7 +368,7 @@ fill_state(EggPrimitive *egg_prim) {
egg_point->get_perspective()));
}
} else {
_primitive_type = qpGeomPrimitive::PT_polygons;
_primitive_type = qpGeom::PT_polygons;
}
if (has_bin) {

View File

@ -65,7 +65,7 @@ public:
CPT(RenderState) _state;
bool _hidden;
bool _flat_shaded;
qpGeomPrimitive::PrimitiveType _primitive_type;
qpGeom::PrimitiveType _primitive_type;
typedef EggLoader::BakeInUVs BakeInUVs;
typedef EggLoader::TextureDef TextureDef;

View File

@ -634,7 +634,7 @@ load_default_model(const NodePath &parent) {
// New, experimental Geom code.
PT(qpGeomVertexData) vdata = new qpGeomVertexData
(string(), qpGeomVertexFormat::get_v3n3cpt2(),
qpGeomUsageHint::UH_static);
qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter normal(vdata, InternalName::get_normal());
qpGeomVertexWriter color(vdata, InternalName::get_color());
@ -656,7 +656,7 @@ load_default_model(const NodePath &parent) {
texcoord.add_data2f(1.0, 0.0);
texcoord.add_data2f(0.0, 1.0);
PT(qpGeomTriangles) tri = new qpGeomTriangles(qpGeomUsageHint::UH_static);
PT(qpGeomTriangles) tri = new qpGeomTriangles(qpGeom::UH_static);
tri->add_consecutive_vertices(0, 3);
tri->close_primitive();
@ -1061,7 +1061,7 @@ load_image_as_model(const Filename &filename) {
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
(string(), qpGeomVertexFormat::get_v3t2(),
qpGeomUsageHint::UH_static);
qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter texcoord(vdata, InternalName::get_texcoord());
@ -1075,7 +1075,7 @@ load_image_as_model(const Filename &filename) {
texcoord.add_data2f(1.0f, 1.0f);
texcoord.add_data2f(1.0f, 0.0f);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_static);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_static);
strip->add_consecutive_vertices(0, 4);
strip->close_primitive();

View File

@ -24,8 +24,7 @@
////////////////////////////////////////////////////////////////////
INLINE CLP(GeomMunger)::
CLP(GeomMunger)(GraphicsStateGuardian *gsg, const RenderState *state) :
StandardMunger(gsg, state, 4, qpGeomVertexColumn::NT_uint8,
qpGeomVertexColumn::C_color),
StandardMunger(gsg, state, 4, NT_uint8, C_color),
_gsg(gsg),
_texture(state->get_texture()),
_tex_gen(state->get_tex_gen())

View File

@ -51,7 +51,7 @@ munge_format_impl(const qpGeomVertexFormat *orig,
const qpGeomVertexColumn *color_type = orig->get_color_column();
if (color_type != (qpGeomVertexColumn *)NULL &&
color_type->get_numeric_type() == qpGeomVertexColumn::NT_packed_dabc) {
color_type->get_numeric_type() == NT_packed_dabc) {
// We need to convert the color format; OpenGL doesn't support the
// byte order of DirectX's packed ARGB format.
int color_array = orig->get_array_with(InternalName::get_color());
@ -60,11 +60,11 @@ munge_format_impl(const qpGeomVertexFormat *orig,
// Replace the existing color format with the new format.
new_array_format->add_column
(InternalName::get_color(), 4, qpGeomVertexColumn::NT_uint8,
qpGeomVertexColumn::C_color, color_type->get_start());
(InternalName::get_color(), 4, NT_uint8,
C_color, color_type->get_start());
}
if (animation.get_animation_type() == qpGeomVertexAnimationSpec::AT_hardware &&
if (animation.get_animation_type() == AT_hardware &&
animation.get_num_transforms() > 0) {
// If we want hardware animation, we need to reserve space for the
// blend weights.
@ -72,7 +72,7 @@ munge_format_impl(const qpGeomVertexFormat *orig,
PT(qpGeomVertexArrayFormat) new_array_format = new qpGeomVertexArrayFormat;
new_array_format->add_column
(InternalName::get_transform_weight(), animation.get_num_transforms() - 1,
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_other);
NT_float32, C_other);
if (animation.get_indexed_transforms()) {
// Also, if we'll be indexing into the transform palette, reserve
@ -83,7 +83,7 @@ munge_format_impl(const qpGeomVertexFormat *orig,
// the maximum palette index, presumably in the AnimationSpec.
new_array_format->add_column
(InternalName::get_transform_index(), animation.get_num_transforms(),
qpGeomVertexColumn::NT_uint8, qpGeomVertexColumn::C_index);
NT_uint8, C_index);
}
// Make sure the old weights and indices are removed, just in

View File

@ -2195,7 +2195,7 @@ begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
const qpGeomVertexAnimationSpec &animation =
vertex_data->get_format()->get_animation();
bool hardware_animation = (animation.get_animation_type() == qpGeomVertexAnimationSpec::AT_hardware);
bool hardware_animation = (animation.get_animation_type() == qpGeom::AT_hardware);
if (hardware_animation) {
// Set up the transform matrices for vertex blending.
GLP(Enable)(GL_VERTEX_BLEND_ARB);
@ -2289,8 +2289,8 @@ begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
GLP(LoadIdentity)();
}
if (geom->get_usage_hint() == qpGeomUsageHint::UH_static &&
_vertex_data->get_usage_hint() == qpGeomUsageHint::UH_static &&
if (geom->get_usage_hint() == qpGeom::UH_static &&
_vertex_data->get_usage_hint() == qpGeom::UH_static &&
display_lists && (!hardware_animation || display_list_animation)) {
// If the geom claims to be totally static, try to build it into
// a display list.
@ -2342,7 +2342,7 @@ begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
const qpGeomVertexArrayData *array_data;
int num_values;
qpGeomVertexColumn::NumericType numeric_type;
qpGeom::NumericType numeric_type;
int start;
int stride;
@ -2366,7 +2366,7 @@ begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
if (_vertex_data->get_color_info(array_data, num_values, numeric_type,
start, stride) &&
numeric_type != qpGeomVertexColumn::NT_packed_dabc) {
numeric_type != qpGeom::NT_packed_dabc) {
const unsigned char *client_pointer = setup_array_data(array_data);
GLP(ColorPointer)(num_values, get_numeric_type(numeric_type),
stride, client_pointer + start);
@ -2494,10 +2494,6 @@ draw_tristrips(const qpGeomTristrips *primitive) {
const unsigned short *client_pointer = setup_primitive(primitive);
if (connect_triangle_strips && _render_mode != RenderModeAttrib::M_wireframe) {
GLCAT.debug()
<< "Connected triangle strips\n";
primitive->write(GLCAT.debug(), 2);
// One long triangle strip, connected by the degenerate vertices
// that have already been set up within the primitive.
_vertices_tristrip_pcollector.add_level(primitive->get_num_vertices());
@ -2508,10 +2504,6 @@ draw_tristrips(const qpGeomTristrips *primitive) {
GL_UNSIGNED_SHORT, client_pointer);
} else {
GLCAT.debug()
<< "Separate triangle strips\n";
primitive->write(GLCAT.debug(), 2);
// Send the individual triangle strips, stepping over the
// degenerate vertices.
CPTA_int ends = primitive->get_ends();
@ -2927,7 +2919,7 @@ setup_array_data(const qpGeomVertexArrayData *data) {
return data->get_data();
}
if (!vertex_buffers || _geom_display_list != 0 ||
data->get_usage_hint() == qpGeomUsageHint::UH_client) {
data->get_usage_hint() == qpGeom::UH_client) {
// The array specifies client rendering only, or buffer objects
// are configured off.
_glBindBuffer(GL_ARRAY_BUFFER, 0);
@ -3058,7 +3050,7 @@ setup_primitive(const qpGeomPrimitive *data) {
return data->get_flat_last_vertices();
}
if (!vertex_buffers || _geom_display_list != 0 ||
data->get_usage_hint() == qpGeomUsageHint::UH_client) {
data->get_usage_hint() == qpGeom::UH_client) {
// The array specifies client rendering only, or buffer objects
// are configured off.
_glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
@ -4723,17 +4715,17 @@ upload_texture_image(CLP(TextureContext) *gtc,
// to GL's.
////////////////////////////////////////////////////////////////////
GLenum CLP(GraphicsStateGuardian)::
get_numeric_type(qpGeomVertexColumn::NumericType numeric_type) {
get_numeric_type(qpGeom::NumericType numeric_type) {
switch (numeric_type) {
case qpGeomVertexColumn::NT_uint16:
case qpGeom::NT_uint16:
return GL_UNSIGNED_SHORT;
case qpGeomVertexColumn::NT_uint8:
case qpGeomVertexColumn::NT_packed_dcba:
case qpGeomVertexColumn::NT_packed_dabc:
case qpGeom::NT_uint8:
case qpGeom::NT_packed_dcba:
case qpGeom::NT_packed_dabc:
return GL_UNSIGNED_BYTE;
case qpGeomVertexColumn::NT_float32:
case qpGeom::NT_float32:
return GL_FLOAT;
}
@ -5191,18 +5183,19 @@ get_blend_func(ColorBlendAttrib::Operand operand) {
// Description: Maps from UsageHint to the GL symbol.
////////////////////////////////////////////////////////////////////
GLenum CLP(GraphicsStateGuardian)::
get_usage(qpGeomUsageHint::UsageHint usage_hint) {
get_usage(qpGeom::UsageHint usage_hint) {
switch (usage_hint) {
case qpGeomUsageHint::UH_stream:
case qpGeom::UH_stream:
return GL_STREAM_DRAW;
case qpGeomUsageHint::UH_static:
case qpGeom::UH_static:
case qpGeom::UH_unspecified:
return GL_STATIC_DRAW;
case qpGeomUsageHint::UH_dynamic:
case qpGeom::UH_dynamic:
return GL_DYNAMIC_DRAW;
case qpGeomUsageHint::UH_client:
case qpGeom::UH_client:
break;
}

View File

@ -242,7 +242,7 @@ protected:
GLint external_format, GLenum component_type,
const unsigned char *image);
static GLenum get_numeric_type(qpGeomVertexColumn::NumericType numeric_type);
static GLenum get_numeric_type(qpGeom::NumericType numeric_type);
GLenum get_texture_target(Texture::TextureType texture_type) const;
GLenum get_texture_wrap_mode(Texture::WrapMode wm);
static GLenum get_texture_filter_type(Texture::FilterType ft, bool ignore_mipmaps);
@ -256,7 +256,7 @@ protected:
static GLenum get_fog_mode_type(Fog::Mode m);
static GLenum get_blend_equation_type(ColorBlendAttrib::Mode mode);
static GLenum get_blend_func(ColorBlendAttrib::Operand operand);
static GLenum get_usage(qpGeomUsageHint::UsageHint usage_hint);
static GLenum get_usage(qpGeom::UsageHint usage_hint);
static CPT(RenderState) get_untextured_state();
static CPT(RenderState) get_smooth_state();

View File

@ -19,6 +19,7 @@
geomQuad.h geomSphere.h geomSprite.I geomSprite.h geomTri.h \
geomTrifan.h geomTristrip.h \
qpgeom.h qpgeom.I \
qpgeomEnums.h \
qpgeomMunger.h qpgeomMunger.I \
qpgeomPrimitive.h qpgeomPrimitive.I \
qpgeomTriangles.h \
@ -27,7 +28,6 @@
qpgeomLines.h \
qpgeomLinestrips.h \
qpgeomPoints.h \
qpgeomUsageHint.h \
qpgeomVertexArrayData.h qpgeomVertexArrayData.I \
qpgeomVertexArrayFormat.h qpgeomVertexArrayFormat.I \
qpgeomCacheEntry.h qpgeomCacheEntry.I \
@ -71,6 +71,7 @@
geomQuad.cxx geomSphere.cxx geomSprite.cxx geomTri.cxx \
geomTrifan.cxx geomTristrip.cxx \
qpgeom.cxx \
qpgeomEnums.cxx \
qpgeomMunger.cxx \
qpgeomPrimitive.cxx \
qpgeomTriangles.cxx \
@ -120,6 +121,7 @@
geomSprite.I geomSprite.h geomTri.h geomTrifan.h geomTristrip.h \
geomprimitives.h \
qpgeom.h qpgeom.I \
qpgeomEnums.h \
qpgeomMunger.h qpgeomMunger.I \
qpgeomPrimitive.h qpgeomPrimitive.I \
qpgeomTriangles.h \
@ -128,7 +130,6 @@
qpgeomLines.h \
qpgeomLinestrips.h \
qpgeomPoints.h \
qpgeomUsageHint.h \
qpgeomVertexArrayData.h qpgeomVertexArrayData.I \
qpgeomVertexArrayFormat.h qpgeomVertexArrayFormat.I \
qpgeomCacheEntry.h qpgeomCacheEntry.I \

View File

@ -12,6 +12,7 @@
#include "geomTrifan.cxx"
#include "geomTristrip.cxx"
#include "qpgeom.cxx"
#include "qpgeomEnums.cxx"
#include "qpgeomMunger.cxx"
#include "qpgeomPrimitive.cxx"
#include "qpgeomTriangles.cxx"

View File

@ -891,7 +891,7 @@ make_geometry() {
}
// Now string together the line segments.
PT(qpGeomLinestrips) line = new qpGeomLinestrips(qpGeomUsageHint::UH_static);
PT(qpGeomLinestrips) line = new qpGeomLinestrips(qpGeom::UH_static);
// Draw a frame around the near plane.
int i, si;
@ -1756,7 +1756,7 @@ define_geom_data() {
if (_geom_data == (qpGeomVertexData *)NULL) {
_geom_data = new qpGeomVertexData
("lens", qpGeomVertexFormat::get_v3(),
qpGeomUsageHint::UH_dynamic);
qpGeom::UH_dynamic);
}
qpGeomVertexWriter vertex(_geom_data, InternalName::get_vertex());

View File

@ -25,7 +25,7 @@
// primitives within a particular Geom must be the same
// type.
////////////////////////////////////////////////////////////////////
INLINE qpGeomPrimitive::PrimitiveType qpGeom::
INLINE qpGeom::PrimitiveType qpGeom::
get_primitive_type() const {
CDReader cdata(_cycler);
return cdata->_primitive_type;
@ -38,7 +38,7 @@ get_primitive_type() const {
// among all of the individual GeomPrimitives that have
// been added to the geom.
////////////////////////////////////////////////////////////////////
INLINE qpGeomUsageHint::UsageHint qpGeom::
INLINE qpGeom::UsageHint qpGeom::
get_usage_hint() const {
CDReader cdata(_cycler);
if (!cdata->_got_usage_hint) {
@ -117,6 +117,9 @@ modify_primitive(int i) {
nassertr(i >= 0 && i < (int)cdata->_primitives.size(), NULL);
cdata->_got_usage_hint = false;
cdata->_modified = qpGeom::get_next_modified();
if (cdata->_primitives[i]->get_ref_count() > 1) {
cdata->_primitives[i] = cdata->_primitives[i]->make_copy();
}
return cdata->_primitives[i];
}
@ -175,9 +178,9 @@ operator < (const CacheEntry &other) const {
////////////////////////////////////////////////////////////////////
INLINE qpGeom::CData::
CData() :
_primitive_type(qpGeomPrimitive::PT_none),
_primitive_type(PT_none),
_point_rendering(0),
_usage_hint(qpGeomUsageHint::UH_static),
_usage_hint(UH_unspecified),
_got_usage_hint(false)
{
}

View File

@ -104,6 +104,30 @@ make_copy() const {
return new qpGeom(*this);
}
////////////////////////////////////////////////////////////////////
// Function: qpGeom::set_usage_hint
// Access: Published
// Description: Changes the UsageHint hint for all of the primitives
// on this Geom to the same value. See
// get_usage_hint().
////////////////////////////////////////////////////////////////////
void qpGeom::
set_usage_hint(qpGeom::UsageHint usage_hint) {
clear_cache();
CDWriter cdata(_cycler);
cdata->_usage_hint = usage_hint;
Primitives::iterator pi;
for (pi = cdata->_primitives.begin(); pi != cdata->_primitives.end(); ++pi) {
if ((*pi)->get_ref_count() > 1) {
(*pi) = (*pi)->make_copy();
}
(*pi)->set_usage_hint(usage_hint);
}
cdata->_modified = qpGeom::get_next_modified();
}
////////////////////////////////////////////////////////////////////
// Function: qpGeom::modify_vertex_data
// Access: Published
@ -163,6 +187,9 @@ offset_vertices(const qpGeomVertexData *data, int offset) {
#endif
Primitives::iterator pi;
for (pi = cdata->_primitives.begin(); pi != cdata->_primitives.end(); ++pi) {
if ((*pi)->get_ref_count() > 1) {
(*pi) = (*pi)->make_copy();
}
(*pi)->offset_vertices(offset);
#ifndef NDEBUG
@ -195,7 +222,7 @@ set_primitive(int i, const qpGeomPrimitive *primitive) {
// All primitives within a particular Geom must have the same
// fundamental primitive type (triangles, points, or lines).
nassertv(cdata->_primitive_type == qpGeomPrimitive::PT_none ||
nassertv(cdata->_primitive_type == PT_none ||
cdata->_primitive_type == primitive->get_primitive_type());
if (cdata->_got_usage_hint &&
@ -212,7 +239,7 @@ set_primitive(int i, const qpGeomPrimitive *primitive) {
}
}
cdata->_primitives[i] = (qpGeomPrimitive *)primitive;
qpGeomPrimitive::PrimitiveType new_primitive_type = primitive->get_primitive_type();
PrimitiveType new_primitive_type = primitive->get_primitive_type();
if (new_primitive_type != cdata->_primitive_type) {
cdata->_primitive_type = new_primitive_type;
reset_point_rendering(cdata);
@ -237,11 +264,11 @@ add_primitive(const qpGeomPrimitive *primitive) {
// All primitives within a particular Geom must have the same
// fundamental primitive type (triangles, points, or lines).
nassertv(cdata->_primitive_type == qpGeomPrimitive::PT_none ||
nassertv(cdata->_primitive_type == PT_none ||
cdata->_primitive_type == primitive->get_primitive_type());
cdata->_primitives.push_back((qpGeomPrimitive *)primitive);
qpGeomPrimitive::PrimitiveType new_primitive_type = primitive->get_primitive_type();
PrimitiveType new_primitive_type = primitive->get_primitive_type();
if (new_primitive_type != cdata->_primitive_type) {
cdata->_primitive_type = new_primitive_type;
reset_point_rendering(cdata);
@ -271,7 +298,7 @@ remove_primitive(int i) {
}
cdata->_primitives.erase(cdata->_primitives.begin() + i);
if (cdata->_primitives.empty()) {
cdata->_primitive_type = qpGeomPrimitive::PT_none;
cdata->_primitive_type = PT_none;
reset_point_rendering(cdata);
}
cdata->_modified = qpGeom::get_next_modified();
@ -290,7 +317,7 @@ clear_primitives() {
clear_cache();
CDWriter cdata(_cycler);
cdata->_primitives.clear();
cdata->_primitive_type = qpGeomPrimitive::PT_none;
cdata->_primitive_type = PT_none;
reset_point_rendering(cdata);
}
@ -674,7 +701,7 @@ check_will_be_valid(const qpGeomVertexData *vertex_data) const {
////////////////////////////////////////////////////////////////////
void qpGeom::
reset_usage_hint(qpGeom::CDWriter &cdata) {
cdata->_usage_hint = qpGeomUsageHint::UH_static;
cdata->_usage_hint = UH_unspecified;
Primitives::const_iterator pi;
for (pi = cdata->_primitives.begin();
pi != cdata->_primitives.end();
@ -692,7 +719,7 @@ reset_usage_hint(qpGeom::CDWriter &cdata) {
void qpGeom::
reset_point_rendering(qpGeom::CDWriter &cdata) {
cdata->_point_rendering = 0;
if (cdata->_primitive_type == qpGeomPrimitive::PT_points) {
if (cdata->_primitive_type == PT_points) {
cdata->_point_rendering |= PR_point;
if (cdata->_data->has_column(InternalName::get_size())) {
@ -877,7 +904,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
_primitives.push_back(NULL);
}
_primitive_type = (qpGeomPrimitive::PrimitiveType)scan.get_uint8();
_primitive_type = (PrimitiveType)scan.get_uint8();
_point_rendering = scan.get_uint16();
_got_usage_hint = false;
_modified = qpGeom::get_next_modified();

View File

@ -29,7 +29,7 @@
#include "qpgeomVertexData.h"
#include "qpgeomPrimitive.h"
#include "qpgeomMunger.h"
#include "qpgeomUsageHint.h"
#include "qpgeomEnums.h"
#include "qpgeomCacheEntry.h"
#include "updateSeq.h"
#include "pointerTo.h"
@ -55,7 +55,8 @@ class EXPCL_PANDA qpGeom /* : public TypedWritableReferenceCount, public Bounded
// pointer where a Geom should go, while we have both implementations
// in the codebase. We pick up some additional cruft from Geom that
// we're not really using.
: public Geom
: public Geom,
public qpGeomEnums
{
PUBLISHED:
qpGeom();
@ -66,33 +67,10 @@ PUBLISHED:
// Temporary.
virtual Geom *make_copy() const;
enum PointRendering {
// If there are any points at all.
PR_point = 0x0001,
INLINE PrimitiveType get_primitive_type() const;
INLINE UsageHint get_usage_hint() const;
void set_usage_hint(UsageHint usage_hint);
// If the points are all the same size, other than 1 pixel.
PR_uniform_size = 0x0002,
// If the points have a per-vertex size designation.
PR_per_point_size = 0x0004,
// If the points' size is specified in camera units rather than
// screen pixels.
PR_perspective = 0x0008,
// If the points have a non-square aspect ratio.
PR_aspect_ratio = 0x0010,
// If the points are rotated off the orthonormal axis.
PR_rotate = 0x0020,
// If the points require texture coordinates interpolated across
// their face, to render textures as sprites.
PR_sprite = 0x0040,
};
INLINE qpGeomPrimitive::PrimitiveType get_primitive_type() const;
INLINE qpGeomUsageHint::UsageHint get_usage_hint() const;
INLINE int get_point_rendering() const;
INLINE CPT(qpGeomVertexData) get_vertex_data() const;
@ -181,9 +159,9 @@ private:
PT(qpGeomVertexData) _data;
Primitives _primitives;
qpGeomPrimitive::PrimitiveType _primitive_type;
PrimitiveType _primitive_type;
int _point_rendering;
qpGeomUsageHint::UsageHint _usage_hint;
UsageHint _usage_hint;
bool _got_usage_hint;
UpdateSeq _modified;
Cache _cache;

View File

@ -0,0 +1,73 @@
// Filename: qpgeomEnums.cxx
// Created by: drose (14Apr05)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#include "qpgeomEnums.h"
ostream &
operator << (ostream &out, qpGeomEnums::NumericType numeric_type) {
switch (numeric_type) {
case qpGeomEnums::NT_uint8:
return out << "uint8";
case qpGeomEnums::NT_uint16:
return out << "uint16";
case qpGeomEnums::NT_packed_dcba:
return out << "packed_dcba";
case qpGeomEnums::NT_packed_dabc:
return out << "packed_dabc";
case qpGeomEnums::NT_float32:
return out << "float32";
}
return out << "**invalid numeric type (" << (int)numeric_type << ")**";
}
ostream &
operator << (ostream &out, qpGeomEnums::Contents contents) {
switch (contents) {
case qpGeomEnums::C_other:
return out << "other";
case qpGeomEnums::C_point:
return out << "point";
case qpGeomEnums::C_clip_point:
return out << "clip_point";
case qpGeomEnums::C_vector:
return out << "vector";
case qpGeomEnums::C_texcoord:
return out << "texcoord";
case qpGeomEnums::C_color:
return out << "color";
case qpGeomEnums::C_index:
return out << "index";
case qpGeomEnums::C_morph_delta:
return out << "morph_delta";
}
return out << "**invalid contents (" << (int)contents << ")**";
}

View File

@ -0,0 +1,185 @@
// Filename: qpgeomEnums.h
// Created by: drose (14Apr05)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#ifndef qpGEOMENUMS_H
#define qpGEOMENUMS_H
#include "pandabase.h"
////////////////////////////////////////////////////////////////////
// Class : qpGeomEnums
// Description : This class exists just to provide scoping for the
// various enumerated types used by Geom,
// GeomVertexData, GeomVertexArrayData, GeomPrimitive,
// and other related classes.
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomEnums {
PUBLISHED:
// The usage hint describes to the rendering backend how often the
// data in question will be modified and/or rendered. It allows the
// backend to make appropriate choices about what part of memory the
// data should be stored in.
// The hint is provided as a performance optimization only, and does
// not constraing actual usage; although it may be an important
// optimization.
// In general, the hint may only be specified at the time the data
// object is constructed. If you need to change it, you must create
// a new object (but in many cases you can just assign the same
// internal data pointer to the new object, to keep the same
// client-side memory).
enum UsageHint {
// The following are intentionally ordered from most dynamic to
// most static. In general, if usage_a < usage_b, then usage_a is
// more dynamic than usage_b.
// UH_client: don't attempt to upload the data; always keep it on
// the client.
UH_client,
// UH_stream: the data will be created once, used to render a few
// times, and then discarded. This should be used for short-lived
// temporary objects.
UH_stream,
// UH_dynamic: the data will be repeatedly modified and
// re-rendered. This is for data that will be modified at
// runtime, such as animated or soft-skinned vertices.
UH_dynamic,
// UH_static: the data will be created once, and used to render
// many times, without modification. This is the most common
// case, since typically vertex data is not directly animated
// (this is not related to scene graph animation, e.g. from
// adjusting transforms on a node).
UH_static,
// UH_unspecified: the usage is unspecified. This is intended as
// a "don't care" option for abstract objects, it should not be
// applied to any actual geometry to be rendered. You take your
// chances if a geom actually gets into the scene graph with this
// set.
UH_unspecified,
};
// This type specifies a number of bits that are used to
// representing the rendering capabilities and/or requirements for
// fancy points.
enum PointRendering {
// If there are any points at all.
PR_point = 0x0001,
// If the points are all the same size, other than 1 pixel.
PR_uniform_size = 0x0002,
// If the points have a per-vertex size designation.
PR_per_point_size = 0x0004,
// If the points' size is specified in camera units rather than
// screen pixels.
PR_perspective = 0x0008,
// If the points have a non-square aspect ratio.
PR_aspect_ratio = 0x0010,
// If the points are rotated off the orthonormal axis.
PR_rotate = 0x0020,
// If the points require texture coordinates interpolated across
// their face, to render textures as sprites.
PR_sprite = 0x0040,
};
// The shade model controls whether colors and/or lighting effects
// are smoothly interpolated across the face of a triangle, or
// uniform for the entire triangle.
enum ShadeModel {
// SM_smooth: vertices within a single face have different
// colors/normals that should be smoothed across the face. This
// primitive should be rendered with SmoothModelAttrib::M_smooth.
SM_smooth,
// SM_uniform: all vertices across all faces have the same colors
// and normals. It doesn't really matter which ShadeModelAttrib
// mode is used to render this primitive.
SM_uniform,
// SM_flat_(first,last)_vertex: each face within the primitive
// might have a different color/normal than the other faces, but
// across a particular face there is only one color/normal. Each
// face's color/normal is taken from the (first, last) vertex of
// the face. This primitive should be rendered with
// SmoothModelAttrib::M_flat.
SM_flat_first_vertex,
SM_flat_last_vertex,
};
// The primitive type represents the core primitive type of a
// particular GeomPrimitive. It's used for determining what kind of
// antialiasing should be enabled.
enum PrimitiveType {
PT_none,
PT_polygons,
PT_lines,
PT_points
};
// The numeric type determines what physical representation is used
// to encode a numeric value within the vertex data.
enum NumericType {
NT_uint8, // An integer 0..255
NT_uint16, // An integer 0..65535
NT_packed_dcba, // DirectX style, four byte values packed in a uint32
NT_packed_dabc, // DirectX packed color order (ARGB)
NT_float32, // A floating-point number
};
// The contents determine the semantic meaning of a numeric value
// within the vertex data. This is also used to determine what
// automatic transforms might be applied to the various columns.
enum Contents {
C_other, // Arbitrary meaning, leave it alone
C_point, // A point in 3-space or 4-space
C_clip_point, // A point pre-transformed into clip coordinates
C_vector, // A surface normal, tangent, or binormal
C_texcoord, // A texture coordinate
C_color, // 3- or 4-component color, ordered R, G, B, [A]
C_index, // An index value into some other table
C_morph_delta, // A delta from some base value, defining a blend shape
};
// The type of animation data that is represented by a particular
// GeomVertexFormat.
enum AnimationType {
AT_none, // No vertex animation.
AT_panda, // Vertex animation calculated on the CPU by Panda.
AT_hardware, // Hardware-accelerated animation on the graphics card.
};
};
ostream &operator << (ostream &out, qpGeomEnums::NumericType numeric_type);
ostream &operator << (ostream &out, qpGeomEnums::Contents contents);
#endif

View File

@ -29,7 +29,7 @@ TypeHandle qpGeomLines::_type_handle;
// Description:
////////////////////////////////////////////////////////////////////
qpGeomLines::
qpGeomLines(qpGeomUsageHint::UsageHint usage_hint) :
qpGeomLines(qpGeomLines::UsageHint usage_hint) :
qpGeomPrimitive(usage_hint)
{
}
@ -159,7 +159,7 @@ register_with_read_factory() {
////////////////////////////////////////////////////////////////////
TypedWritable *qpGeomLines::
make_from_bam(const FactoryParams &params) {
qpGeomLines *object = new qpGeomLines(qpGeomUsageHint::UH_client);
qpGeomLines *object = new qpGeomLines(UH_unspecified);
DatagramIterator scan;
BamReader *manager;

View File

@ -30,7 +30,7 @@
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomLines : public qpGeomPrimitive {
PUBLISHED:
qpGeomLines(qpGeomUsageHint::UsageHint usage_hint);
qpGeomLines(UsageHint usage_hint);
qpGeomLines(const qpGeomLines &copy);
virtual ~qpGeomLines();

View File

@ -30,7 +30,7 @@ TypeHandle qpGeomLinestrips::_type_handle;
// Description:
////////////////////////////////////////////////////////////////////
qpGeomLinestrips::
qpGeomLinestrips(qpGeomUsageHint::UsageHint usage_hint) :
qpGeomLinestrips(qpGeomLinestrips::UsageHint usage_hint) :
qpGeomPrimitive(usage_hint)
{
}
@ -193,7 +193,7 @@ register_with_read_factory() {
////////////////////////////////////////////////////////////////////
TypedWritable *qpGeomLinestrips::
make_from_bam(const FactoryParams &params) {
qpGeomLinestrips *object = new qpGeomLinestrips(qpGeomUsageHint::UH_client);
qpGeomLinestrips *object = new qpGeomLinestrips(UH_unspecified);
DatagramIterator scan;
BamReader *manager;

View File

@ -30,7 +30,7 @@
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomLinestrips : public qpGeomPrimitive {
PUBLISHED:
qpGeomLinestrips(qpGeomUsageHint::UsageHint usage_hint);
qpGeomLinestrips(UsageHint usage_hint);
qpGeomLinestrips(const qpGeomLinestrips &copy);
virtual ~qpGeomLinestrips();

View File

@ -58,7 +58,7 @@ class qpGeom;
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomMunger : public TypedReferenceCount {
class EXPCL_PANDA qpGeomMunger : public TypedReferenceCount, public qpGeomEnums {
public:
qpGeomMunger(const GraphicsStateGuardianBase *gsg, const RenderState *state);
qpGeomMunger(const qpGeomMunger &copy);

View File

@ -29,7 +29,7 @@ TypeHandle qpGeomPoints::_type_handle;
// Description:
////////////////////////////////////////////////////////////////////
qpGeomPoints::
qpGeomPoints(qpGeomUsageHint::UsageHint usage_hint) :
qpGeomPoints(qpGeomPoints::UsageHint usage_hint) :
qpGeomPrimitive(usage_hint)
{
}
@ -137,7 +137,7 @@ register_with_read_factory() {
////////////////////////////////////////////////////////////////////
TypedWritable *qpGeomPoints::
make_from_bam(const FactoryParams &params) {
qpGeomPoints *object = new qpGeomPoints(qpGeomUsageHint::UH_client);
qpGeomPoints *object = new qpGeomPoints(UH_unspecified);
DatagramIterator scan;
BamReader *manager;

View File

@ -30,7 +30,7 @@
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomPoints : public qpGeomPrimitive {
PUBLISHED:
qpGeomPoints(qpGeomUsageHint::UsageHint usage_hint);
qpGeomPoints(UsageHint usage_hint);
qpGeomPoints(const qpGeomPoints &copy);
virtual ~qpGeomPoints();

View File

@ -21,7 +21,7 @@
// Function: qpGeomPrimitive::get_usage_hint
// Access: Published
// Description: Returns the usage hint for this primitive. See
// GeomUsageHint. This has nothing to do with the usage
// geomEnums.h. This has nothing to do with the usage
// hint associated with the primitive's vertices; this
// only specifies how often the vertex indices that
// define the primitive will be modified.
@ -33,9 +33,23 @@
// the primitive will always reference the same set of
// vertices from the pool.
////////////////////////////////////////////////////////////////////
INLINE qpGeomUsageHint::UsageHint qpGeomPrimitive::
INLINE qpGeomPrimitive::UsageHint qpGeomPrimitive::
get_usage_hint() const {
return _usage_hint;
CDReader cdata(_cycler);
return cdata->_usage_hint;
}
////////////////////////////////////////////////////////////////////
// Function: qpGeomPrimitive::set_usage_hint
// Access: Published
// Description: Changes the UsageHint hint for this primitive. See
// get_usage_hint().
////////////////////////////////////////////////////////////////////
INLINE void qpGeomPrimitive::
set_usage_hint(qpGeomPrimitive::UsageHint usage_hint) {
clear_cache();
CDWriter cdata(_cycler);
cdata->_usage_hint = usage_hint;
}
////////////////////////////////////////////////////////////////////
@ -359,6 +373,7 @@ get_maxs() const {
////////////////////////////////////////////////////////////////////
INLINE qpGeomPrimitive::CData::
CData() :
_usage_hint(UH_unspecified),
_shade_model(SM_smooth),
_got_minmax(true),
_min_vertex(0),
@ -373,6 +388,7 @@ CData() :
////////////////////////////////////////////////////////////////////
INLINE qpGeomPrimitive::CData::
CData(const qpGeomPrimitive::CData &copy) :
_usage_hint(copy._usage_hint),
_shade_model(copy._shade_model),
_vertices(copy._vertices),
_rotated_vertices(copy._rotated_vertices),

View File

@ -38,9 +38,8 @@ PStatCollector qpGeomPrimitive::_rotate_pcollector("Draw:Rotate");
// Description:
////////////////////////////////////////////////////////////////////
qpGeomPrimitive::
qpGeomPrimitive(qpGeomUsageHint::UsageHint usage_hint) :
_usage_hint(usage_hint)
{
qpGeomPrimitive(qpGeomPrimitive::UsageHint usage_hint) {
set_usage_hint(usage_hint);
}
////////////////////////////////////////////////////////////////////
@ -51,7 +50,6 @@ qpGeomPrimitive(qpGeomUsageHint::UsageHint usage_hint) :
qpGeomPrimitive::
qpGeomPrimitive(const qpGeomPrimitive &copy) :
TypedWritableReferenceCount(copy),
_usage_hint(copy._usage_hint),
_cycler(copy._cycler)
{
}
@ -1026,8 +1024,6 @@ void qpGeomPrimitive::
write_datagram(BamWriter *manager, Datagram &dg) {
TypedWritable::write_datagram(manager, dg);
dg.add_uint8(_usage_hint);
manager->write_cdata(dg, _cycler);
}
@ -1042,8 +1038,6 @@ void qpGeomPrimitive::
fillin(DatagramIterator &scan, BamReader *manager) {
TypedWritable::fillin(scan, manager);
_usage_hint = (qpGeomUsageHint::UsageHint)scan.get_uint8();
manager->read_cdata(scan, _cycler);
}
@ -1105,6 +1099,7 @@ make_copy() const {
////////////////////////////////////////////////////////////////////
void qpGeomPrimitive::CData::
write_datagram(BamWriter *manager, Datagram &dg) const {
dg.add_uint8(_usage_hint);
dg.add_uint8(_shade_model);
WRITE_PTA(manager, dg, IPD_ushort::write_datagram, _vertices);
@ -1120,6 +1115,7 @@ write_datagram(BamWriter *manager, Datagram &dg) const {
////////////////////////////////////////////////////////////////////
void qpGeomPrimitive::CData::
fillin(DatagramIterator &scan, BamReader *manager) {
_usage_hint = (UsageHint)scan.get_uint8();
_shade_model = (ShadeModel)scan.get_uint8();
READ_PTA(manager, scan, IPD_ushort::read_datagram, _vertices);

View File

@ -20,7 +20,7 @@
#define qpGEOMPRIMITIVE_H
#include "pandabase.h"
#include "qpgeomUsageHint.h"
#include "qpgeomEnums.h"
#include "qpgeomCacheEntry.h"
#include "typedWritableReferenceCount.h"
#include "luse.h"
@ -63,44 +63,18 @@ class FactoryParams;
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomPrimitive : public TypedWritableReferenceCount {
class EXPCL_PANDA qpGeomPrimitive : public TypedWritableReferenceCount, public qpGeomEnums {
PUBLISHED:
qpGeomPrimitive(qpGeomUsageHint::UsageHint usage_hint);
qpGeomPrimitive(UsageHint usage_hint);
qpGeomPrimitive(const qpGeomPrimitive &copy);
virtual ~qpGeomPrimitive();
virtual PT(qpGeomPrimitive) make_copy() const=0;
enum ShadeModel {
// SM_smooth: vertices within a single face have different
// colors/normals that should be smoothed across the face. This
// primitive should be rendered with SmoothModelAttrib::M_smooth.
SM_smooth,
// SM_uniform: all vertices across all faces have the same colors
// and normals. It doesn't really matter which ShadeModelAttrib
// mode is used to render this primitive.
SM_uniform,
// SM_flat_(first,last)_vertex: each face within the primitive
// might have a different color/normal than the other faces, but
// across a particular face there is only one color/normal. Each
// face's color/normal is taken from the (first, last) vertex of
// the face. This primitive should be rendered with
// SmoothModelAttrib::M_flat.
SM_flat_first_vertex,
SM_flat_last_vertex,
};
enum PrimitiveType {
PT_none,
PT_polygons,
PT_lines,
PT_points
};
virtual PrimitiveType get_primitive_type() const=0;
INLINE qpGeomUsageHint::UsageHint get_usage_hint() const;
INLINE UsageHint get_usage_hint() const;
INLINE void set_usage_hint(UsageHint usage_hint);
INLINE ShadeModel get_shade_model() const;
INLINE void set_shade_model(ShadeModel shade_model);
@ -202,8 +176,6 @@ protected:
static PStatCollector _rotate_pcollector;
private:
qpGeomUsageHint::UsageHint _usage_hint;
// A GeomPrimitive keeps a list (actually, a map) of all the
// PreparedGraphicsObjects tables that it has been prepared into.
// Each PGO conversely keeps a list (a set) of all the Geoms that
@ -231,6 +203,7 @@ private:
virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
virtual void fillin(DatagramIterator &scan, BamReader *manager);
UsageHint _usage_hint;
ShadeModel _shade_model;
PTA_ushort _vertices;
CPTA_ushort _rotated_vertices;

View File

@ -29,7 +29,7 @@ TypeHandle qpGeomTriangles::_type_handle;
// Description:
////////////////////////////////////////////////////////////////////
qpGeomTriangles::
qpGeomTriangles(qpGeomUsageHint::UsageHint usage_hint) :
qpGeomTriangles(qpGeomTriangles::UsageHint usage_hint) :
qpGeomPrimitive(usage_hint)
{
}
@ -174,7 +174,7 @@ register_with_read_factory() {
////////////////////////////////////////////////////////////////////
TypedWritable *qpGeomTriangles::
make_from_bam(const FactoryParams &params) {
qpGeomTriangles *object = new qpGeomTriangles(qpGeomUsageHint::UH_client);
qpGeomTriangles *object = new qpGeomTriangles(UH_unspecified);
DatagramIterator scan;
BamReader *manager;

View File

@ -30,7 +30,7 @@
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomTriangles : public qpGeomPrimitive {
PUBLISHED:
qpGeomTriangles(qpGeomUsageHint::UsageHint usage_hint);
qpGeomTriangles(UsageHint usage_hint);
qpGeomTriangles(const qpGeomTriangles &copy);
virtual ~qpGeomTriangles();

View File

@ -29,7 +29,7 @@ TypeHandle qpGeomTrifans::_type_handle;
// Description:
////////////////////////////////////////////////////////////////////
qpGeomTrifans::
qpGeomTrifans(qpGeomUsageHint::UsageHint usage_hint) :
qpGeomTrifans(qpGeomTrifans::UsageHint usage_hint) :
qpGeomPrimitive(usage_hint)
{
}
@ -172,7 +172,7 @@ register_with_read_factory() {
////////////////////////////////////////////////////////////////////
TypedWritable *qpGeomTrifans::
make_from_bam(const FactoryParams &params) {
qpGeomTrifans *object = new qpGeomTrifans(qpGeomUsageHint::UH_client);
qpGeomTrifans *object = new qpGeomTrifans(UH_unspecified);
DatagramIterator scan;
BamReader *manager;

View File

@ -30,7 +30,7 @@
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomTrifans : public qpGeomPrimitive {
PUBLISHED:
qpGeomTrifans(qpGeomUsageHint::UsageHint usage_hint);
qpGeomTrifans(UsageHint usage_hint);
qpGeomTrifans(const qpGeomTrifans &copy);
virtual ~qpGeomTrifans();

View File

@ -30,7 +30,7 @@ TypeHandle qpGeomTristrips::_type_handle;
// Description:
////////////////////////////////////////////////////////////////////
qpGeomTristrips::
qpGeomTristrips(qpGeomUsageHint::UsageHint usage_hint) :
qpGeomTristrips(qpGeomTristrips::UsageHint usage_hint) :
qpGeomPrimitive(usage_hint)
{
}
@ -296,7 +296,7 @@ register_with_read_factory() {
////////////////////////////////////////////////////////////////////
TypedWritable *qpGeomTristrips::
make_from_bam(const FactoryParams &params) {
qpGeomTristrips *object = new qpGeomTristrips(qpGeomUsageHint::UH_client);
qpGeomTristrips *object = new qpGeomTristrips(UH_unspecified);
DatagramIterator scan;
BamReader *manager;

View File

@ -30,7 +30,7 @@
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomTristrips : public qpGeomPrimitive {
PUBLISHED:
qpGeomTristrips(qpGeomUsageHint::UsageHint usage_hint);
qpGeomTristrips(UsageHint usage_hint);
qpGeomTristrips(const qpGeomTristrips &copy);
virtual ~qpGeomTristrips();

View File

@ -1,81 +0,0 @@
// Filename: qpgeomUsageHint.h
// Created by: drose (18Mar05)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#ifndef qpGEOMUSAGEHINT_H
#define qpGEOMUSAGEHINT_H
#include "pandabase.h"
////////////////////////////////////////////////////////////////////
// Class : qpGeomUsageHint
// Description : This class exists just to provide scoping for the
// UsageHint enumerated type, which is used by
// GeomVertexData, GeomVertexArrayData, and
// GeomPrimitive.
//
// The usage hint describes to the rendering backend how
// often the data in question will be modified and/or
// rendered. It allows the backend to make appropriate
// choices about what part of memory the data should be
// stored in.
//
// The hint is provided as a performance optimization
// only, and does not constraing actual usage; although
// it may be an important optimization.
//
// In general, the hint may only be specified at the
// time the data object is constructed. If you need to
// change it, you must create a new object (but in many
// cases you can just assign the same internal data
// pointer to the new object, to keep the same
// client-side memory).
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomUsageHint {
PUBLISHED:
enum UsageHint {
// The following are intentionally ordered from most dynamic to
// most static. In general, if usage_a < usage_b, then usage_a is
// more dynamic than usage_b.
// UH_client: don't attempt to upload the data; always keep it on
// the client.
UH_client,
// UH_stream: the data will be created once, used to render a few
// times, and then discarded. This should be used for short-lived
// temporary objects.
UH_stream,
// UH_dynamic: the data will be repeatedly modified and
// re-rendered. This is for data that will be modified at
// runtime, such as animated or soft-skinned vertices.
UH_dynamic,
// UH_static: the data will be created once, and used to render
// many times, without modification. This is the most common
// case, since typically vertex data is not directly animated
// (this is not related to scene graph animation, e.g. from
// adjusting transforms on a node).
UH_static,
};
};
#endif

View File

@ -20,6 +20,7 @@
#define qpGEOMVERTEXANIMATIONSPEC_H
#include "pandabase.h"
#include "qpgeomEnums.h"
class BamWriter;
class BamReader;
@ -44,18 +45,12 @@ class DatagramIterator;
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomVertexAnimationSpec {
class EXPCL_PANDA qpGeomVertexAnimationSpec : public qpGeomEnums {
PUBLISHED:
INLINE qpGeomVertexAnimationSpec();
INLINE qpGeomVertexAnimationSpec(const qpGeomVertexAnimationSpec &other);
INLINE void operator = (const qpGeomVertexAnimationSpec &other);
enum AnimationType {
AT_none, // No vertex animation.
AT_panda, // Vertex animation calculated on the CPU by Panda.
AT_hardware, // Hardware-accelerated animation on the graphics card.
};
INLINE AnimationType get_animation_type() const;
INLINE int get_num_transforms() const;

View File

@ -32,11 +32,12 @@ get_array_format() const {
// Access: Published
// Description: Returns the usage hint that describes to the
// rendering backend how often the vertex data will be
// modified and/or rendered. See GeomUsageHint.
// modified and/or rendered. See geomEnums.h.
////////////////////////////////////////////////////////////////////
INLINE qpGeomUsageHint::UsageHint qpGeomVertexArrayData::
INLINE qpGeomVertexArrayData::UsageHint qpGeomVertexArrayData::
get_usage_hint() const {
return _usage_hint;
CDReader cdata(_cycler);
return cdata->_usage_hint;
}
////////////////////////////////////////////////////////////////////
@ -118,7 +119,9 @@ get_data() const {
// Description:
////////////////////////////////////////////////////////////////////
INLINE qpGeomVertexArrayData::CData::
CData() {
CData() :
_usage_hint(UH_unspecified)
{
}
////////////////////////////////////////////////////////////////////
@ -128,6 +131,7 @@ CData() {
////////////////////////////////////////////////////////////////////
INLINE qpGeomVertexArrayData::CData::
CData(const qpGeomVertexArrayData::CData &copy) :
_usage_hint(copy._usage_hint),
_data(copy._data),
_modified(copy._modified)
{

View File

@ -42,10 +42,11 @@ qpGeomVertexArrayData() {
////////////////////////////////////////////////////////////////////
qpGeomVertexArrayData::
qpGeomVertexArrayData(const qpGeomVertexArrayFormat *array_format,
qpGeomUsageHint::UsageHint usage_hint) :
_array_format(array_format),
_usage_hint(usage_hint)
qpGeomVertexArrayData::UsageHint usage_hint) :
_array_format(array_format)
{
set_usage_hint(usage_hint);
nassertv(_array_format->is_registered());
}
////////////////////////////////////////////////////////////////////
@ -55,21 +56,28 @@ qpGeomVertexArrayData(const qpGeomVertexArrayFormat *array_format,
////////////////////////////////////////////////////////////////////
qpGeomVertexArrayData::
qpGeomVertexArrayData(const qpGeomVertexArrayData &copy) :
TypedWritableReferenceCount(copy),
_array_format(copy._array_format),
_usage_hint(copy._usage_hint),
_cycler(copy._cycler)
{
nassertv(_array_format->is_registered());
}
////////////////////////////////////////////////////////////////////
// Function: qpGeomVertexArrayData::Copy Assignment Operator
// Access: Private
// Description: Directly copying ArrayData objects by assignment is
// disallowed.
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
void qpGeomVertexArrayData::
operator = (const qpGeomVertexArrayData &) {
nassertv(false);
operator = (const qpGeomVertexArrayData &copy) {
TypedWritableReferenceCount::operator = (copy);
_array_format = copy._array_format;
_cycler = copy._cycler;
CDWriter cdata(_cycler);
cdata->_modified = qpGeom::get_next_modified();
nassertv(_array_format->is_registered());
}
////////////////////////////////////////////////////////////////////
@ -138,6 +146,19 @@ set_num_vertices(int n) {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: qpGeomVertexArrayData::set_usage_hint
// Access: Published
// Description: Changes the UsageHint hint for this array. See
// get_usage_hint().
////////////////////////////////////////////////////////////////////
void qpGeomVertexArrayData::
set_usage_hint(qpGeomVertexArrayData::UsageHint usage_hint) {
CDWriter cdata(_cycler);
cdata->_usage_hint = usage_hint;
cdata->_modified = qpGeom::get_next_modified();
}
////////////////////////////////////////////////////////////////////
// Function: qpGeomVertexArrayData::modify_data
// Access: Public
@ -320,7 +341,6 @@ write_datagram(BamWriter *manager, Datagram &dg) {
TypedWritableReferenceCount::write_datagram(manager, dg);
manager->write_pointer(dg, _array_format);
dg.add_uint8(_usage_hint);
manager->write_cdata(dg, _cycler);
}
@ -406,7 +426,6 @@ fillin(DatagramIterator &scan, BamReader *manager) {
TypedWritableReferenceCount::fillin(scan, manager);
manager->read_pointer(scan);
_usage_hint = (qpGeomUsageHint::UsageHint)scan.get_uint8();
manager->read_cdata(scan, _cycler);
}
@ -429,6 +448,7 @@ make_copy() const {
////////////////////////////////////////////////////////////////////
void qpGeomVertexArrayData::CData::
write_datagram(BamWriter *manager, Datagram &dg) const {
dg.add_uint8(_usage_hint);
WRITE_PTA(manager, dg, write_raw_data, _data);
}
@ -441,6 +461,7 @@ write_datagram(BamWriter *manager, Datagram &dg) const {
////////////////////////////////////////////////////////////////////
void qpGeomVertexArrayData::CData::
fillin(DatagramIterator &scan, BamReader *manager) {
_usage_hint = (UsageHint)scan.get_uint8();
READ_PTA(manager, scan, read_raw_data, _data);
_modified = qpGeom::get_next_modified();

View File

@ -22,7 +22,7 @@
#include "pandabase.h"
#include "typedWritableReferenceCount.h"
#include "qpgeomVertexArrayFormat.h"
#include "qpgeomUsageHint.h"
#include "qpgeomEnums.h"
#include "pta_uchar.h"
#include "updateSeq.h"
#include "cycleData.h"
@ -56,21 +56,21 @@ class GraphicsStateGuardianBase;
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomVertexArrayData : public TypedWritableReferenceCount {
class EXPCL_PANDA qpGeomVertexArrayData : public TypedWritableReferenceCount, public qpGeomEnums {
private:
qpGeomVertexArrayData();
PUBLISHED:
qpGeomVertexArrayData(const qpGeomVertexArrayFormat *array_format,
qpGeomUsageHint::UsageHint usage_hint);
UsageHint usage_hint);
qpGeomVertexArrayData(const qpGeomVertexArrayData &copy);
private:
void operator = (const qpGeomVertexArrayData &copy);
PUBLISHED:
virtual ~qpGeomVertexArrayData();
INLINE const qpGeomVertexArrayFormat *get_array_format() const;
INLINE qpGeomUsageHint::UsageHint get_usage_hint() const;
INLINE UsageHint get_usage_hint() const;
void set_usage_hint(UsageHint usage_hint);
INLINE bool has_column(const InternalName *name) const;
@ -98,7 +98,6 @@ private:
void clear_prepared(PreparedGraphicsObjects *prepared_objects);
CPT(qpGeomVertexArrayFormat) _array_format;
qpGeomUsageHint::UsageHint _usage_hint;
// A GeomVertexArrayData keeps a list (actually, a map) of all the
// PreparedGraphicsObjects tables that it has been prepared into.
@ -117,6 +116,7 @@ private:
virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
virtual void fillin(DatagramIterator &scan, BamReader *manager);
UsageHint _usage_hint;
PTA_uchar _data;
UpdateSeq _modified;
};

View File

@ -50,8 +50,8 @@ qpGeomVertexArrayFormat() :
////////////////////////////////////////////////////////////////////
qpGeomVertexArrayFormat::
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
qpGeomVertexColumn::NumericType numeric_type0,
qpGeomVertexColumn::Contents contents0) :
qpGeomVertexArrayFormat::NumericType numeric_type0,
qpGeomVertexArrayFormat::Contents contents0) :
_is_registered(false),
_stride(0),
_total_bytes(0),
@ -68,11 +68,11 @@ qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
////////////////////////////////////////////////////////////////////
qpGeomVertexArrayFormat::
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
qpGeomVertexColumn::NumericType numeric_type0,
qpGeomVertexColumn::Contents contents0,
qpGeomVertexArrayFormat::NumericType numeric_type0,
qpGeomVertexArrayFormat::Contents contents0,
const InternalName *name1, int num_components1,
qpGeomVertexColumn::NumericType numeric_type1,
qpGeomVertexColumn::Contents contents1) :
qpGeomVertexArrayFormat::NumericType numeric_type1,
qpGeomVertexArrayFormat::Contents contents1) :
_is_registered(false),
_stride(0),
_total_bytes(0),
@ -90,14 +90,14 @@ qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
////////////////////////////////////////////////////////////////////
qpGeomVertexArrayFormat::
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
qpGeomVertexColumn::NumericType numeric_type0,
qpGeomVertexColumn::Contents contents0,
qpGeomVertexArrayFormat::NumericType numeric_type0,
qpGeomVertexArrayFormat::Contents contents0,
const InternalName *name1, int num_components1,
qpGeomVertexColumn::NumericType numeric_type1,
qpGeomVertexColumn::Contents contents1,
qpGeomVertexArrayFormat::NumericType numeric_type1,
qpGeomVertexArrayFormat::Contents contents1,
const InternalName *name2, int num_components2,
qpGeomVertexColumn::NumericType numeric_type2,
qpGeomVertexColumn::Contents contents2) :
qpGeomVertexArrayFormat::NumericType numeric_type2,
qpGeomVertexArrayFormat::Contents contents2) :
_is_registered(false),
_stride(0),
_total_bytes(0),
@ -116,17 +116,17 @@ qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
////////////////////////////////////////////////////////////////////
qpGeomVertexArrayFormat::
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
qpGeomVertexColumn::NumericType numeric_type0,
qpGeomVertexColumn::Contents contents0,
qpGeomVertexArrayFormat::NumericType numeric_type0,
qpGeomVertexArrayFormat::Contents contents0,
const InternalName *name1, int num_components1,
qpGeomVertexColumn::NumericType numeric_type1,
qpGeomVertexColumn::Contents contents1,
qpGeomVertexArrayFormat::NumericType numeric_type1,
qpGeomVertexArrayFormat::Contents contents1,
const InternalName *name2, int num_components2,
qpGeomVertexColumn::NumericType numeric_type2,
qpGeomVertexColumn::Contents contents2,
qpGeomVertexArrayFormat::NumericType numeric_type2,
qpGeomVertexArrayFormat::Contents contents2,
const InternalName *name3, int num_components3,
qpGeomVertexColumn::NumericType numeric_type3,
qpGeomVertexColumn::Contents contents3) :
qpGeomVertexArrayFormat::NumericType numeric_type3,
qpGeomVertexArrayFormat::Contents contents3) :
_is_registered(false),
_stride(0),
_total_bytes(0),
@ -209,8 +209,8 @@ qpGeomVertexArrayFormat::
////////////////////////////////////////////////////////////////////
int qpGeomVertexArrayFormat::
add_column(const InternalName *name, int num_components,
qpGeomVertexColumn::NumericType numeric_type,
qpGeomVertexColumn::Contents contents, int start) {
qpGeomVertexArrayFormat::NumericType numeric_type,
qpGeomVertexArrayFormat::Contents contents, int start) {
if (start < 0) {
start = _total_bytes;

View File

@ -22,6 +22,7 @@
#include "pandabase.h"
#include "typedWritableReferenceCount.h"
#include "qpgeomVertexColumn.h"
#include "qpgeomEnums.h"
#include "indirectCompareTo.h"
#include "pvector.h"
#include "pmap.h"
@ -53,40 +54,30 @@ class BamReader;
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomVertexArrayFormat : public TypedWritableReferenceCount {
class EXPCL_PANDA qpGeomVertexArrayFormat : public TypedWritableReferenceCount, public qpGeomEnums {
PUBLISHED:
qpGeomVertexArrayFormat();
qpGeomVertexArrayFormat(const qpGeomVertexArrayFormat &copy);
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
qpGeomVertexColumn::NumericType numeric_type0,
qpGeomVertexColumn::Contents contents0);
NumericType numeric_type0, Contents contents0);
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
qpGeomVertexColumn::NumericType numeric_type0,
qpGeomVertexColumn::Contents contents0,
NumericType numeric_type0, Contents contents0,
const InternalName *name1, int num_components1,
qpGeomVertexColumn::NumericType numeric_type1,
qpGeomVertexColumn::Contents contents1);
NumericType numeric_type1, Contents contents1);
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
qpGeomVertexColumn::NumericType numeric_type0,
qpGeomVertexColumn::Contents contents0,
NumericType numeric_type0, Contents contents0,
const InternalName *name1, int num_components1,
qpGeomVertexColumn::NumericType numeric_type1,
qpGeomVertexColumn::Contents contents1,
NumericType numeric_type1, Contents contents1,
const InternalName *name2, int num_components2,
qpGeomVertexColumn::NumericType numeric_type2,
qpGeomVertexColumn::Contents contents2);
NumericType numeric_type2, Contents contents2);
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
qpGeomVertexColumn::NumericType numeric_type0,
qpGeomVertexColumn::Contents contents0,
NumericType numeric_type0, Contents contents0,
const InternalName *name1, int num_components1,
qpGeomVertexColumn::NumericType numeric_type1,
qpGeomVertexColumn::Contents contents1,
NumericType numeric_type1, Contents contents1,
const InternalName *name2, int num_components2,
qpGeomVertexColumn::NumericType numeric_type2,
qpGeomVertexColumn::Contents contents2,
NumericType numeric_type2, Contents contents2,
const InternalName *name3, int num_components3,
qpGeomVertexColumn::NumericType numeric_type3,
qpGeomVertexColumn::Contents contents3);
NumericType numeric_type3, Contents contents3);
void operator = (const qpGeomVertexArrayFormat &copy);
~qpGeomVertexArrayFormat();
@ -100,8 +91,7 @@ PUBLISHED:
INLINE int get_pad_to() const;
int add_column(const InternalName *name, int num_components,
qpGeomVertexColumn::NumericType numeric_type,
qpGeomVertexColumn::Contents contents,
NumericType numeric_type, Contents contents,
int start = -1);
int add_column(const qpGeomVertexColumn &column);
void remove_column(const InternalName *name);

View File

@ -114,56 +114,3 @@ fillin(DatagramIterator &scan, BamReader *manager) {
setup();
}
ostream &
operator << (ostream &out, qpGeomVertexColumn::NumericType numeric_type) {
switch (numeric_type) {
case qpGeomVertexColumn::NT_uint8:
return out << "uint8";
case qpGeomVertexColumn::NT_uint16:
return out << "uint16";
case qpGeomVertexColumn::NT_packed_dcba:
return out << "packed_dcba";
case qpGeomVertexColumn::NT_packed_dabc:
return out << "packed_dabc";
case qpGeomVertexColumn::NT_float32:
return out << "float32";
}
return out << "**invalid numeric type (" << (int)numeric_type << ")**";
}
ostream &
operator << (ostream &out, qpGeomVertexColumn::Contents contents) {
switch (contents) {
case qpGeomVertexColumn::C_other:
return out << "other";
case qpGeomVertexColumn::C_point:
return out << "point";
case qpGeomVertexColumn::C_clip_point:
return out << "clip_point";
case qpGeomVertexColumn::C_vector:
return out << "vector";
case qpGeomVertexColumn::C_texcoord:
return out << "texcoord";
case qpGeomVertexColumn::C_color:
return out << "color";
case qpGeomVertexColumn::C_index:
return out << "index";
case qpGeomVertexColumn::C_morph_delta:
return out << "morph_delta";
}
return out << "**invalid contents (" << (int)contents << ")**";
}

View File

@ -20,6 +20,7 @@
#define qpGEOMVERTEXCOLUMN_H
#include "pandabase.h"
#include "qpgeomEnums.h"
#include "internalName.h"
#include "pointerTo.h"
@ -38,27 +39,8 @@ class DatagramIterator;
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomVertexColumn {
class EXPCL_PANDA qpGeomVertexColumn : public qpGeomEnums {
PUBLISHED:
enum NumericType {
NT_uint8, // An integer 0..255
NT_uint16, // An integer 0..65535
NT_packed_dcba, // DirectX style, four byte values packed in a uint32
NT_packed_dabc, // DirectX packed color order (ARGB)
NT_float32, // A floating-point number
};
enum Contents {
C_other, // Arbitrary meaning, leave it alone
C_point, // A point in 3-space or 4-space
C_clip_point, // A point pre-transformed into clip coordinates
C_vector, // A surface normal, tangent, or binormal
C_texcoord, // A texture coordinate
C_color, // 3- or 4-component color, ordered R, G, B, [A]
C_index, // An index value into some other table
C_morph_delta, // A delta from some base value, defining a blend shape
};
private:
INLINE qpGeomVertexColumn();
PUBLISHED:
@ -114,8 +96,6 @@ private:
};
INLINE ostream &operator << (ostream &out, const qpGeomVertexColumn &obj);
ostream &operator << (ostream &out, qpGeomVertexColumn::NumericType numeric_type);
ostream &operator << (ostream &out, qpGeomVertexColumn::Contents contents);
#include "qpgeomVertexColumn.I"

View File

@ -62,16 +62,17 @@ get_format() const {
// constructor, and which will be passed to each array
// data object created initially, and arrays created as
// the result of a convert_to() operation. See
// GeomUsageHint.
// geomEnums.h.
//
// However, each individual array may be replaced with a
// different array object with an independent usage hint
// specified, so there is no guarantee that the
// individual arrays all have the same usage_hint.
////////////////////////////////////////////////////////////////////
INLINE qpGeomUsageHint::UsageHint qpGeomVertexData::
INLINE qpGeomVertexData::UsageHint qpGeomVertexData::
get_usage_hint() const {
return _usage_hint;
CDReader cdata(_cycler);
return cdata->_usage_hint;
}
////////////////////////////////////////////////////////////////////
@ -308,7 +309,7 @@ INLINE bool qpGeomVertexData::
is_vertex_transformed() const {
const qpGeomVertexColumn *column = _format->get_vertex_column();
if (column != (qpGeomVertexColumn *)NULL) {
return column->get_contents() == qpGeomVertexColumn::C_clip_point;
return column->get_contents() == C_clip_point;
}
return false;
@ -419,7 +420,9 @@ add_transform(TransformPalette *palette, const VertexTransform *transform,
// Description:
////////////////////////////////////////////////////////////////////
INLINE qpGeomVertexData::CData::
CData() {
CData() :
_usage_hint(UH_unspecified)
{
}
////////////////////////////////////////////////////////////////////
@ -429,6 +432,7 @@ CData() {
////////////////////////////////////////////////////////////////////
INLINE qpGeomVertexData::CData::
CData(const qpGeomVertexData::CData &copy) :
_usage_hint(copy._usage_hint),
_arrays(copy._arrays),
_transform_palette(copy._transform_palette),
_transform_blend_palette(copy._transform_blend_palette),

View File

@ -55,15 +55,16 @@ qpGeomVertexData() :
qpGeomVertexData::
qpGeomVertexData(const string &name,
const qpGeomVertexFormat *format,
qpGeomUsageHint::UsageHint usage_hint) :
qpGeomVertexData::UsageHint usage_hint) :
_name(name),
_format(format),
_usage_hint(usage_hint),
_app_char_pcollector(PStatCollector(_app_animation_pcollector, name), "Vertices"),
_cull_char_pcollector(PStatCollector(_cull_animation_pcollector, name), "Vertices")
{
nassertv(_format->is_registered());
set_usage_hint(usage_hint);
// Create some empty arrays as required by the format.
CDWriter cdata(_cycler);
@ -85,7 +86,6 @@ qpGeomVertexData(const qpGeomVertexData &copy) :
TypedWritableReferenceCount(copy),
_name(copy._name),
_format(copy._format),
_usage_hint(copy._usage_hint),
_cycler(copy._cycler),
_app_char_pcollector(copy._app_char_pcollector),
_cull_char_pcollector(copy._cull_char_pcollector)
@ -102,13 +102,13 @@ operator = (const qpGeomVertexData &copy) {
TypedWritableReferenceCount::operator = (copy);
_name = copy._name;
_format = copy._format;
// The assignment operator does not copy the usage_hint, which is
// not supposed to change over the lifetime of a GeomVertexData.
_cycler = copy._cycler;
_app_char_pcollector = copy._app_char_pcollector;
_cull_char_pcollector = copy._cull_char_pcollector;
CDWriter cdata(_cycler);
cdata->_modified = qpGeom::get_next_modified();
cdata->_animated_vertices_modified = UpdateSeq();
}
////////////////////////////////////////////////////////////////////
@ -120,6 +120,31 @@ qpGeomVertexData::
~qpGeomVertexData() {
}
////////////////////////////////////////////////////////////////////
// Function: qpGeomVertexData::set_usage_hint
// Access: Published
// Description: Changes the UsageHint hint for this vertex data, and
// for all of the arrays that share this data. See
// get_usage_hint().
////////////////////////////////////////////////////////////////////
void qpGeomVertexData::
set_usage_hint(qpGeomVertexData::UsageHint usage_hint) {
CDWriter cdata(_cycler);
cdata->_usage_hint = usage_hint;
Arrays::iterator ai;
for (ai = cdata->_arrays.begin();
ai != cdata->_arrays.end();
++ai) {
if ((*ai)->get_ref_count() > 1) {
(*ai) = new qpGeomVertexArrayData(*(*ai));
}
(*ai)->set_usage_hint(usage_hint);
}
cdata->_modified = qpGeom::get_next_modified();
cdata->_animated_vertices_modified = UpdateSeq();
}
////////////////////////////////////////////////////////////////////
// Function: qpGeomVertexData::get_num_vertices
// Access: Published
@ -157,6 +182,9 @@ clear_vertices() {
for (ai = cdata->_arrays.begin();
ai != cdata->_arrays.end();
++ai) {
if ((*ai)->get_ref_count() > 1) {
(*ai) = new qpGeomVertexArrayData(*(*ai));
}
(*ai)->clear_vertices();
}
cdata->_modified = qpGeom::get_next_modified();
@ -195,13 +223,14 @@ modify_array(int i) {
// Access: Published
// Description: Replaces the indicated vertex data array with
// a completely new array. You should be careful that
// the new array has the same length as the old one,
// unless you know what you are doing.
// the new array has the same length and format as the
// old one, unless you know what you are doing.
////////////////////////////////////////////////////////////////////
void qpGeomVertexData::
set_array(int i, const qpGeomVertexArrayData *array) {
CDWriter cdata(_cycler);
nassertv(i >= 0 && i < (int)cdata->_arrays.size());
nassertv(array->get_array_format() == cdata->_arrays[i]->get_array_format());
cdata->_arrays[i] = (qpGeomVertexArrayData *)array;
cdata->_modified = qpGeom::get_next_modified();
cdata->_animated_vertices_modified = UpdateSeq();
@ -448,7 +477,7 @@ copy_from(const qpGeomVertexData &source, bool keep_data_objects) {
const qpGeomVertexAnimationSpec &source_animation = source_format->get_animation();
const qpGeomVertexAnimationSpec &dest_animation = dest_format->get_animation();
if (source_animation != dest_animation) {
if (dest_animation.get_animation_type() == qpGeomVertexAnimationSpec::AT_hardware) {
if (dest_animation.get_animation_type() == AT_hardware) {
// Convert Panda-style animation tables to hardware-style
// animation tables.
CPT(TransformBlendPalette) blend_palette = source.get_transform_blend_palette();
@ -581,8 +610,8 @@ scale_color(const LVecBase4f &color_scale) const {
////////////////////////////////////////////////////////////////////
CPT(qpGeomVertexData) qpGeomVertexData::
scale_color(const LVecBase4f &color_scale, int num_components,
qpGeomVertexColumn::NumericType numeric_type,
qpGeomVertexColumn::Contents contents) const {
qpGeomVertexData::NumericType numeric_type,
qpGeomVertexData::Contents contents) const {
int old_color_array = _format->get_array_with(InternalName::get_color());
if (old_color_array == -1) {
// Oops, no color anyway.
@ -655,8 +684,8 @@ set_color(const Colorf &color) const {
////////////////////////////////////////////////////////////////////
CPT(qpGeomVertexData) qpGeomVertexData::
set_color(const Colorf &color, int num_components,
qpGeomVertexColumn::NumericType numeric_type,
qpGeomVertexColumn::Contents contents) const {
qpGeomVertexData::NumericType numeric_type,
qpGeomVertexData::Contents contents) const {
if (gobj_cat.is_debug()) {
gobj_cat.debug()
<< "Setting color for " << get_num_vertices() << " vertices to "
@ -693,9 +722,9 @@ set_color(const Colorf &color, int num_components,
////////////////////////////////////////////////////////////////////
PT(qpGeomVertexData) qpGeomVertexData::
replace_column(const InternalName *name, int num_components,
qpGeomVertexColumn::NumericType numeric_type,
qpGeomVertexColumn::Contents contents,
qpGeomUsageHint::UsageHint usage_hint,
qpGeomVertexData::NumericType numeric_type,
qpGeomVertexData::Contents contents,
qpGeomVertexData::UsageHint usage_hint,
bool keep_animation) const {
PT(qpGeomVertexFormat) new_format = new qpGeomVertexFormat(*_format);
@ -732,7 +761,7 @@ replace_column(const InternalName *name, int num_components,
gobj_cat.debug()
<< "Replacing data type " << *name << "; converting "
<< get_num_vertices() << " vertices from "
<< *_format << " to " << *new_format << "\n";
<< *_format << " to " << *format << "\n";
}
PT(qpGeomVertexData) new_data =
@ -766,7 +795,7 @@ replace_column(const InternalName *name, int num_components,
// For the new type array, we set up a temporary array that has
// room for the right number of vertices.
PT(qpGeomVertexArrayData) new_array = new qpGeomVertexArrayData
(new_format->get_array(j), get_usage_hint());
(format->get_array(j), get_usage_hint());
new_array->set_num_vertices(get_num_vertices());
new_data->set_array(j, new_array);
}
@ -823,7 +852,7 @@ bool qpGeomVertexData::
get_array_info(const InternalName *name,
const qpGeomVertexArrayData *&array_data,
int &num_values,
qpGeomVertexColumn::NumericType &numeric_type,
qpGeomVertexData::NumericType &numeric_type,
int &start, int &stride) const {
int array_index;
const qpGeomVertexColumn *column;
@ -848,7 +877,7 @@ get_array_info(const InternalName *name,
bool qpGeomVertexData::
get_vertex_info(const qpGeomVertexArrayData *&array_data,
int &num_values,
qpGeomVertexColumn::NumericType &numeric_type,
qpGeomVertexData::NumericType &numeric_type,
int &start, int &stride) const {
int array_index = _format->get_vertex_array_index();
if (array_index >= 0) {
@ -874,7 +903,7 @@ get_vertex_info(const qpGeomVertexArrayData *&array_data,
////////////////////////////////////////////////////////////////////
bool qpGeomVertexData::
get_normal_info(const qpGeomVertexArrayData *&array_data,
qpGeomVertexColumn::NumericType &numeric_type,
qpGeomVertexData::NumericType &numeric_type,
int &start, int &stride) const {
int array_index = _format->get_normal_array_index();
if (array_index >= 0) {
@ -900,7 +929,7 @@ get_normal_info(const qpGeomVertexArrayData *&array_data,
bool qpGeomVertexData::
get_color_info(const qpGeomVertexArrayData *&array_data,
int &num_values,
qpGeomVertexColumn::NumericType &numeric_type,
qpGeomVertexData::NumericType &numeric_type,
int &start, int &stride) const {
int array_index = _format->get_color_array_index();
if (array_index >= 0) {
@ -927,8 +956,7 @@ CPT(qpGeomVertexData) qpGeomVertexData::
do_animate_vertices(bool from_app) const {
CDReader cdata(_cycler);
if (_format->get_animation().get_animation_type() !=
qpGeomVertexAnimationSpec::AT_panda) {
if (_format->get_animation().get_animation_type() != AT_panda) {
return this;
}
@ -1095,23 +1123,23 @@ do_set_num_vertices(int n, qpGeomVertexData::CDWriter &cdata) {
int num_values = column->get_num_values();
switch (column->get_numeric_type()) {
case qpGeomVertexColumn::NT_packed_dcba:
case qpGeomVertexColumn::NT_packed_dabc:
case qpGeomVertexColumn::NT_uint8:
case NT_packed_dcba:
case NT_packed_dabc:
case NT_uint8:
while (pointer < stop) {
memset(pointer, 0xff, num_values);
pointer += stride;
}
break;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
while (pointer < stop) {
memset(pointer, 0xff, num_values * 2);
pointer += stride;
}
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
while (pointer < stop) {
PN_float32 *pi = (PN_float32 *)pointer;
for (int i = 0; i < num_values; i++) {
@ -1157,7 +1185,7 @@ update_animated_vertices(qpGeomVertexData::CDWriter &cdata, bool from_app) {
CPT(qpGeomVertexFormat) animated_format = get_post_animated_format();
cdata->_animated_vertices =
new qpGeomVertexData(get_name(), animated_format,
min(get_usage_hint(), qpGeomUsageHint::UH_dynamic));
min(get_usage_hint(), UH_dynamic));
}
PT(qpGeomVertexData) new_data = cdata->_animated_vertices;
@ -1326,7 +1354,6 @@ write_datagram(BamWriter *manager, Datagram &dg) {
dg.add_string(_name);
manager->write_pointer(dg, _format);
dg.add_uint8(_usage_hint);
manager->write_cdata(dg, _cycler);
}
@ -1431,7 +1458,6 @@ fillin(DatagramIterator &scan, BamReader *manager) {
_name = scan.get_string();
manager->read_pointer(scan);
_usage_hint = (qpGeomUsageHint::UsageHint)scan.get_uint8();
manager->read_cdata(scan, _cycler);
}
@ -1454,6 +1480,8 @@ make_copy() const {
////////////////////////////////////////////////////////////////////
void qpGeomVertexData::CData::
write_datagram(BamWriter *manager, Datagram &dg) const {
dg.add_uint8(_usage_hint);
dg.add_uint16(_arrays.size());
Arrays::const_iterator ai;
for (ai = _arrays.begin(); ai != _arrays.end(); ++ai) {
@ -1499,6 +1527,8 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
////////////////////////////////////////////////////////////////////
void qpGeomVertexData::CData::
fillin(DatagramIterator &scan, BamReader *manager) {
_usage_hint = (UsageHint)scan.get_uint8();
size_t num_arrays = scan.get_uint16();
_arrays.reserve(num_arrays);
for (size_t i = 0; i < num_arrays; ++i) {

View File

@ -24,7 +24,7 @@
#include "qpgeomVertexFormat.h"
#include "qpgeomVertexColumn.h"
#include "qpgeomVertexArrayData.h"
#include "qpgeomUsageHint.h"
#include "qpgeomEnums.h"
#include "transformPalette.h"
#include "transformBlendPalette.h"
#include "sliderTable.h"
@ -72,13 +72,13 @@ class qpGeomVertexColumn;
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomVertexData : public TypedWritableReferenceCount {
class EXPCL_PANDA qpGeomVertexData : public TypedWritableReferenceCount, public qpGeomEnums {
private:
qpGeomVertexData();
PUBLISHED:
qpGeomVertexData(const string &name,
const qpGeomVertexFormat *format,
qpGeomUsageHint::UsageHint usage_hint);
UsageHint usage_hint);
qpGeomVertexData(const qpGeomVertexData &copy);
void operator = (const qpGeomVertexData &copy);
virtual ~qpGeomVertexData();
@ -87,7 +87,8 @@ PUBLISHED:
INLINE void set_name(const string &name);
INLINE const qpGeomVertexFormat *get_format() const;
INLINE qpGeomUsageHint::UsageHint get_usage_hint() const;
INLINE UsageHint get_usage_hint() const;
void set_usage_hint(UsageHint usage_hint);
INLINE bool has_column(const InternalName *name) const;
@ -122,23 +123,19 @@ PUBLISHED:
scale_color(const LVecBase4f &color_scale) const;
CPT(qpGeomVertexData)
scale_color(const LVecBase4f &color_scale, int num_components,
qpGeomVertexColumn::NumericType numeric_type,
qpGeomVertexColumn::Contents contents) const;
NumericType numeric_type, Contents contents) const;
CPT(qpGeomVertexData)
set_color(const Colorf &color) const;
CPT(qpGeomVertexData)
set_color(const Colorf &color, int num_components,
qpGeomVertexColumn::NumericType numeric_type,
qpGeomVertexColumn::Contents contents) const;
NumericType numeric_type, Contents contents) const;
INLINE CPT(qpGeomVertexData) animate_vertices() const;
PT(qpGeomVertexData)
replace_column(const InternalName *name, int num_components,
qpGeomVertexColumn::NumericType numeric_type,
qpGeomVertexColumn::Contents contents,
qpGeomUsageHint::UsageHint usage_hint,
bool keep_animation) const;
NumericType numeric_type, Contents contents,
UsageHint usage_hint, bool keep_animation) const;
void output(ostream &out) const;
void write(ostream &out, int indent_level = 0) const;
@ -148,26 +145,23 @@ public:
bool get_array_info(const InternalName *name,
const qpGeomVertexArrayData *&array_data,
int &num_values,
qpGeomVertexColumn::NumericType &numeric_type,
int &num_values, NumericType &numeric_type,
int &start, int &stride) const;
INLINE bool has_vertex() const;
INLINE bool is_vertex_transformed() const;
bool get_vertex_info(const qpGeomVertexArrayData *&array_data,
int &num_values,
qpGeomVertexColumn::NumericType &numeric_type,
int &num_values, NumericType &numeric_type,
int &start, int &stride) const;
INLINE bool has_normal() const;
bool get_normal_info(const qpGeomVertexArrayData *&array_data,
qpGeomVertexColumn::NumericType &numeric_type,
NumericType &numeric_type,
int &start, int &stride) const;
INLINE bool has_color() const;
bool get_color_info(const qpGeomVertexArrayData *&array_data,
int &num_values,
qpGeomVertexColumn::NumericType &numeric_type,
int &num_values, NumericType &numeric_type,
int &start, int &stride) const;
static INLINE PN_uint32 pack_abcd(unsigned int a, unsigned int b,
@ -201,7 +195,6 @@ private:
private:
string _name;
CPT(qpGeomVertexFormat) _format;
qpGeomUsageHint::UsageHint _usage_hint;
typedef pvector< PT(qpGeomVertexArrayData) > Arrays;
@ -215,6 +208,7 @@ private:
virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
virtual void fillin(DatagramIterator &scan, BamReader *manager);
UsageHint _usage_hint;
Arrays _arrays;
CPT(TransformPalette) _transform_palette;
PT(TransformBlendPalette) _transform_blend_palette;

View File

@ -380,7 +380,7 @@ output(ostream &out) const {
}
}
if (_animation.get_animation_type() != qpGeomVertexAnimationSpec::AT_none) {
if (_animation.get_animation_type() != AT_none) {
out << ", anim " << _animation;
}
}
@ -398,7 +398,7 @@ write(ostream &out, int indent_level) const {
_arrays[i]->write(out, indent_level + 2);
}
if (_animation.get_animation_type() != qpGeomVertexAnimationSpec::AT_none) {
if (_animation.get_animation_type() != AT_none) {
indent(out, indent_level)
<< "anim " << _animation;
}
@ -536,22 +536,22 @@ do_register() {
const qpGeomVertexColumn *column = _arrays[record._array_index]->get_column(record._column_index);
switch (column->get_contents()) {
case qpGeomVertexColumn::C_point:
case C_point:
// It's a point.
_points.push_back(column->get_name());
break;
case qpGeomVertexColumn::C_vector:
case C_vector:
// It's a vector.
_vectors.push_back(column->get_name());
break;
case qpGeomVertexColumn::C_texcoord:
case C_texcoord:
// It's a texcoord.
_texcoords.push_back(column->get_name());
break;
case qpGeomVertexColumn::C_morph_delta:
case C_morph_delta:
{
// It's a morph description.
MorphRecord morph;
@ -713,127 +713,95 @@ qpGeomVertexFormat::Registry::
Registry() {
_v3 = register_format(new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point));
NT_float32, C_point));
_v3n3 = register_format(new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_normal(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_vector));
NT_float32, C_vector));
_v3t2 = register_format(new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_texcoord(), 2,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_texcoord));
NT_float32, C_texcoord));
_v3n3t2 = register_format(new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_normal(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_vector,
NT_float32, C_vector,
InternalName::get_texcoord(), 2,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_texcoord));
NT_float32, C_texcoord));
// Define the DirectX-style packed color formats
_v3cp = register_format(new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_color(), 1,
qpGeomVertexColumn::NT_packed_dabc,
qpGeomVertexColumn::C_color));
NT_packed_dabc, C_color));
_v3n3cp = register_format(new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_normal(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_color(), 1,
qpGeomVertexColumn::NT_packed_dabc,
qpGeomVertexColumn::C_color));
NT_packed_dabc, C_color));
_v3cpt2 = register_format(new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_color(), 1,
qpGeomVertexColumn::NT_packed_dabc,
qpGeomVertexColumn::C_color,
NT_packed_dabc, C_color,
InternalName::get_texcoord(), 2,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_texcoord));
NT_float32, C_texcoord));
_v3n3cpt2 = register_format(new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_normal(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_color(), 1,
qpGeomVertexColumn::NT_packed_dabc,
qpGeomVertexColumn::C_color,
NT_packed_dabc, C_color,
InternalName::get_texcoord(), 2,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_texcoord));
NT_float32, C_texcoord));
// Define the OpenGL-style per-byte color formats. This is not the
// same as a packed format, above, because the resulting byte order
// is endian-independent.
_v3c4 = register_format(new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_color(), 4,
qpGeomVertexColumn::NT_uint8,
qpGeomVertexColumn::C_color));
NT_uint8, C_color));
_v3n3c4 = register_format(new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_normal(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_color(), 4,
qpGeomVertexColumn::NT_uint8,
qpGeomVertexColumn::C_color));
NT_uint8, C_color));
_v3c4t2 = register_format(new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_color(), 4,
qpGeomVertexColumn::NT_uint8,
qpGeomVertexColumn::C_color,
NT_uint8, C_color,
InternalName::get_texcoord(), 2,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_texcoord));
NT_float32, C_texcoord));
_v3n3c4t2 = register_format(new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_normal(), 3,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
NT_float32, C_point,
InternalName::get_color(), 4,
qpGeomVertexColumn::NT_uint8,
qpGeomVertexColumn::C_color,
NT_uint8, C_color,
InternalName::get_texcoord(), 2,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_texcoord));
NT_float32, C_texcoord));
}
////////////////////////////////////////////////////////////////////

View File

@ -23,6 +23,7 @@
#include "typedWritableReferenceCount.h"
#include "qpgeomVertexAnimationSpec.h"
#include "qpgeomVertexArrayFormat.h"
#include "qpgeomEnums.h"
#include "internalName.h"
#include "luse.h"
#include "pointerTo.h"
@ -64,7 +65,7 @@ class qpGeomMunger;
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomVertexFormat : public TypedWritableReferenceCount {
class EXPCL_PANDA qpGeomVertexFormat : public TypedWritableReferenceCount, public qpGeomEnums {
PUBLISHED:
qpGeomVertexFormat();
qpGeomVertexFormat(const qpGeomVertexArrayFormat *array_format);

View File

@ -401,7 +401,7 @@ inc_pointer() {
////////////////////////////////////////////////////////////////////
INLINE float qpGeomVertexReader::Reader::
maybe_scale_color(unsigned int value) {
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
if (_column->get_contents() == C_color) {
return (float)value / 255.0f;
} else {
return (float)value;
@ -416,7 +416,7 @@ maybe_scale_color(unsigned int value) {
////////////////////////////////////////////////////////////////////
INLINE void qpGeomVertexReader::Reader::
maybe_scale_color(unsigned int a, unsigned int b) {
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
if (_column->get_contents() == C_color) {
_v2.set((float)a / 255.0f,
(float)b / 255.0f);
} else {
@ -432,7 +432,7 @@ maybe_scale_color(unsigned int a, unsigned int b) {
////////////////////////////////////////////////////////////////////
INLINE void qpGeomVertexReader::Reader::
maybe_scale_color(unsigned int a, unsigned int b, unsigned int c) {
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
if (_column->get_contents() == C_color) {
_v3.set((float)a / 255.0f,
(float)b / 255.0f,
(float)c / 255.0f);
@ -450,7 +450,7 @@ maybe_scale_color(unsigned int a, unsigned int b, unsigned int c) {
INLINE void qpGeomVertexReader::Reader::
maybe_scale_color(unsigned int a, unsigned int b, unsigned int c,
unsigned int d) {
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
if (_column->get_contents() == C_color) {
_v4.set((float)a / 255.0f,
(float)b / 255.0f,
(float)c / 255.0f,

View File

@ -82,12 +82,12 @@ set_column(int array, const qpGeomVertexColumn *column) {
qpGeomVertexReader::Reader *qpGeomVertexReader::
make_reader() const {
switch (_column->get_contents()) {
case qpGeomVertexColumn::C_point:
case qpGeomVertexColumn::C_clip_point:
case qpGeomVertexColumn::C_texcoord:
case C_point:
case C_clip_point:
case C_texcoord:
// These types are read as a 4-d homogeneous point.
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_float32:
case NT_float32:
if (sizeof(float) == sizeof(PN_float32)) {
// Use the native float type implementation for a tiny bit
// more optimization.
@ -115,9 +115,9 @@ make_reader() const {
}
return new Reader_point;
case qpGeomVertexColumn::C_color:
case C_color:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
switch (_column->get_num_components()) {
case 4:
return new Reader_rgba_uint8_4;
@ -126,7 +126,7 @@ make_reader() const {
break;
}
break;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
switch (_column->get_num_components()) {
case 1:
return new Reader_argb_packed;
@ -135,7 +135,7 @@ make_reader() const {
break;
}
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
switch (_column->get_num_components()) {
case 4:
if (sizeof(float) == sizeof(PN_float32)) {
@ -158,7 +158,7 @@ make_reader() const {
default:
// Otherwise, we just read it as a generic value.
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_float32:
case NT_float32:
switch (_column->get_num_components()) {
case 3:
if (sizeof(float) == sizeof(PN_float32)) {
@ -197,25 +197,25 @@ qpGeomVertexReader::Reader::
float qpGeomVertexReader::Reader::
get_data1f(const unsigned char *pointer) {
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
return maybe_scale_color(*pointer);
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
return *(const PN_uint16 *)pointer;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
return maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword));
}
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
return maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword));
}
case qpGeomVertexColumn::NT_float32:
case NT_float32:
return *(const PN_float32 *)pointer;
}
@ -235,18 +235,18 @@ get_data2f(const unsigned char *pointer) {
} else {
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
maybe_scale_color(pointer[0], pointer[1]);
return _v2;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
const PN_uint16 *pi = (const PN_uint16 *)pointer;
_v2.set(pi[0], pi[1]);
}
return _v2;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
@ -254,7 +254,7 @@ get_data2f(const unsigned char *pointer) {
}
return _v2;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
@ -262,7 +262,7 @@ get_data2f(const unsigned char *pointer) {
}
return _v2;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
const PN_float32 *pi = (const PN_float32 *)pointer;
_v2.set(pi[0], pi[1]);
@ -295,18 +295,18 @@ get_data3f(const unsigned char *pointer) {
default:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
maybe_scale_color(pointer[0], pointer[1], pointer[2]);
return _v3;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
const PN_uint16 *pi = (const PN_uint16 *)pointer;
_v3.set(pi[0], pi[1], pi[2]);
}
return _v3;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
@ -315,7 +315,7 @@ get_data3f(const unsigned char *pointer) {
}
return _v3;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
@ -324,7 +324,7 @@ get_data3f(const unsigned char *pointer) {
}
return _v3;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
const PN_float32 *pi = (const PN_float32 *)pointer;
_v3.set(pi[0], pi[1], pi[2]);
@ -364,18 +364,18 @@ get_data4f(const unsigned char *pointer) {
default:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
maybe_scale_color(pointer[0], pointer[1], pointer[2], pointer[3]);
return _v4;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
const PN_uint16 *pi = (const PN_uint16 *)pointer;
_v4.set(pi[0], pi[1], pi[2], pi[3]);
}
return _v4;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
@ -385,7 +385,7 @@ get_data4f(const unsigned char *pointer) {
}
return _v4;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
@ -395,7 +395,7 @@ get_data4f(const unsigned char *pointer) {
}
return _v4;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
const PN_float32 *pi = (const PN_float32 *)pointer;
_v4.set(pi[0], pi[1], pi[2], pi[3]);
@ -415,27 +415,27 @@ get_data4f(const unsigned char *pointer) {
int qpGeomVertexReader::Reader::
get_data1i(const unsigned char *pointer) {
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
return *pointer;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
return *(const PN_uint16 *)pointer;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
return qpGeomVertexData::unpack_abcd_d(dword);
}
break;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
return qpGeomVertexData::unpack_abcd_b(dword);
}
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
return (int)*(const PN_float32 *)pointer;
}
@ -457,12 +457,12 @@ get_data2i(const unsigned char *pointer) {
default:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
_i[0] = pointer[0];
_i[1] = pointer[1];
return _i;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
const PN_uint16 *pi = (const PN_uint16 *)pointer;
_i[0] = pi[0];
@ -470,7 +470,7 @@ get_data2i(const unsigned char *pointer) {
}
return _i;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
_i[0] = qpGeomVertexData::unpack_abcd_d(dword);
@ -478,7 +478,7 @@ get_data2i(const unsigned char *pointer) {
}
return _i;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
_i[0] = qpGeomVertexData::unpack_abcd_b(dword);
@ -486,7 +486,7 @@ get_data2i(const unsigned char *pointer) {
}
return _i;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
const PN_float32 *pi = (const PN_float32 *)pointer;
_i[0] = (int)pi[0];
@ -524,13 +524,13 @@ get_data3i(const unsigned char *pointer) {
default:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
_i[0] = pointer[0];
_i[1] = pointer[1];
_i[2] = pointer[2];
return _i;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
const PN_uint16 *pi = (const PN_uint16 *)pointer;
_i[0] = pi[0];
@ -539,7 +539,7 @@ get_data3i(const unsigned char *pointer) {
}
return _i;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
_i[0] = qpGeomVertexData::unpack_abcd_d(dword);
@ -548,7 +548,7 @@ get_data3i(const unsigned char *pointer) {
}
return _i;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
_i[0] = qpGeomVertexData::unpack_abcd_b(dword);
@ -557,7 +557,7 @@ get_data3i(const unsigned char *pointer) {
}
return _i;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
const PN_float32 *pi = (const PN_float32 *)pointer;
_i[0] = (int)pi[0];
@ -608,14 +608,14 @@ get_data4i(const unsigned char *pointer) {
default:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
_i[0] = pointer[0];
_i[1] = pointer[1];
_i[2] = pointer[2];
_i[3] = pointer[3];
return _i;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
const PN_uint16 *pi = (const PN_uint16 *)pointer;
_i[0] = pi[0];
@ -625,7 +625,7 @@ get_data4i(const unsigned char *pointer) {
}
return _i;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
_i[0] = qpGeomVertexData::unpack_abcd_d(dword);
@ -635,7 +635,7 @@ get_data4i(const unsigned char *pointer) {
}
return _i;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
_i[0] = qpGeomVertexData::unpack_abcd_b(dword);
@ -645,7 +645,7 @@ get_data4i(const unsigned char *pointer) {
}
return _i;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
const PN_float32 *pi = (const PN_float32 *)pointer;
_i[0] = (int)pi[0];
@ -735,18 +735,18 @@ get_data4f(const unsigned char *pointer) {
default:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
maybe_scale_color(pointer[0], pointer[1], pointer[2], pointer[3]);
return _v4;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
const PN_uint16 *pi = (const PN_uint16 *)pointer;
_v4.set(pi[0], pi[1], pi[2], pi[3]);
}
return _v4;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
@ -756,7 +756,7 @@ get_data4f(const unsigned char *pointer) {
}
return _v4;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
@ -766,7 +766,7 @@ get_data4f(const unsigned char *pointer) {
}
return _v4;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
const PN_float32 *pi = (const PN_float32 *)pointer;
_v4.set(pi[0], pi[1], pi[2], pi[3]);
@ -806,18 +806,18 @@ get_data4f(const unsigned char *pointer) {
default:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
maybe_scale_color(pointer[0], pointer[1], pointer[2], pointer[3]);
return _v4;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
const PN_uint16 *pi = (const PN_uint16 *)pointer;
_v4.set(pi[0], pi[1], pi[2], pi[3]);
}
return _v4;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
@ -827,7 +827,7 @@ get_data4f(const unsigned char *pointer) {
}
return _v4;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
{
PN_uint32 dword = *(const PN_uint32 *)pointer;
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
@ -837,7 +837,7 @@ get_data4f(const unsigned char *pointer) {
}
return _v4;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
const PN_float32 *pi = (const PN_float32 *)pointer;
_v4.set(pi[0], pi[1], pi[2], pi[3]);

View File

@ -59,7 +59,7 @@
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomVertexReader {
class EXPCL_PANDA qpGeomVertexReader : public qpGeomEnums {
PUBLISHED:
INLINE qpGeomVertexReader(const qpGeomVertexData *vertex_data);
INLINE qpGeomVertexReader(const qpGeomVertexData *vertex_data,

View File

@ -729,7 +729,7 @@ inc_add_pointer() {
////////////////////////////////////////////////////////////////////
INLINE unsigned int qpGeomVertexWriter::Writer::
maybe_scale_color(float data) {
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
if (_column->get_contents() == C_color) {
return (unsigned int)(data * 255.0f);
} else {
return (unsigned int)data;
@ -745,7 +745,7 @@ maybe_scale_color(float data) {
////////////////////////////////////////////////////////////////////
INLINE void qpGeomVertexWriter::Writer::
maybe_scale_color(const LVecBase2f &data) {
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
if (_column->get_contents() == C_color) {
_a = (unsigned int)(data[0] * 255.0f);
_b = (unsigned int)(data[1] * 255.0f);
} else {
@ -763,7 +763,7 @@ maybe_scale_color(const LVecBase2f &data) {
////////////////////////////////////////////////////////////////////
INLINE void qpGeomVertexWriter::Writer::
maybe_scale_color(const LVecBase3f &data) {
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
if (_column->get_contents() == C_color) {
_a = (unsigned int)(data[0] * 255.0f);
_b = (unsigned int)(data[1] * 255.0f);
_c = (unsigned int)(data[2] * 255.0f);
@ -783,7 +783,7 @@ maybe_scale_color(const LVecBase3f &data) {
////////////////////////////////////////////////////////////////////
INLINE void qpGeomVertexWriter::Writer::
maybe_scale_color(const LVecBase4f &data) {
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
if (_column->get_contents() == C_color) {
_a = (unsigned int)(data[0] * 255.0f);
_b = (unsigned int)(data[1] * 255.0f);
_c = (unsigned int)(data[2] * 255.0f);

View File

@ -86,12 +86,12 @@ set_column(int array, const qpGeomVertexColumn *column) {
qpGeomVertexWriter::Writer *qpGeomVertexWriter::
make_writer() const {
switch (_column->get_contents()) {
case qpGeomVertexColumn::C_point:
case qpGeomVertexColumn::C_clip_point:
case qpGeomVertexColumn::C_texcoord:
case C_point:
case C_clip_point:
case C_texcoord:
// These types are written as a 4-d homogeneous point.
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_float32:
case NT_float32:
switch (_column->get_num_components()) {
case 2:
return new Writer_point_float32_2;
@ -109,9 +109,9 @@ make_writer() const {
}
return new Writer_point;
case qpGeomVertexColumn::C_color:
case C_color:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
switch (_column->get_num_components()) {
case 4:
return new Writer_rgba_uint8_4;
@ -120,7 +120,7 @@ make_writer() const {
break;
}
break;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
switch (_column->get_num_components()) {
case 1:
return new Writer_argb_packed;
@ -129,7 +129,7 @@ make_writer() const {
break;
}
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
switch (_column->get_num_components()) {
case 4:
return new Writer_rgba_float32_4;
@ -146,7 +146,7 @@ make_writer() const {
default:
// Otherwise, we just write it as a generic value.
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_float32:
case NT_float32:
switch (_column->get_num_components()) {
case 3:
return new Writer_float32_3;
@ -181,20 +181,20 @@ set_data1f(unsigned char *pointer, float data) {
switch (_column->get_num_values()) {
case 1:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
*pointer = maybe_scale_color(data);
break;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
*(PN_uint16 *)pointer = (unsigned int)data;
break;
case qpGeomVertexColumn::NT_packed_dcba:
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dcba:
case NT_packed_dabc:
nassertv(false);
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
*(PN_float32 *)pointer = data;
break;
}
@ -227,13 +227,13 @@ set_data2f(unsigned char *pointer, const LVecBase2f &data) {
case 2:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
maybe_scale_color(data);
pointer[0] = _a;
pointer[1] = _b;
break;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
PN_uint16 *pi = (PN_uint16 *)pointer;
pi[0] = (unsigned int)data[0];
@ -241,12 +241,12 @@ set_data2f(unsigned char *pointer, const LVecBase2f &data) {
}
break;
case qpGeomVertexColumn::NT_packed_dcba:
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dcba:
case NT_packed_dabc:
nassertv(false);
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
PN_float32 *pi = (PN_float32 *)pointer;
pi[0] = data[0];
@ -284,14 +284,14 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) {
case 3:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
maybe_scale_color(data);
pointer[0] = _a;
pointer[1] = _b;
pointer[2] = _c;
break;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
PN_uint16 *pi = (PN_uint16 *)pointer;
pi[0] = (unsigned int)data[0];
@ -300,12 +300,12 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) {
}
break;
case qpGeomVertexColumn::NT_packed_dcba:
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dcba:
case NT_packed_dabc:
nassertv(false);
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
PN_float32 *pi = (PN_float32 *)pointer;
pi[0] = data[0];
@ -344,7 +344,7 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
default:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
maybe_scale_color(data);
pointer[0] = _a;
pointer[1] = _b;
@ -352,7 +352,7 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
pointer[3] = _d;
break;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
PN_uint16 *pi = (PN_uint16 *)pointer;
pi[0] = (unsigned int)data[0];
@ -362,17 +362,17 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
}
break;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
maybe_scale_color(data);
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(_d, _c, _b, _a);
break;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
maybe_scale_color(data);
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(_d, _a, _b, _c);
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
PN_float32 *pi = (PN_float32 *)pointer;
pi[0] = data[0];
@ -396,20 +396,20 @@ set_data1i(unsigned char *pointer, int a) {
switch (_column->get_num_values()) {
case 1:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
*pointer = a;
break;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
*(PN_uint16 *)pointer = a;
break;
case qpGeomVertexColumn::NT_packed_dcba:
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dcba:
case NT_packed_dabc:
nassertv(false);
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
*(PN_float32 *)pointer = (float)a;
break;
}
@ -443,12 +443,12 @@ set_data2i(unsigned char *pointer, int a, int b) {
case 2:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
pointer[0] = a;
pointer[1] = b;
break;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
PN_uint16 *pi = (PN_uint16 *)pointer;
pi[0] = a;
@ -456,12 +456,12 @@ set_data2i(unsigned char *pointer, int a, int b) {
}
break;
case qpGeomVertexColumn::NT_packed_dcba:
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dcba:
case NT_packed_dabc:
nassertv(false);
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
PN_float32 *pi = (PN_float32 *)pointer;
pi[0] = a;
@ -499,13 +499,13 @@ set_data3i(unsigned char *pointer, int a, int b, int c) {
case 3:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
pointer[0] = a;
pointer[1] = b;
pointer[2] = c;
break;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
PN_uint16 *pi = (PN_uint16 *)pointer;
pi[0] = a;
@ -514,12 +514,12 @@ set_data3i(unsigned char *pointer, int a, int b, int c) {
}
break;
case qpGeomVertexColumn::NT_packed_dcba:
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dcba:
case NT_packed_dabc:
nassertv(false);
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
PN_float32 *pi = (PN_float32 *)pointer;
pi[0] = a;
@ -558,14 +558,14 @@ set_data4i(unsigned char *pointer, int a, int b, int c, int d) {
default:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
pointer[0] = a;
pointer[1] = b;
pointer[2] = c;
pointer[3] = d;
break;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
PN_uint16 *pi = (PN_uint16 *)pointer;
pi[0] = a;
@ -575,15 +575,15 @@ set_data4i(unsigned char *pointer, int a, int b, int c, int d) {
}
break;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(d, c, b, a);
break;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(d, a, b, c);
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
PN_float32 *pi = (PN_float32 *)pointer;
pi[0] = a;
@ -661,7 +661,7 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
default:
switch (_column->get_numeric_type()) {
case qpGeomVertexColumn::NT_uint8:
case NT_uint8:
maybe_scale_color(data);
pointer[0] = _a;
pointer[1] = _b;
@ -669,7 +669,7 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
pointer[3] = _d;
break;
case qpGeomVertexColumn::NT_uint16:
case NT_uint16:
{
PN_uint16 *pi = (PN_uint16 *)pointer;
pi[0] = (unsigned int)data[0];
@ -679,17 +679,17 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
}
break;
case qpGeomVertexColumn::NT_packed_dcba:
case NT_packed_dcba:
maybe_scale_color(data);
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(_d, _c, _b, _a);
break;
case qpGeomVertexColumn::NT_packed_dabc:
case NT_packed_dabc:
maybe_scale_color(data);
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(_d, _a, _b, _c);
break;
case qpGeomVertexColumn::NT_float32:
case NT_float32:
{
PN_float32 *pi = (PN_float32 *)pointer;
pi[0] = data[0];

View File

@ -72,7 +72,7 @@
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA qpGeomVertexWriter {
class EXPCL_PANDA qpGeomVertexWriter : public qpGeomEnums {
PUBLISHED:
INLINE qpGeomVertexWriter(qpGeomVertexData *vertex_data);
INLINE qpGeomVertexWriter(qpGeomVertexData *vertex_data,

View File

@ -73,7 +73,7 @@ generate() {
}
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("card", format, qpGeomUsageHint::UH_static);
("card", format, qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter color(vdata, InternalName::get_color());
@ -95,7 +95,7 @@ generate() {
texcoord.add_data2f(_ur[0], _ll[1]);
}
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_static);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_static);
strip->add_next_vertices(4);
PT(qpGeom) geom = new qpGeom;

View File

@ -47,6 +47,7 @@ FrameRateMeter(const string &name) : TextNode(name) {
LMatrix4f::translate_mat(LVector3f::rfu(1.0f - frame_rate_meter_side_margins * frame_rate_meter_scale, 0.0f, 1.0f - frame_rate_meter_scale)));
set_card_color(0.0f, 0.0f, 0.0f, 0.4f);
set_card_as_margin(frame_rate_meter_side_margins, frame_rate_meter_side_margins, 0.1f, 0.0f);
set_usage_hint(qpGeom::UH_client);
do_update();
}

View File

@ -161,12 +161,12 @@ create(GeomNode *previous, bool dynamic) {
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("lineSegs", qpGeomVertexFormat::get_v3cp(),
dynamic ? qpGeomUsageHint::UH_dynamic : qpGeomUsageHint::UH_static);
dynamic ? qpGeom::UH_dynamic : qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter color(vdata, InternalName::get_color());
PT(qpGeomLinestrips) lines = new qpGeomLinestrips(qpGeomUsageHint::UH_static);
PT(qpGeomPoints) points = new qpGeomPoints(qpGeomUsageHint::UH_static);
PT(qpGeomLinestrips) lines = new qpGeomLinestrips(qpGeom::UH_static);
PT(qpGeomPoints) points = new qpGeomPoints(qpGeom::UH_static);
int v = 0;
LineList::const_iterator ll;

View File

@ -832,7 +832,7 @@ transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name,
vdata = vdata->replace_column
(InternalName::get_texcoord(), column->get_num_components(),
column->get_numeric_type(), column->get_contents(),
qpGeomUsageHint::UH_stream, true);
qpGeom::UH_stream, true);
geom->set_vertex_data(vdata);
qpGeomVertexReader from(vdata, texcoord_name);

View File

@ -262,23 +262,23 @@ recompute_internal_bound() {
CPT(qpGeomVertexFormat) RopeNode::
get_format(bool support_normals) const {
PT(qpGeomVertexArrayFormat) array_format = new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3, qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point);
(InternalName::get_vertex(), 3, qpGeom::NT_float32,
qpGeom::C_point);
if (support_normals && get_normal_mode() == NM_vertex) {
array_format->add_column
(InternalName::get_normal(), 3, qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_vector);
(InternalName::get_normal(), 3, qpGeom::NT_float32,
qpGeom::C_vector);
}
if (get_use_vertex_color()) {
array_format->add_column
(InternalName::get_color(), 1, qpGeomVertexColumn::NT_packed_dabc,
qpGeomVertexColumn::C_color);
(InternalName::get_color(), 1, qpGeom::NT_packed_dabc,
qpGeom::C_color);
}
if (get_uv_mode() != UV_none) {
array_format->add_column
(InternalName::get_texcoord(), 2, qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_texcoord);
(InternalName::get_texcoord(), 2, qpGeom::NT_float32,
qpGeom::C_texcoord);
}
return qpGeomVertexFormat::register_format(array_format);
@ -340,11 +340,11 @@ render_thread(CullTraverser *trav, CullTraverserData &data,
// center strips. Go back through and calculate the vertices on
// either side.
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("rope", get_format(false), qpGeomUsageHint::UH_stream);
("rope", get_format(false), qpGeom::UH_stream);
compute_thread_vertices(vdata, curve_segments);
PT(qpGeomLinestrips) strip = new qpGeomLinestrips(qpGeomUsageHint::UH_stream);
PT(qpGeomLinestrips) strip = new qpGeomLinestrips(qpGeom::UH_stream);
CurveSegments::const_iterator si;
for (si = curve_segments.begin(); si != curve_segments.end(); ++si) {
const CurveSegment &segment = (*si);
@ -432,12 +432,12 @@ render_tape(CullTraverser *trav, CullTraverserData &data,
// center strips. Go back through and calculate the vertices on
// either side.
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("rope", get_format(false), qpGeomUsageHint::UH_stream);
("rope", get_format(false), qpGeom::UH_stream);
compute_billboard_vertices(vdata, -get_tube_up(),
curve_segments, result);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_stream);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_stream);
CurveSegments::const_iterator si;
for (si = curve_segments.begin(); si != curve_segments.end(); ++si) {
const CurveSegment &segment = (*si);
@ -530,12 +530,12 @@ render_billboard(CullTraverser *trav, CullTraverserData &data,
// center strips. Go back through and calculate the vertices on
// either side.
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("rope", get_format(false), qpGeomUsageHint::UH_stream);
("rope", get_format(false), qpGeom::UH_stream);
compute_billboard_vertices(vdata, camera_vec,
curve_segments, result);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_stream);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_stream);
CurveSegments::const_iterator si;
for (si = curve_segments.begin(); si != curve_segments.end(); ++si) {
const CurveSegment &segment = (*si);
@ -623,12 +623,12 @@ render_tube(CullTraverser *trav, CullTraverserData &data,
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("rope", get_format(true), qpGeomUsageHint::UH_stream);
("rope", get_format(true), qpGeom::UH_stream);
compute_tube_vertices(vdata,
num_verts_per_slice, curve_segments, result);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_stream);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_stream);
// Finally, go through build up the index array, to tie all the
// triangle strips together.
int vi = 0;

View File

@ -280,13 +280,13 @@ render_sheet(CullTraverser *trav, CullTraverserData &data,
format = qpGeomVertexFormat::get_v3n3t2();
}
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("sheet", format, qpGeomUsageHint::UH_stream);
("sheet", format, qpGeom::UH_stream);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter normal(vdata, InternalName::get_normal());
qpGeomVertexWriter color(vdata, InternalName::get_color());
qpGeomVertexWriter texcoord(vdata, InternalName::get_texcoord());
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_stream);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_stream);
for (int ui = 0; ui < num_u_segments; ui++) {
for (int uni = 0; uni < num_u_verts; uni++) {
float u0 = (float)uni / (float)num_u_verts;

View File

@ -143,9 +143,9 @@ init_geoms() {
_line_primitive = qpgeom;
_vdata = new qpGeomVertexData
("particles", qpGeomVertexFormat::get_v3cp(),
qpGeomUsageHint::UH_dynamic);
qpGeom::UH_dynamic);
qpgeom->set_vertex_data(_vdata);
_lines = new qpGeomLines(qpGeomUsageHint::UH_dynamic);
_lines = new qpGeomLines(qpGeom::UH_dynamic);
qpgeom->add_primitive(_lines);
} else {

View File

@ -118,9 +118,9 @@ init_geoms() {
_point_primitive = qpgeom;
_vdata = new qpGeomVertexData
("particles", qpGeomVertexFormat::get_v3cp(),
qpGeomUsageHint::UH_dynamic);
qpGeom::UH_dynamic);
qpgeom->set_vertex_data(_vdata);
_points = new qpGeomPoints(qpGeomUsageHint::UH_dynamic);
_points = new qpGeomPoints(qpGeom::UH_dynamic);
qpgeom->add_primitive(_points);
} else {

View File

@ -139,9 +139,9 @@ init_geoms() {
_line_primitive = qpgeom;
_vdata = new qpGeomVertexData
("particles", qpGeomVertexFormat::get_v3cp(),
qpGeomUsageHint::UH_dynamic);
qpGeom::UH_dynamic);
qpgeom->set_vertex_data(_vdata);
_lines = new qpGeomLines(qpGeomUsageHint::UH_dynamic);
_lines = new qpGeomLines(qpGeom::UH_dynamic);
qpgeom->add_primitive(_lines);
} else {

View File

@ -320,15 +320,12 @@ init_geoms() {
_sprite_primitive = qpgeom;
PT(qpGeomVertexArrayFormat) array_format = new qpGeomVertexArrayFormat
(InternalName::get_vertex(), 3, qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_point,
InternalName::get_color(), 1, qpGeomVertexColumn::NT_packed_dabc,
qpGeomVertexColumn::C_color);
(InternalName::get_vertex(), 3, qpGeom::NT_float32, qpGeom::C_point,
InternalName::get_color(), 1, qpGeom::NT_packed_dabc, qpGeom::C_color);
if (_animate_theta || _theta != 0.0f) {
array_format->add_column
(InternalName::get_rotate(), 1, qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_other);
(InternalName::get_rotate(), 1, qpGeom::NT_float32, qpGeom::C_other);
}
_base_y_scale = _initial_y_scale;
@ -340,24 +337,23 @@ init_geoms() {
if (_animate_y_ratio) {
_base_y_scale = max(_initial_y_scale, _final_y_scale);
array_format->add_column
(InternalName::get_size(), 1, qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_other);
(InternalName::get_size(), 1, qpGeom::NT_float32, qpGeom::C_other);
}
if (_aspect_ratio * _initial_x_scale != _initial_y_scale ||
_aspect_ratio * final_x_scale != final_y_scale) {
array_format->add_column
(InternalName::get_aspect_ratio(), 1, qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_other);
(InternalName::get_aspect_ratio(), 1, qpGeom::NT_float32,
qpGeom::C_other);
}
CPT(qpGeomVertexFormat) format = qpGeomVertexFormat::register_format
(new qpGeomVertexFormat(array_format));
_vdata = new qpGeomVertexData
("particles", format, qpGeomUsageHint::UH_dynamic);
("particles", format, qpGeom::UH_dynamic);
qpgeom->set_vertex_data(_vdata);
_sprites = new qpGeomPoints(qpGeomUsageHint::UH_dynamic);
_sprites = new qpGeomPoints(qpGeom::UH_dynamic);
qpgeom->add_primitive(_sprites);
state = state->add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_unchanged, _base_y_scale * _height, true));

View File

@ -306,10 +306,10 @@ make_bounds_viz(const BoundingVolume &vol) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("collision", qpGeomVertexFormat::get_v3(),
qpGeomUsageHint::UH_stream);
qpGeom::UH_stream);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_stream);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_stream);
for (int sl = 0; sl < num_slices; ++sl) {
float longitude0 = (float)sl / (float)num_slices;
float longitude1 = (float)(sl + 1) / (float)num_slices;

View File

@ -81,8 +81,7 @@ munge_geom(GraphicsStateGuardianBase *gsg,
// We have to add a color column, which means we have to
// re-munge.
animated_vertices = animated_vertices->set_color
(flash_color, 1, qpGeomVertexColumn::NT_packed_dabc,
qpGeomVertexColumn::C_color);
(flash_color, 1, qpGeom::NT_packed_dabc, qpGeom::C_color);
animated_vertices = munger->munge_data(animated_vertices);
}
_state = _state->remove_attrib(TextureAttrib::get_class_type());
@ -172,8 +171,8 @@ munge_points_to_quads(const CullTraverser *traverser) {
PT(qpGeomVertexArrayFormat) new_array_format =
new qpGeomVertexArrayFormat(InternalName::get_vertex(), 4,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_clip_point);
qpGeom::NT_float32,
qpGeom::C_clip_point);
if (has_normal) {
const qpGeomVertexColumn *c = normal.get_column();
new_array_format->add_column
@ -189,8 +188,8 @@ munge_points_to_quads(const CullTraverser *traverser) {
if (sprite_texcoord) {
new_array_format->add_column
(InternalName::get_texcoord(), 2,
qpGeomVertexColumn::NT_float32,
qpGeomVertexColumn::C_texcoord);
qpGeom::NT_float32,
qpGeom::C_texcoord);
} else if (has_texcoord) {
const qpGeomVertexColumn *c = texcoord.get_column();
@ -203,7 +202,7 @@ munge_points_to_quads(const CullTraverser *traverser) {
qpGeomVertexFormat::register_format(new_array_format);
PT(qpGeomVertexData) new_data = new qpGeomVertexData
(_munged_data->get_name(), new_format, qpGeomUsageHint::UH_client);
(_munged_data->get_name(), new_format, qpGeom::UH_client);
qpGeomVertexWriter new_vertex(new_data, InternalName::get_vertex());
qpGeomVertexWriter new_normal(new_data, InternalName::get_normal());
@ -289,7 +288,7 @@ munge_points_to_quads(const CullTraverser *traverser) {
// generally faster on PC hardware (otherwise, we'd have to nearly
// double the vertices to stitch all the little triangle strips
// together).
PT(qpGeomPrimitive) new_primitive = new qpGeomTriangles(qpGeomUsageHint::UH_client);
PT(qpGeomPrimitive) new_primitive = new qpGeomTriangles(qpGeom::UH_client);
for (vi = vertices; vi != vertices_end; ++vi) {
// The point in eye coordinates.

View File

@ -17,6 +17,32 @@
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: GeomTransformer::set_usage_hint
// Access: Published
// Description: Specifies the ceiling UsageHint that will be applied
// to transformed geometry. If the source geometry's
// usage hint is greater (more static) than this, it
// will be reduced to this level. If the source
// geometry's usage hit is less (more dynamic) than
// this, it will be preserved at its current level.
////////////////////////////////////////////////////////////////////
INLINE void GeomTransformer::
set_usage_hint(qpGeom::UsageHint usage_hint) {
_usage_hint = usage_hint;
}
////////////////////////////////////////////////////////////////////
// Function: GeomTransformer::get_usage_hint
// Access: Published
// Description: Returns the UsageHint that will be applied to
// generated geometry. See set_usage_hint().
////////////////////////////////////////////////////////////////////
INLINE qpGeom::UsageHint GeomTransformer::
get_usage_hint() const {
return _usage_hint;
}
////////////////////////////////////////////////////////////////////
// Function: GeomTransformer::get_max_collect_vertices
// Access: Public

View File

@ -30,6 +30,7 @@
////////////////////////////////////////////////////////////////////
GeomTransformer::
GeomTransformer() :
_usage_hint(qpGeom::UH_static),
// The default value here comes from the Config file.
_max_collect_vertices(max_collect_vertices)
{
@ -42,6 +43,7 @@ GeomTransformer() :
////////////////////////////////////////////////////////////////////
GeomTransformer::
GeomTransformer(const GeomTransformer &copy) :
_usage_hint(copy._usage_hint),
_max_collect_vertices(copy._max_collect_vertices)
{
}
@ -234,7 +236,8 @@ transform_texcoords(Geom *geom, const InternalName *from_name,
new_data = st._vertex_data->replace_column
(to_name, old_column->get_num_components(),
old_column->get_numeric_type(),
old_column->get_contents(), st._vertex_data->get_usage_hint(),
old_column->get_contents(),
min(_usage_hint, st._vertex_data->get_usage_hint()),
false);
}
@ -343,8 +346,7 @@ set_color(Geom *geom, const Colorf &color) {
new_data = sc._vertex_data->set_color(color);
} else {
new_data = sc._vertex_data->set_color
(color, 1, qpGeomVertexColumn::NT_packed_dabc,
qpGeomVertexColumn::C_color);
(color, 1, qpGeom::NT_packed_dabc, qpGeom::C_color);
}
}
@ -424,8 +426,7 @@ transform_colors(Geom *geom, const LVecBase4f &scale) {
new_data = sc._vertex_data->scale_color(scale);
} else {
new_data = sc._vertex_data->set_color
(scale, 1, qpGeomVertexColumn::NT_packed_dabc,
qpGeomVertexColumn::C_color);
(scale, 1, qpGeom::NT_packed_dabc, qpGeom::C_color);
}
}
@ -634,7 +635,7 @@ collect_vertex_data(GeomNode *node, int collect_bits) {
entry._geom = new_geom;
if ((collect_bits & SceneGraphReducer::CVD_avoid_dynamic) != 0 &&
new_geom->get_vertex_data()->get_usage_hint() < qpGeomUsageHint::UH_static) {
new_geom->get_vertex_data()->get_usage_hint() < qpGeom::UH_static) {
// This one has some dynamic properties. Collect it
// independently of the outside world.
if (dynamic == (GeomTransformer *)NULL) {

View File

@ -21,14 +21,13 @@
#include "pandabase.h"
#include "geom.h"
#include "luse.h"
#include "qpgeom.h"
#include "qpgeomVertexData.h"
class GeomNode;
class RenderState;
class InternalName;
class qpGeom;
///////////////////////////////////////////////////////////////////
// Class : GeomTransformer
@ -52,6 +51,9 @@ public:
GeomTransformer(const GeomTransformer &copy);
~GeomTransformer();
INLINE void set_usage_hint(qpGeom::UsageHint usage_hint);
INLINE qpGeom::UsageHint get_usage_hint() const;
INLINE int get_max_collect_vertices() const;
INLINE void set_max_collect_vertices(int max_collect_vertices);
@ -77,6 +79,7 @@ public:
int collect_vertex_data(GeomNode *node, int collect_bits);
private:
qpGeom::UsageHint _usage_hint;
int _max_collect_vertices;
class qpSourceVertices {
@ -178,7 +181,7 @@ private:
string _name;
CPT(qpGeomVertexFormat) _format;
qpGeomUsageHint::UsageHint _usage_hint;
qpGeom::UsageHint _usage_hint;
};
typedef pmap< NewCollectedKey, PT(qpGeomVertexData) > NewCollectedData;
NewCollectedData _new_collected_data;

View File

@ -35,6 +35,32 @@ INLINE SceneGraphReducer::
~SceneGraphReducer() {
}
////////////////////////////////////////////////////////////////////
// Function: SceneGraphReducer::set_usage_hint
// Access: Published
// Description: Specifies the ceiling UsageHint that will be applied
// to transformed geometry. If the source geometry's
// usage hint is greater (more static) than this, it
// will be reduced to this level. If the source
// geometry's usage hit is less (more dynamic) than
// this, it will be preserved at its current level.
////////////////////////////////////////////////////////////////////
INLINE void SceneGraphReducer::
set_usage_hint(qpGeom::UsageHint usage_hint) {
_transformer.set_usage_hint(usage_hint);
}
////////////////////////////////////////////////////////////////////
// Function: SceneGraphReducer::get_usage_hint
// Access: Published
// Description: Returns the UsageHint that will be applied to
// generated geometry. See set_usage_hint().
////////////////////////////////////////////////////////////////////
INLINE qpGeom::UsageHint SceneGraphReducer::
get_usage_hint() const {
return _transformer.get_usage_hint();
}
////////////////////////////////////////////////////////////////////
// Function: SceneGraphReducer::apply_attribs

View File

@ -83,6 +83,9 @@ PUBLISHED:
CVD_avoid_dynamic = 0x008,
};
INLINE void set_usage_hint(qpGeom::UsageHint usage_hint);
INLINE qpGeom::UsageHint get_usage_hint() const;
INLINE void apply_attribs(PandaNode *node, int attrib_types = ~0);
INLINE void apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs,
int attrib_types, GeomTransformer &transformer);

View File

@ -189,7 +189,7 @@ generate_flat_geom(const LVecBase4f &frame) {
}
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("PGFrame", format, qpGeomUsageHint::UH_static);
("PGFrame", format, qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter color(vdata, InternalName::get_color());
@ -217,7 +217,7 @@ generate_flat_geom(const LVecBase4f &frame) {
texcoord.add_data2f(right, bottom);
}
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_static);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_static);
strip->add_next_vertices(4);
strip->close_primitive();
@ -390,12 +390,12 @@ generate_bevel_geom(const LVecBase4f &frame, bool in) {
if (use_qpgeom) {
CPT(qpGeomVertexFormat) format = qpGeomVertexFormat::get_v3cp();
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("PGFrame", format, qpGeomUsageHint::UH_static);
("PGFrame", format, qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter color(vdata, InternalName::get_color());
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_static);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_static);
// Tristrip 1.
vertex.add_data3f(right, 0.0f, bottom);
vertex.add_data3f(inner_right, 0.0f, inner_bottom);
@ -433,7 +433,7 @@ generate_bevel_geom(const LVecBase4f &frame, bool in) {
strip->add_next_vertices(6);
strip->close_primitive();
strip->set_shade_model(qpGeomPrimitive::SM_flat_last_vertex);
strip->set_shade_model(qpGeom::SM_flat_last_vertex);
PT(qpGeom) geom = new qpGeom;
geom->set_vertex_data(vdata);
@ -656,12 +656,12 @@ generate_groove_geom(const LVecBase4f &frame, bool in) {
if (use_qpgeom) {
CPT(qpGeomVertexFormat) format = qpGeomVertexFormat::get_v3cp();
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("PGFrame", format, qpGeomUsageHint::UH_static);
("PGFrame", format, qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter color(vdata, InternalName::get_color());
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_static);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_static);
// Tristrip 1.
vertex.add_data3f(right, 0.0f, bottom);
vertex.add_data3f(mid_right, 0.0f, mid_bottom);
@ -725,7 +725,7 @@ generate_groove_geom(const LVecBase4f &frame, bool in) {
strip->add_next_vertices(8);
strip->close_primitive();
strip->set_shade_model(qpGeomPrimitive::SM_flat_last_vertex);
strip->set_shade_model(qpGeom::SM_flat_last_vertex);
PT(qpGeom) geom = new qpGeom;
geom->set_vertex_data(vdata);

View File

@ -25,7 +25,7 @@
#include "qpgeomTextGlyph.h"
#include "qpgeomVertexData.h"
#include "qpgeomVertexFormat.h"
#include "qpgeomTristrips.h"
#include "qpgeomTriangles.h"
#include "qpgeomVertexWriter.h"
#include "textureAttrib.h"
#include "transparencyAttrib.h"
@ -122,11 +122,13 @@ make_geom(int bitmap_top, int bitmap_left, float advance, float poly_margin,
float uv_left = (float)(_x - poly_margin) / _page->get_x_size();
float uv_bottom = 1.0f - (float)(_y + poly_margin + tex_y_size) / _page->get_y_size();
float uv_right = (float)(_x + poly_margin + tex_x_size) / _page->get_x_size();
// Create a corresponding tristrip.
// Create a corresponding triangle pair. We use a pair of indexed
// triangles rther than a single triangle strip, to avoid the bad
// vertex duplication behavior with lots of two-triangle strips.
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
(string(), qpGeomVertexFormat::get_v3t2(),
qpGeomUsageHint::UH_static);
qpGeom::UH_static);
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter texcoord(vdata, InternalName::get_texcoord());
@ -140,13 +142,19 @@ make_geom(int bitmap_top, int bitmap_left, float advance, float poly_margin,
texcoord.add_data2f(uv_right, uv_top);
texcoord.add_data2f(uv_right, uv_bottom);
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeomUsageHint::UH_static);
strip->add_consecutive_vertices(0, 4);
strip->close_primitive();
PT(qpGeomTriangles) tris = new qpGeomTriangles(qpGeom::UH_static);
tris->add_vertex(0);
tris->add_vertex(1);
tris->add_vertex(2);
tris->close_primitive();
tris->add_vertex(2);
tris->add_vertex(1);
tris->add_vertex(3);
tris->close_primitive();
PT(qpGeom) geom = new qpGeomTextGlyph(this);
geom->set_vertex_data(vdata);
geom->add_primitive(strip);
geom->add_primitive(tris);
_geom = geom;

View File

@ -17,6 +17,32 @@
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: TextAssembler::set_usage_hint
// Access: Published
// Description: Specifies the UsageHint that will be applied to
// generated geometry. The default is UH_static, which
// is probably the right setting, but if you know the
// TextNode's geometry will have a short lifespan, it
// may be better to set it to UH_stream. See
// geomEnums.h.
////////////////////////////////////////////////////////////////////
INLINE void TextAssembler::
set_usage_hint(qpGeom::UsageHint usage_hint) {
_usage_hint = usage_hint;
}
////////////////////////////////////////////////////////////////////
// Function: TextAssembler::get_usage_hint
// Access: Published
// Description: Returns the UsageHint that will be applied to
// generated geometry. See set_usage_hint().
////////////////////////////////////////////////////////////////////
INLINE qpGeom::UsageHint TextAssembler::
get_usage_hint() const {
return _usage_hint;
}
////////////////////////////////////////////////////////////////////
// Function: TextAssembler::get_ul
// Access: Public

View File

@ -83,7 +83,10 @@ isbreakpoint(unsigned int ch) {
// associated TextProperties.
////////////////////////////////////////////////////////////////////
TextAssembler::
TextAssembler(TextEncoder *encoder) : _encoder(encoder) {
TextAssembler(TextEncoder *encoder) :
_encoder(encoder),
_usage_hint(qpGeom::UH_static)
{
clear();
}
@ -833,14 +836,14 @@ assemble_row(TextAssembler::TextString::const_iterator &si,
float advance = 0.0f;
if (first_glyph != (TextGlyph *)NULL) {
PT(Geom) first_char_geom = first_glyph->get_geom();
PT(Geom) first_char_geom = first_glyph->get_geom(_usage_hint);
if (first_char_geom != (Geom *)NULL) {
placement->add_piece(first_char_geom, first_glyph->get_state());
}
advance = first_glyph->get_advance() * advance_scale;
}
if (second_glyph != (TextGlyph *)NULL) {
PT(Geom) second_char_geom = second_glyph->get_geom();
PT(Geom) second_char_geom = second_glyph->get_geom(_usage_hint);
if (second_char_geom != (Geom *)NULL) {
second_char_geom->transform_vertices(LMatrix4f::translate_mat(advance, 0.0f, 0.0f));
placement->add_piece(second_char_geom, second_glyph->get_state());
@ -1007,7 +1010,7 @@ get_character_glyphs(int character, const TextProperties *properties,
////////////////////////////////////////////////////////////////////
// Function: TextAssembler::tack_on_accent
// Access: Private, Static
// Access: Private
// Description: This is a cheesy attempt to tack on an accent to an
// ASCII letter for which we don't have the appropriate
// already-accented glyph in the font.
@ -1017,7 +1020,7 @@ tack_on_accent(UnicodeLatinMap::AccentType accent_type,
const LPoint3f &min_vert, const LPoint3f &max_vert,
const LPoint3f &centroid,
const TextProperties *properties,
TextAssembler::GlyphPlacement *placement) {
TextAssembler::GlyphPlacement *placement) const {
switch (accent_type) {
case UnicodeLatinMap::AT_grave:
// We use the slash as the grave and acute accents. ASCII does
@ -1150,7 +1153,7 @@ tack_on_accent(UnicodeLatinMap::AccentType accent_type,
////////////////////////////////////////////////////////////////////
// Function: TextAssembler::tack_on_accent
// Access: Private, Static
// Access: Private
// Description: Generates a cheesy accent mark above (or below, etc.)
// the character. Returns true if successful, or false
// if the named accent character doesn't exist in the
@ -1162,14 +1165,14 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position,
const LPoint3f &min_vert, const LPoint3f &max_vert,
const LPoint3f &centroid,
const TextProperties *properties,
TextAssembler::GlyphPlacement *placement) {
TextAssembler::GlyphPlacement *placement) const {
TextFont *font = properties->get_font();
nassertr(font != (TextFont *)NULL, false);
const TextGlyph *accent_glyph;
if (font->get_glyph(accent_mark, accent_glyph) ||
font->get_glyph(toupper(accent_mark), accent_glyph)) {
PT(Geom) accent_geom = accent_glyph->get_geom();
PT(Geom) accent_geom = accent_glyph->get_geom(_usage_hint);
if (accent_geom != (Geom *)NULL) {
LPoint3f min_accent, max_accent;
bool found_any = false;

View File

@ -28,6 +28,7 @@
#include "unicodeLatinMap.h"
#include "geomNode.h"
#include "pointerTo.h"
#include "qpgeom.h"
class TextEncoder;
@ -48,6 +49,9 @@ public:
void clear();
INLINE void set_usage_hint(qpGeom::UsageHint usage_hint);
INLINE qpGeom::UsageHint get_usage_hint() const;
bool set_wtext(const wstring &wtext, const TextProperties &properties,
int max_rows = 0);
INLINE int get_num_rows() const;
@ -162,23 +166,24 @@ private:
int &additional_flags,
float &glyph_scale, float &advance_scale);
static void
void
tack_on_accent(UnicodeLatinMap::AccentType accent_type,
const LPoint3f &min_vert, const LPoint3f &max_vert,
const LPoint3f &centroid,
const TextProperties *properties, GlyphPlacement *placement);
static bool
const TextProperties *properties, GlyphPlacement *placement) const;
bool
tack_on_accent(char accent_mark, CheesyPosition position,
CheesyTransform transform,
const LPoint3f &min_vert, const LPoint3f &max_vert,
const LPoint3f &centroid,
const TextProperties *properties, GlyphPlacement *placement);
const TextProperties *properties, GlyphPlacement *placement) const;
// These are filled in by assemble_paragraph().
LVector2f _ul;
LVector2f _lr;
TextEncoder *_encoder;
qpGeom::UsageHint _usage_hint;
};
#include "textAssembler.I"

View File

@ -73,7 +73,7 @@ operator = (const TextGlyph &copy) {
// Description: Returns a Geom that renders the particular glyph.
////////////////////////////////////////////////////////////////////
INLINE PT(Geom) TextGlyph::
get_geom() const {
get_geom(qpGeom::UsageHint usage_hint) const {
if (_geom == (Geom *)NULL) {
return NULL;
}
@ -82,7 +82,15 @@ get_geom() const {
// to modify its vertices without fear of stomping on other copies;
// it is also critical for the DynamicTextGlyph, which depends on
// this behavior to properly count references to this glyph.
return _geom->make_copy();
PT(Geom) new_geom = _geom->make_copy();
if (new_geom->is_of_type(qpGeom::get_class_type())) {
qpGeom *qpgeom = DCAST(qpGeom, new_geom);
qpgeom->set_usage_hint(usage_hint);
if (qpgeom->get_vertex_data()->get_usage_hint() != usage_hint) {
qpgeom->modify_vertex_data()->set_usage_hint(usage_hint);
}
}
return new_geom;
}
////////////////////////////////////////////////////////////////////

View File

@ -22,8 +22,9 @@
#include "pandabase.h"
#include "renderState.h"
#include "referenceCount.h"
#include "geom.h"
#include "qpgeom.h"
#include "pointerTo.h"
#include "dcast.h"
////////////////////////////////////////////////////////////////////
// Class : TextGlyph
@ -39,7 +40,7 @@ public:
INLINE void operator = (const TextGlyph &copy);
virtual ~TextGlyph();
INLINE PT(Geom) get_geom() const;
INLINE PT(Geom) get_geom(qpGeom::UsageHint usage_hint) const;
INLINE const RenderState *get_state() const;
INLINE float get_advance() const;

View File

@ -1058,6 +1058,34 @@ clear_glyph_shift() {
invalidate_with_measure();
}
////////////////////////////////////////////////////////////////////
// Function: TextNode::set_usage_hint
// Access: Published
// Description: Specifies the UsageHint that will be applied to
// generated geometry. The default is UH_static, which
// is probably the right setting, but if you know the
// TextNode's geometry will have a short lifespan, it
// may be better to set it to UH_stream. See
// geomEnums.h.
////////////////////////////////////////////////////////////////////
INLINE void TextNode::
set_usage_hint(qpGeom::UsageHint usage_hint) {
_assembler.set_usage_hint(usage_hint);
invalidate_no_measure();
}
////////////////////////////////////////////////////////////////////
// Function: TextNode::get_usage_hint
// Access: Published
// Description: Returns the UsageHint that will be applied to
// generated geometry. See set_usage_hint().
////////////////////////////////////////////////////////////////////
INLINE qpGeom::UsageHint TextNode::
get_usage_hint() const {
return _assembler.get_usage_hint();
}
////////////////////////////////////////////////////////////////////
// Function: TextNode::set_text
// Access: Published

View File

@ -607,8 +607,7 @@ make_frame() {
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("text", qpGeomVertexFormat::get_v3(),
qpGeomUsageHint::UH_static);
("text", qpGeomVertexFormat::get_v3(), get_usage_hint());
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
vertex.add_data3f(left, 0.0f, top);
@ -616,7 +615,7 @@ make_frame() {
vertex.add_data3f(right, 0.0f, bottom);
vertex.add_data3f(right, 0.0f, top);
PT(qpGeomLinestrips) frame = new qpGeomLinestrips(qpGeomUsageHint::UH_static);
PT(qpGeomLinestrips) frame = new qpGeomLinestrips(get_usage_hint());
frame->add_consecutive_vertices(0, 4);
frame->add_vertex(0);
frame->close_primitive();
@ -627,7 +626,7 @@ make_frame() {
frame_node->add_geom(geom, state);
if (get_frame_corners()) {
PT(qpGeomPoints) corners = new qpGeomPoints(qpGeomUsageHint::UH_static);
PT(qpGeomPoints) corners = new qpGeomPoints(get_usage_hint());
corners->add_consecutive_vertices(0, 4);
PT(qpGeom) geom2 = new qpGeom;
geom2->set_vertex_data(vdata);
@ -681,8 +680,7 @@ make_card() {
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("text", qpGeomVertexFormat::get_v3t2(),
qpGeomUsageHint::UH_static);
("text", qpGeomVertexFormat::get_v3t2(), get_usage_hint());
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter texcoord(vdata, InternalName::get_texcoord());
@ -696,7 +694,7 @@ make_card() {
texcoord.add_data2f(1.0f, 1.0f);
texcoord.add_data2f(1.0f, 0.0f);
PT(qpGeomTristrips) card = new qpGeomTristrips(qpGeomUsageHint::UH_static);
PT(qpGeomTristrips) card = new qpGeomTristrips(get_usage_hint());
card->add_consecutive_vertices(0, 4);
card->close_primitive();
@ -766,8 +764,7 @@ make_card_with_border() {
if (use_qpgeom) {
PT(qpGeomVertexData) vdata = new qpGeomVertexData
("text", qpGeomVertexFormat::get_v3t2(),
qpGeomUsageHint::UH_static);
("text", qpGeomVertexFormat::get_v3t2(), get_usage_hint());
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
qpGeomVertexWriter texcoord(vdata, InternalName::get_texcoord());
@ -817,7 +814,7 @@ make_card_with_border() {
texcoord.add_data2f(1.0f, _card_border_uv_portion);//15
texcoord.add_data2f(1.0f, 0.0f);//16
PT(qpGeomTristrips) card = new qpGeomTristrips(qpGeomUsageHint::UH_static);
PT(qpGeomTristrips) card = new qpGeomTristrips(get_usage_hint());
// tristrip #1
card->add_consecutive_vertices(0, 8);

View File

@ -28,6 +28,7 @@
#include "textAssembler.h"
#include "pandaNode.h"
#include "luse.h"
#include "qpgeom.h"
////////////////////////////////////////////////////////////////////
// Class : TextNode
@ -169,6 +170,9 @@ PUBLISHED:
INLINE void set_glyph_shift(float glyph_shift);
INLINE void clear_glyph_shift();
INLINE void set_usage_hint(qpGeom::UsageHint usage_hint);
INLINE qpGeom::UsageHint get_usage_hint() const;
// These methods are inherited from TextEncoder, but we override
// here so we can flag the TextNode as dirty when they have been
// change.