animate normals too; rename data_type -> column
This commit is contained in:
parent
6212af0b1b
commit
f37bdbf512
|
|
@ -35,8 +35,8 @@ TypeHandle StandardMunger::_type_handle;
|
|||
StandardMunger::
|
||||
StandardMunger(const GraphicsStateGuardianBase *gsg, const RenderState *state,
|
||||
int num_components,
|
||||
qpGeomVertexDataType::NumericType numeric_type,
|
||||
qpGeomVertexDataType::Contents contents) :
|
||||
qpGeomVertexColumn::NumericType numeric_type,
|
||||
qpGeomVertexColumn::Contents contents) :
|
||||
qpGeomMunger(gsg, state),
|
||||
_num_components(num_components),
|
||||
_numeric_type(numeric_type),
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ class EXPCL_PANDA StandardMunger : public qpGeomMunger {
|
|||
public:
|
||||
StandardMunger(const GraphicsStateGuardianBase *gsg, const RenderState *state,
|
||||
int num_components,
|
||||
qpGeomVertexDataType::NumericType numeric_type,
|
||||
qpGeomVertexDataType::Contents contents);
|
||||
qpGeomVertexColumn::NumericType numeric_type,
|
||||
qpGeomVertexColumn::Contents contents);
|
||||
virtual ~StandardMunger();
|
||||
|
||||
protected:
|
||||
|
|
@ -50,8 +50,8 @@ protected:
|
|||
|
||||
private:
|
||||
int _num_components;
|
||||
qpGeomVertexDataType::NumericType _numeric_type;
|
||||
qpGeomVertexDataType::Contents _contents;
|
||||
qpGeomVertexColumn::NumericType _numeric_type;
|
||||
qpGeomVertexColumn::Contents _contents;
|
||||
CPT(GraphicsStateGuardian) _gsg;
|
||||
CPT(ColorAttrib) _color;
|
||||
CPT(ColorScaleAttrib) _color_scale;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE DXGeomMunger8::
|
||||
DXGeomMunger8(GraphicsStateGuardian *gsg, const RenderState *state) :
|
||||
StandardMunger(gsg, state, 1, qpGeomVertexDataType::NT_packed_dabc,
|
||||
qpGeomVertexDataType::C_color)
|
||||
StandardMunger(gsg, state, 1, qpGeomVertexColumn::NT_packed_dabc,
|
||||
qpGeomVertexColumn::C_color)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,20 +46,20 @@ munge_format_impl(const qpGeomVertexFormat *orig,
|
|||
new_format->set_animation(animation);
|
||||
PT(qpGeomVertexArrayFormat) new_array_format = new qpGeomVertexArrayFormat;
|
||||
|
||||
const qpGeomVertexDataType *vertex_type =
|
||||
orig->get_data_type(InternalName::get_vertex());
|
||||
const qpGeomVertexDataType *normal_type =
|
||||
orig->get_data_type(InternalName::get_normal());
|
||||
const qpGeomVertexDataType *color_type =
|
||||
orig->get_data_type(InternalName::get_color());
|
||||
const qpGeomVertexDataType *texcoord_type =
|
||||
orig->get_data_type(InternalName::get_texcoord());
|
||||
const qpGeomVertexColumn *vertex_type =
|
||||
orig->get_column(InternalName::get_vertex());
|
||||
const qpGeomVertexColumn *normal_type =
|
||||
orig->get_column(InternalName::get_normal());
|
||||
const qpGeomVertexColumn *color_type =
|
||||
orig->get_column(InternalName::get_color());
|
||||
const qpGeomVertexColumn *texcoord_type =
|
||||
orig->get_column(InternalName::get_texcoord());
|
||||
|
||||
if (vertex_type != (const qpGeomVertexDataType *)NULL) {
|
||||
new_array_format->add_data_type
|
||||
(InternalName::get_vertex(), 3, qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point);
|
||||
new_format->remove_data_type(vertex_type->get_name());
|
||||
if (vertex_type != (const qpGeomVertexColumn *)NULL) {
|
||||
new_array_format->add_column
|
||||
(InternalName::get_vertex(), 3, qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point);
|
||||
new_format->remove_column(vertex_type->get_name());
|
||||
} else {
|
||||
// If we don't have a vertex type, not much we can do.
|
||||
return orig;
|
||||
|
|
@ -69,41 +69,41 @@ munge_format_impl(const qpGeomVertexFormat *orig,
|
|||
animation.get_num_transforms() > 0) {
|
||||
// If we want hardware animation, we need to reserve space for the
|
||||
// blend weights.
|
||||
new_array_format->add_data_type
|
||||
new_array_format->add_column
|
||||
(InternalName::get_transform_weight(), animation.get_num_transforms() - 1,
|
||||
qpGeomVertexDataType::NT_float32, qpGeomVertexDataType::C_other);
|
||||
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_other);
|
||||
|
||||
if (animation.get_indexed_transforms()) {
|
||||
// Also, if we'll be indexing into the transfom palette, reserve
|
||||
// space for the index.
|
||||
new_array_format->add_data_type
|
||||
new_array_format->add_column
|
||||
(InternalName::get_transform_index(), 1,
|
||||
qpGeomVertexDataType::NT_packed_dcba, qpGeomVertexDataType::C_index);
|
||||
qpGeomVertexColumn::NT_packed_dcba, qpGeomVertexColumn::C_index);
|
||||
}
|
||||
}
|
||||
|
||||
if (normal_type != (const qpGeomVertexDataType *)NULL) {
|
||||
new_array_format->add_data_type
|
||||
(InternalName::get_normal(), 3, qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_vector);
|
||||
new_format->remove_data_type(normal_type->get_name());
|
||||
if (normal_type != (const qpGeomVertexColumn *)NULL) {
|
||||
new_array_format->add_column
|
||||
(InternalName::get_normal(), 3, qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_vector);
|
||||
new_format->remove_column(normal_type->get_name());
|
||||
}
|
||||
|
||||
if (color_type != (const qpGeomVertexDataType *)NULL) {
|
||||
new_array_format->add_data_type
|
||||
(InternalName::get_color(), 1, qpGeomVertexDataType::NT_packed_dabc,
|
||||
qpGeomVertexDataType::C_color);
|
||||
new_format->remove_data_type(color_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);
|
||||
new_format->remove_column(color_type->get_name());
|
||||
}
|
||||
|
||||
// To support multitexture, we will need to add all of the relevant
|
||||
// texcoord types, and in the correct order (or at least in a known
|
||||
// order). For now, we just add the default texcoords only.
|
||||
if (texcoord_type != (const qpGeomVertexDataType *)NULL) {
|
||||
new_array_format->add_data_type
|
||||
if (texcoord_type != (const qpGeomVertexColumn *)NULL) {
|
||||
new_array_format->add_column
|
||||
(InternalName::get_texcoord(), texcoord_type->get_num_values(),
|
||||
qpGeomVertexDataType::NT_float32, qpGeomVertexDataType::C_texcoord);
|
||||
new_format->remove_data_type(texcoord_type->get_name());
|
||||
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_texcoord);
|
||||
new_format->remove_column(texcoord_type->get_name());
|
||||
}
|
||||
|
||||
if (new_array_format->is_data_subset_of(*orig->get_array(0))) {
|
||||
|
|
|
|||
|
|
@ -41,24 +41,24 @@ DXVertexBufferContext8(qpGeomVertexArrayData *data) :
|
|||
// We have to start with the vertex data, and work up from there in
|
||||
// order, since that's the way the FVF is defined.
|
||||
int n = 0;
|
||||
int num_data_types = array_format->get_num_data_types();
|
||||
int num_columns = array_format->get_num_columns();
|
||||
|
||||
_fvf = 0;
|
||||
|
||||
if (n < num_data_types &&
|
||||
array_format->get_data_type(n)->get_name() == InternalName::get_vertex()) {
|
||||
if (n < num_columns &&
|
||||
array_format->get_column(n)->get_name() == InternalName::get_vertex()) {
|
||||
++n;
|
||||
|
||||
int num_blend_values = 0;
|
||||
|
||||
if (n < num_data_types &&
|
||||
array_format->get_data_type(n)->get_name() == InternalName::get_transform_weight()) {
|
||||
if (n < num_columns &&
|
||||
array_format->get_column(n)->get_name() == InternalName::get_transform_weight()) {
|
||||
// We have hardware vertex animation.
|
||||
num_blend_values = array_format->get_data_type(n)->get_num_values();
|
||||
num_blend_values = array_format->get_column(n)->get_num_values();
|
||||
++n;
|
||||
|
||||
if (n < num_data_types &&
|
||||
array_format->get_data_type(n)->get_name() == InternalName::get_transform_index()) {
|
||||
if (n < num_columns &&
|
||||
array_format->get_column(n)->get_name() == InternalName::get_transform_index()) {
|
||||
// Furthermore, it's indexed vertex animation.
|
||||
_fvf |= D3DFVF_LASTBETA_UBYTE4;
|
||||
++num_blend_values;
|
||||
|
|
@ -93,23 +93,23 @@ DXVertexBufferContext8(qpGeomVertexArrayData *data) :
|
|||
}
|
||||
}
|
||||
|
||||
if (n < num_data_types &&
|
||||
array_format->get_data_type(n)->get_name() == InternalName::get_normal()) {
|
||||
if (n < num_columns &&
|
||||
array_format->get_column(n)->get_name() == InternalName::get_normal()) {
|
||||
_fvf |= D3DFVF_NORMAL;
|
||||
++n;
|
||||
}
|
||||
if (n < num_data_types &&
|
||||
array_format->get_data_type(n)->get_name() == InternalName::get_color()) {
|
||||
if (n < num_columns &&
|
||||
array_format->get_column(n)->get_name() == InternalName::get_color()) {
|
||||
_fvf |= D3DFVF_DIFFUSE;
|
||||
++n;
|
||||
}
|
||||
|
||||
// For multitexture support, we will need to look for all of the
|
||||
// texcoord names and enable them in order.
|
||||
if (n < num_data_types &&
|
||||
array_format->get_data_type(n)->get_name() == InternalName::get_texcoord()) {
|
||||
const qpGeomVertexDataType *data_type = array_format->get_data_type(n);
|
||||
switch (data_type->get_num_values()) {
|
||||
if (n < num_columns &&
|
||||
array_format->get_column(n)->get_name() == InternalName::get_texcoord()) {
|
||||
const qpGeomVertexColumn *column = array_format->get_column(n);
|
||||
switch (column->get_num_values()) {
|
||||
case 1:
|
||||
_fvf |= D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE1(0);
|
||||
++n;
|
||||
|
|
|
|||
|
|
@ -1919,20 +1919,20 @@ make_vertex_data(const EggRenderState *render_state,
|
|||
|
||||
// Decide on the format for the vertices.
|
||||
PT(qpGeomVertexArrayFormat) array_format = new qpGeomVertexArrayFormat;
|
||||
array_format->add_data_type
|
||||
array_format->add_column
|
||||
(InternalName::get_vertex(), vertex_pool->get_num_dimensions(),
|
||||
qpGeomVertexDataType::NT_float32, qpGeomVertexDataType::C_point);
|
||||
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_point);
|
||||
|
||||
if (vertex_pool->has_normals()) {
|
||||
array_format->add_data_type
|
||||
array_format->add_column
|
||||
(InternalName::get_normal(), 3,
|
||||
qpGeomVertexDataType::NT_float32, qpGeomVertexDataType::C_vector);
|
||||
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_vector);
|
||||
}
|
||||
|
||||
if (vertex_pool->has_colors()) {
|
||||
array_format->add_data_type
|
||||
array_format->add_column
|
||||
(InternalName::get_color(), 1,
|
||||
qpGeomVertexDataType::NT_packed_dabc, qpGeomVertexDataType::C_color);
|
||||
qpGeomVertexColumn::NT_packed_dabc, qpGeomVertexColumn::C_color);
|
||||
}
|
||||
|
||||
vector_string uv_names;
|
||||
|
|
@ -1944,9 +1944,9 @@ make_vertex_data(const EggRenderState *render_state,
|
|||
name = string();
|
||||
}
|
||||
PT(InternalName) iname = InternalName::get_texcoord_name(name);
|
||||
array_format->add_data_type
|
||||
array_format->add_column
|
||||
(iname, 2,
|
||||
qpGeomVertexDataType::NT_float32, qpGeomVertexDataType::C_texcoord);
|
||||
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_texcoord);
|
||||
}
|
||||
|
||||
PT(qpGeomVertexFormat) temp_format = new qpGeomVertexFormat(array_format);
|
||||
|
|
@ -1970,9 +1970,9 @@ make_vertex_data(const EggRenderState *render_state,
|
|||
blend_palette = new TransformBlendPalette;
|
||||
|
||||
PT(qpGeomVertexArrayFormat) anim_array_format = new qpGeomVertexArrayFormat;
|
||||
anim_array_format->add_data_type
|
||||
anim_array_format->add_column
|
||||
(InternalName::get_transform_blend(), 1,
|
||||
qpGeomVertexDataType::NT_uint16, qpGeomVertexDataType::C_index);
|
||||
qpGeomVertexColumn::NT_uint16, qpGeomVertexColumn::C_index);
|
||||
temp_format->add_array(anim_array_format);
|
||||
|
||||
pset<string> slider_names;
|
||||
|
|
@ -2060,7 +2060,7 @@ make_vertex_data(const EggRenderState *render_state,
|
|||
EggVertex *vertex = (*vi);
|
||||
gvw.set_vertex(vertex->get_index());
|
||||
|
||||
gvw.set_data_type(InternalName::get_vertex());
|
||||
gvw.set_column(InternalName::get_vertex());
|
||||
gvw.add_data4f(LCAST(float, vertex->get_pos4() * transform));
|
||||
|
||||
if (is_dynamic) {
|
||||
|
|
@ -2069,13 +2069,13 @@ make_vertex_data(const EggRenderState *render_state,
|
|||
const EggMorphVertex &morph = (*mvi);
|
||||
CPT(InternalName) delta_name =
|
||||
InternalName::get_morph(InternalName::get_vertex(), morph.get_name());
|
||||
gvw.set_data_type(delta_name);
|
||||
gvw.set_column(delta_name);
|
||||
gvw.add_data3f(LCAST(float, morph.get_offset() * transform));
|
||||
}
|
||||
}
|
||||
|
||||
if (vertex->has_normal()) {
|
||||
gvw.set_data_type(InternalName::get_normal());
|
||||
gvw.set_column(InternalName::get_normal());
|
||||
gvw.add_data3f(LCAST(float, vertex->get_normal() * transform));
|
||||
|
||||
if (is_dynamic) {
|
||||
|
|
@ -2084,14 +2084,14 @@ make_vertex_data(const EggRenderState *render_state,
|
|||
const EggMorphNormal &morph = (*mni);
|
||||
CPT(InternalName) delta_name =
|
||||
InternalName::get_morph(InternalName::get_normal(), morph.get_name());
|
||||
gvw.set_data_type(delta_name);
|
||||
gvw.set_column(delta_name);
|
||||
gvw.add_data3f(LCAST(float, morph.get_offset() * transform));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vertex->has_color()) {
|
||||
gvw.set_data_type(InternalName::get_color());
|
||||
gvw.set_column(InternalName::get_color());
|
||||
gvw.add_data4f(vertex->get_color());
|
||||
|
||||
if (is_dynamic) {
|
||||
|
|
@ -2100,7 +2100,7 @@ make_vertex_data(const EggRenderState *render_state,
|
|||
const EggMorphColor &morph = (*mci);
|
||||
CPT(InternalName) delta_name =
|
||||
InternalName::get_morph(InternalName::get_color(), morph.get_name());
|
||||
gvw.set_data_type(delta_name);
|
||||
gvw.set_column(delta_name);
|
||||
gvw.add_data4f(morph.get_offset());
|
||||
}
|
||||
}
|
||||
|
|
@ -2117,7 +2117,7 @@ make_vertex_data(const EggRenderState *render_state,
|
|||
name = string();
|
||||
}
|
||||
PT(InternalName) iname = InternalName::get_texcoord_name(name);
|
||||
gvw.set_data_type(iname);
|
||||
gvw.set_column(iname);
|
||||
|
||||
BakeInUVs::const_iterator buv = render_state->_bake_in_uvs.find(iname);
|
||||
if (buv != render_state->_bake_in_uvs.end()) {
|
||||
|
|
@ -2133,7 +2133,7 @@ make_vertex_data(const EggRenderState *render_state,
|
|||
const EggMorphTexCoord &morph = (*mti);
|
||||
CPT(InternalName) delta_name =
|
||||
InternalName::get_morph(iname, morph.get_name());
|
||||
gvw.set_data_type(delta_name);
|
||||
gvw.set_column(delta_name);
|
||||
TexCoordd duv = morph.get_offset();
|
||||
if (buv != render_state->_bake_in_uvs.end()) {
|
||||
TexCoordd new_uv = orig_uv + duv;
|
||||
|
|
@ -2160,7 +2160,7 @@ make_vertex_data(const EggRenderState *render_state,
|
|||
blend.normalize_weights();
|
||||
|
||||
int palette_index = blend_palette->add_blend(blend);
|
||||
gvw.set_data_type(InternalName::get_transform_blend());
|
||||
gvw.set_column(InternalName::get_transform_blend());
|
||||
gvw.set_data1i(palette_index);
|
||||
}
|
||||
}
|
||||
|
|
@ -2180,15 +2180,15 @@ make_vertex_data(const EggRenderState *render_state,
|
|||
void EggLoader::
|
||||
record_morph(qpGeomVertexArrayFormat *array_format,
|
||||
CharacterMaker *character_maker,
|
||||
const string &morph_name, InternalName *data_type_name,
|
||||
const string &morph_name, InternalName *column_name,
|
||||
int num_components) {
|
||||
CPT(InternalName) slider_name = InternalName::make(morph_name);
|
||||
CPT(InternalName) delta_name =
|
||||
InternalName::get_morph(data_type_name, morph_name);
|
||||
if (!array_format->has_data_type(delta_name)) {
|
||||
array_format->add_data_type
|
||||
InternalName::get_morph(column_name, morph_name);
|
||||
if (!array_format->has_column(delta_name)) {
|
||||
array_format->add_column
|
||||
(delta_name, num_components,
|
||||
qpGeomVertexDataType::NT_float32, qpGeomVertexDataType::C_morph_delta);
|
||||
qpGeomVertexColumn::NT_float32, qpGeomVertexColumn::C_morph_delta);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ private:
|
|||
void record_morph
|
||||
(qpGeomVertexArrayFormat *array_format,
|
||||
CharacterMaker *character_maker, const string &morph_name,
|
||||
InternalName *data_type_name, int num_components);
|
||||
InternalName *column_name, int num_components);
|
||||
|
||||
void make_primitive(const EggRenderState *render_state,
|
||||
EggPrimitive *egg_prim, Primitives &primitives);
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE CLP(GeomMunger)::
|
||||
CLP(GeomMunger)(GraphicsStateGuardian *gsg, const RenderState *state) :
|
||||
StandardMunger(gsg, state, 4, qpGeomVertexDataType::NT_uint8,
|
||||
qpGeomVertexDataType::C_color),
|
||||
StandardMunger(gsg, state, 4, qpGeomVertexColumn::NT_uint8,
|
||||
qpGeomVertexColumn::C_color),
|
||||
_gsg(gsg),
|
||||
_texture(state->get_texture()),
|
||||
_tex_gen(state->get_tex_gen())
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ munge_format_impl(const qpGeomVertexFormat *orig,
|
|||
PT(qpGeomVertexFormat) new_format = new qpGeomVertexFormat(*orig);
|
||||
new_format->set_animation(animation);
|
||||
|
||||
const qpGeomVertexDataType *color_type =
|
||||
orig->get_data_type(InternalName::get_color());
|
||||
if (color_type != (qpGeomVertexDataType *)NULL &&
|
||||
color_type->get_numeric_type() == qpGeomVertexDataType::NT_packed_dabc) {
|
||||
const qpGeomVertexColumn *color_type =
|
||||
orig->get_column(InternalName::get_color());
|
||||
if (color_type != (qpGeomVertexColumn *)NULL &&
|
||||
color_type->get_numeric_type() == qpGeomVertexColumn::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,9 +60,9 @@ munge_format_impl(const qpGeomVertexFormat *orig,
|
|||
PT(qpGeomVertexArrayFormat) new_array_format = new_format->modify_array(color_array);
|
||||
|
||||
// Replace the existing color format with the new format.
|
||||
new_array_format->add_data_type
|
||||
(InternalName::get_color(), 4, qpGeomVertexDataType::NT_uint8,
|
||||
qpGeomVertexDataType::C_color, color_type->get_start());
|
||||
new_array_format->add_column
|
||||
(InternalName::get_color(), 4, qpGeomVertexColumn::NT_uint8,
|
||||
qpGeomVertexColumn::C_color, color_type->get_start());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -70,11 +70,11 @@ munge_format_impl(const qpGeomVertexFormat *orig,
|
|||
// Split out the interleaved array into n parallel arrays.
|
||||
CPT(qpGeomVertexFormat) format = new_format;
|
||||
new_format = new qpGeomVertexFormat;
|
||||
for (int i = 0; i < format->get_num_data_types(); i++) {
|
||||
const qpGeomVertexDataType *data_type = format->get_data_type(i);
|
||||
for (int i = 0; i < format->get_num_columns(); i++) {
|
||||
const qpGeomVertexColumn *column = format->get_column(i);
|
||||
PT(qpGeomVertexArrayFormat) new_array_format = new qpGeomVertexArrayFormat;
|
||||
new_array_format->add_data_type(data_type->get_name(), data_type->get_num_components(),
|
||||
data_type->get_numeric_type());
|
||||
new_array_format->add_column(column->get_name(), column->get_num_components(),
|
||||
column->get_numeric_type());
|
||||
new_format->add_array(new_array_format);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2135,7 +2135,7 @@ begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
|
|||
|
||||
const qpGeomVertexArrayData *array_data;
|
||||
int num_values;
|
||||
qpGeomVertexDataType::NumericType numeric_type;
|
||||
qpGeomVertexColumn::NumericType numeric_type;
|
||||
int start;
|
||||
int stride;
|
||||
|
||||
|
|
@ -2162,7 +2162,7 @@ begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
|
|||
if (_vertex_data->get_array_info(InternalName::get_color(),
|
||||
array_data, num_values, numeric_type,
|
||||
start, stride) &&
|
||||
numeric_type != qpGeomVertexDataType::NT_packed_dabc) {
|
||||
numeric_type != qpGeomVertexColumn::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);
|
||||
|
|
@ -4430,17 +4430,17 @@ upload_texture_image(CLP(TextureContext) *gtc,
|
|||
// to GL's.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
GLenum CLP(GraphicsStateGuardian)::
|
||||
get_numeric_type(qpGeomVertexDataType::NumericType numeric_type) {
|
||||
get_numeric_type(qpGeomVertexColumn::NumericType numeric_type) {
|
||||
switch (numeric_type) {
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
return GL_UNSIGNED_SHORT;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
return GL_UNSIGNED_BYTE;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
return GL_FLOAT;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "graphicsStateGuardian.h"
|
||||
#include "geomprimitives.h"
|
||||
#include "qpgeomVertexDataType.h"
|
||||
#include "qpgeomVertexColumn.h"
|
||||
#include "texture.h"
|
||||
#include "displayRegion.h"
|
||||
#include "material.h"
|
||||
|
|
@ -241,7 +241,7 @@ protected:
|
|||
GLint external_format, GLenum component_type,
|
||||
const unsigned char *image);
|
||||
|
||||
static GLenum get_numeric_type(qpGeomVertexDataType::NumericType numeric_type);
|
||||
static GLenum get_numeric_type(qpGeomVertexColumn::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);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
qpgeomCacheManager.h qpgeomCacheManager.I \
|
||||
qpgeomVertexAnimationSpec.h qpgeomVertexAnimationSpec.I \
|
||||
qpgeomVertexData.h qpgeomVertexData.I \
|
||||
qpgeomVertexDataType.h qpgeomVertexDataType.I \
|
||||
qpgeomVertexColumn.h qpgeomVertexColumn.I \
|
||||
qpgeomVertexFormat.h qpgeomVertexFormat.I \
|
||||
qpgeomVertexReader.h qpgeomVertexReader.I \
|
||||
qpgeomVertexRewriter.h qpgeomVertexRewriter.I \
|
||||
|
|
@ -85,7 +85,7 @@
|
|||
qpgeomCacheManager.cxx \
|
||||
qpgeomVertexAnimationSpec.cxx \
|
||||
qpgeomVertexData.cxx \
|
||||
qpgeomVertexDataType.cxx \
|
||||
qpgeomVertexColumn.cxx \
|
||||
qpgeomVertexFormat.cxx \
|
||||
qpgeomVertexReader.cxx \
|
||||
qpgeomVertexRewriter.cxx \
|
||||
|
|
@ -135,7 +135,7 @@
|
|||
qpgeomCacheManager.h qpgeomCacheManager.I \
|
||||
qpgeomVertexAnimationSpec.h qpgeomVertexAnimationSpec.I \
|
||||
qpgeomVertexData.h qpgeomVertexData.I \
|
||||
qpgeomVertexDataType.h qpgeomVertexDataType.I \
|
||||
qpgeomVertexColumn.h qpgeomVertexColumn.I \
|
||||
qpgeomVertexFormat.h qpgeomVertexFormat.I \
|
||||
qpgeomVertexReader.h qpgeomVertexReader.I \
|
||||
qpgeomVertexRewriter.h qpgeomVertexRewriter.I \
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#include "qpgeomCacheManager.cxx"
|
||||
#include "qpgeomVertexAnimationSpec.cxx"
|
||||
#include "qpgeomVertexData.cxx"
|
||||
#include "qpgeomVertexDataType.cxx"
|
||||
#include "qpgeomVertexColumn.cxx"
|
||||
#include "qpgeomVertexFormat.cxx"
|
||||
#include "qpgeomVertexReader.cxx"
|
||||
#include "qpgeomVertexRewriter.cxx"
|
||||
|
|
|
|||
|
|
@ -225,9 +225,9 @@ get_transform_index() {
|
|||
// indicated data type name, using the named slider.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PT(InternalName) InternalName::
|
||||
get_morph(InternalName *data_type, const string &slider) {
|
||||
// Returns data_type.morph.slider
|
||||
return data_type->append("morph")->append(slider);
|
||||
get_morph(InternalName *column, const string &slider) {
|
||||
// Returns column.morph.slider
|
||||
return column->append("morph")->append(slider);
|
||||
}
|
||||
|
||||
INLINE ostream &
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ PUBLISHED:
|
|||
INLINE static PT(InternalName) get_transform_blend();
|
||||
INLINE static PT(InternalName) get_transform_weight();
|
||||
INLINE static PT(InternalName) get_transform_index();
|
||||
INLINE static PT(InternalName) get_morph(InternalName *data_type, const string &slider);
|
||||
INLINE static PT(InternalName) get_morph(InternalName *column, const string &slider);
|
||||
|
||||
private:
|
||||
PT(InternalName) _parent;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#include "qpgeom.h"
|
||||
#include "qpgeomVertexData.h"
|
||||
#include "qpgeomVertexArrayFormat.h"
|
||||
#include "qpgeomVertexDataType.h"
|
||||
#include "qpgeomVertexColumn.h"
|
||||
#include "qpgeomVertexReader.h"
|
||||
#include "preparedGraphicsObjects.h"
|
||||
#include "internalName.h"
|
||||
|
|
@ -675,7 +675,7 @@ calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point,
|
|||
const qpGeomVertexData *vertex_data,
|
||||
bool got_mat, const LMatrix4f &mat) const {
|
||||
qpGeomVertexReader reader(vertex_data, InternalName::get_vertex());
|
||||
if (!reader.has_data_type()) {
|
||||
if (!reader.has_column()) {
|
||||
// No vertex data.
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,8 +41,11 @@ class GraphicsStateGuardianBase;
|
|||
// structure. Many GeomVertexData structures will only
|
||||
// define one array, with all data elements interleaved
|
||||
// (DirectX 8.0 and before insisted on this format);
|
||||
// some will define multiple arrays. DirectX calls this
|
||||
// concept a "stream".
|
||||
// some will define multiple arrays.
|
||||
//
|
||||
// DirectX calls this concept of one array a "stream".
|
||||
// It also closely correlates with the concept of a
|
||||
// vertex buffer.
|
||||
//
|
||||
// This object is just a block of data. See
|
||||
// GeomVertexData for the organizing structure.
|
||||
|
|
|
|||
|
|
@ -80,48 +80,48 @@ get_pad_to() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexArrayFormat::get_num_data_types
|
||||
// Function: qpGeomVertexArrayFormat::get_num_columns
|
||||
// Access: Published
|
||||
// Description: Returns the number of different data types in the
|
||||
// specification.
|
||||
// Description: Returns the number of different columns in the
|
||||
// array.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexArrayFormat::
|
||||
get_num_data_types() const {
|
||||
return (int)_data_types.size();
|
||||
get_num_columns() const {
|
||||
return (int)_columns.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexArrayFormat::get_data_type
|
||||
// Function: qpGeomVertexArrayFormat::get_column
|
||||
// Access: Published
|
||||
// Description: Returns the ith data types of the specification.
|
||||
// Description: Returns the ith column of the array.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const qpGeomVertexDataType *qpGeomVertexArrayFormat::
|
||||
get_data_type(int i) const {
|
||||
nassertr(i >= 0 && i < (int)_data_types.size(), NULL);
|
||||
consider_sort_data_types();
|
||||
return _data_types[i];
|
||||
INLINE const qpGeomVertexColumn *qpGeomVertexArrayFormat::
|
||||
get_column(int i) const {
|
||||
nassertr(i >= 0 && i < (int)_columns.size(), NULL);
|
||||
consider_sort_columns();
|
||||
return _columns[i];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexArrayFormat::has_data_type
|
||||
// Function: qpGeomVertexArrayFormat::has_column
|
||||
// Access: Published
|
||||
// Description: Returns true if the format has the named data type,
|
||||
// Description: Returns true if the array has the named column,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexArrayFormat::
|
||||
has_data_type(const InternalName *name) const {
|
||||
return (get_data_type(name) != (qpGeomVertexDataType *)NULL);
|
||||
has_column(const InternalName *name) const {
|
||||
return (get_column(name) != (qpGeomVertexColumn *)NULL);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexArrayFormat::consider_sort_data_types
|
||||
// Function: qpGeomVertexArrayFormat::consider_sort_columns
|
||||
// Access: Private
|
||||
// Description: Resorts the _data_types vector if necessary.
|
||||
// Description: Resorts the _columns vector if necessary.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexArrayFormat::
|
||||
consider_sort_data_types() const {
|
||||
if (_data_types_unsorted) {
|
||||
((qpGeomVertexArrayFormat *)this)->sort_data_types();
|
||||
consider_sort_columns() const {
|
||||
if (_columns_unsorted) {
|
||||
((qpGeomVertexArrayFormat *)this)->sort_columns();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "qpgeomVertexFormat.h"
|
||||
#include "qpgeomVertexDataType.h"
|
||||
#include "qpgeomVertexColumn.h"
|
||||
#include "qpgeomVertexData.h"
|
||||
#include "qpgeomVertexReader.h"
|
||||
#include "indent.h"
|
||||
|
|
@ -38,7 +38,7 @@ qpGeomVertexArrayFormat() :
|
|||
_stride(0),
|
||||
_total_bytes(0),
|
||||
_pad_to(1),
|
||||
_data_types_unsorted(false)
|
||||
_columns_unsorted(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -49,15 +49,15 @@ qpGeomVertexArrayFormat() :
|
|||
////////////////////////////////////////////////////////////////////
|
||||
qpGeomVertexArrayFormat::
|
||||
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
|
||||
qpGeomVertexDataType::NumericType numeric_type0,
|
||||
qpGeomVertexDataType::Contents contents0) :
|
||||
qpGeomVertexColumn::NumericType numeric_type0,
|
||||
qpGeomVertexColumn::Contents contents0) :
|
||||
_is_registered(false),
|
||||
_stride(0),
|
||||
_total_bytes(0),
|
||||
_pad_to(1),
|
||||
_data_types_unsorted(false)
|
||||
_columns_unsorted(false)
|
||||
{
|
||||
add_data_type(name0, num_components0, numeric_type0, contents0);
|
||||
add_column(name0, num_components0, numeric_type0, contents0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -67,19 +67,19 @@ qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
|
|||
////////////////////////////////////////////////////////////////////
|
||||
qpGeomVertexArrayFormat::
|
||||
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
|
||||
qpGeomVertexDataType::NumericType numeric_type0,
|
||||
qpGeomVertexDataType::Contents contents0,
|
||||
qpGeomVertexColumn::NumericType numeric_type0,
|
||||
qpGeomVertexColumn::Contents contents0,
|
||||
const InternalName *name1, int num_components1,
|
||||
qpGeomVertexDataType::NumericType numeric_type1,
|
||||
qpGeomVertexDataType::Contents contents1) :
|
||||
qpGeomVertexColumn::NumericType numeric_type1,
|
||||
qpGeomVertexColumn::Contents contents1) :
|
||||
_is_registered(false),
|
||||
_stride(0),
|
||||
_total_bytes(0),
|
||||
_pad_to(1),
|
||||
_data_types_unsorted(false)
|
||||
_columns_unsorted(false)
|
||||
{
|
||||
add_data_type(name0, num_components0, numeric_type0, contents0);
|
||||
add_data_type(name1, num_components1, numeric_type1, contents1);
|
||||
add_column(name0, num_components0, numeric_type0, contents0);
|
||||
add_column(name1, num_components1, numeric_type1, contents1);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -89,23 +89,23 @@ qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
|
|||
////////////////////////////////////////////////////////////////////
|
||||
qpGeomVertexArrayFormat::
|
||||
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
|
||||
qpGeomVertexDataType::NumericType numeric_type0,
|
||||
qpGeomVertexDataType::Contents contents0,
|
||||
qpGeomVertexColumn::NumericType numeric_type0,
|
||||
qpGeomVertexColumn::Contents contents0,
|
||||
const InternalName *name1, int num_components1,
|
||||
qpGeomVertexDataType::NumericType numeric_type1,
|
||||
qpGeomVertexDataType::Contents contents1,
|
||||
qpGeomVertexColumn::NumericType numeric_type1,
|
||||
qpGeomVertexColumn::Contents contents1,
|
||||
const InternalName *name2, int num_components2,
|
||||
qpGeomVertexDataType::NumericType numeric_type2,
|
||||
qpGeomVertexDataType::Contents contents2) :
|
||||
qpGeomVertexColumn::NumericType numeric_type2,
|
||||
qpGeomVertexColumn::Contents contents2) :
|
||||
_is_registered(false),
|
||||
_stride(0),
|
||||
_total_bytes(0),
|
||||
_pad_to(1),
|
||||
_data_types_unsorted(false)
|
||||
_columns_unsorted(false)
|
||||
{
|
||||
add_data_type(name0, num_components0, numeric_type0, contents0);
|
||||
add_data_type(name1, num_components1, numeric_type1, contents1);
|
||||
add_data_type(name2, num_components2, numeric_type2, contents2);
|
||||
add_column(name0, num_components0, numeric_type0, contents0);
|
||||
add_column(name1, num_components1, numeric_type1, contents1);
|
||||
add_column(name2, num_components2, numeric_type2, contents2);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -115,27 +115,27 @@ qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
|
|||
////////////////////////////////////////////////////////////////////
|
||||
qpGeomVertexArrayFormat::
|
||||
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
|
||||
qpGeomVertexDataType::NumericType numeric_type0,
|
||||
qpGeomVertexDataType::Contents contents0,
|
||||
qpGeomVertexColumn::NumericType numeric_type0,
|
||||
qpGeomVertexColumn::Contents contents0,
|
||||
const InternalName *name1, int num_components1,
|
||||
qpGeomVertexDataType::NumericType numeric_type1,
|
||||
qpGeomVertexDataType::Contents contents1,
|
||||
qpGeomVertexColumn::NumericType numeric_type1,
|
||||
qpGeomVertexColumn::Contents contents1,
|
||||
const InternalName *name2, int num_components2,
|
||||
qpGeomVertexDataType::NumericType numeric_type2,
|
||||
qpGeomVertexDataType::Contents contents2,
|
||||
qpGeomVertexColumn::NumericType numeric_type2,
|
||||
qpGeomVertexColumn::Contents contents2,
|
||||
const InternalName *name3, int num_components3,
|
||||
qpGeomVertexDataType::NumericType numeric_type3,
|
||||
qpGeomVertexDataType::Contents contents3) :
|
||||
qpGeomVertexColumn::NumericType numeric_type3,
|
||||
qpGeomVertexColumn::Contents contents3) :
|
||||
_is_registered(false),
|
||||
_stride(0),
|
||||
_total_bytes(0),
|
||||
_pad_to(1),
|
||||
_data_types_unsorted(false)
|
||||
_columns_unsorted(false)
|
||||
{
|
||||
add_data_type(name0, num_components0, numeric_type0, contents0);
|
||||
add_data_type(name1, num_components1, numeric_type1, contents1);
|
||||
add_data_type(name2, num_components2, numeric_type2, contents2);
|
||||
add_data_type(name3, num_components3, numeric_type3, contents3);
|
||||
add_column(name0, num_components0, numeric_type0, contents0);
|
||||
add_column(name1, num_components1, numeric_type1, contents1);
|
||||
add_column(name2, num_components2, numeric_type2, contents2);
|
||||
add_column(name3, num_components3, numeric_type3, contents3);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -149,11 +149,11 @@ qpGeomVertexArrayFormat(const qpGeomVertexArrayFormat ©) :
|
|||
_stride(copy._stride),
|
||||
_total_bytes(copy._total_bytes),
|
||||
_pad_to(copy._pad_to),
|
||||
_data_types_unsorted(copy._data_types_unsorted)
|
||||
_columns_unsorted(copy._columns_unsorted)
|
||||
{
|
||||
DataTypes::const_iterator dti;
|
||||
for (dti = copy._data_types.begin(); dti != copy._data_types.end(); ++dti) {
|
||||
add_data_type(*(*dti));
|
||||
for (dti = copy._columns.begin(); dti != copy._columns.end(); ++dti) {
|
||||
add_column(*(*dti));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -169,12 +169,12 @@ operator = (const qpGeomVertexArrayFormat ©) {
|
|||
_total_bytes = copy._total_bytes;
|
||||
_pad_to = copy._pad_to;
|
||||
|
||||
_data_types.clear();
|
||||
_data_types_by_name.clear();
|
||||
_data_types_unsorted = false;
|
||||
_columns.clear();
|
||||
_columns_by_name.clear();
|
||||
_columns_unsorted = false;
|
||||
DataTypes::const_iterator dti;
|
||||
for (dti = copy._data_types.begin(); dti != copy._data_types.end(); ++dti) {
|
||||
add_data_type(*(*dti));
|
||||
for (dti = copy._columns.begin(); dti != copy._columns.end(); ++dti) {
|
||||
add_column(*(*dti));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,15 +186,15 @@ operator = (const qpGeomVertexArrayFormat ©) {
|
|||
qpGeomVertexArrayFormat::
|
||||
~qpGeomVertexArrayFormat() {
|
||||
DataTypes::iterator dti;
|
||||
for (dti = _data_types.begin(); dti != _data_types.end(); ++dti) {
|
||||
for (dti = _columns.begin(); dti != _columns.end(); ++dti) {
|
||||
delete (*dti);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexArrayFormat::add_data_type
|
||||
// Function: qpGeomVertexArrayFormat::add_column
|
||||
// Access: Published
|
||||
// Description: Adds a new data type to the specification. This is a
|
||||
// Description: Adds a new column to the specification. This is a
|
||||
// table of per-vertex floating-point numbers such as
|
||||
// "vertex" or "normal"; you must specify where in each
|
||||
// record the table starts, and how many components
|
||||
|
|
@ -204,32 +204,32 @@ qpGeomVertexArrayFormat::
|
|||
// type.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int qpGeomVertexArrayFormat::
|
||||
add_data_type(const InternalName *name, int num_components,
|
||||
qpGeomVertexDataType::NumericType numeric_type,
|
||||
qpGeomVertexDataType::Contents contents, int start) {
|
||||
add_column(const InternalName *name, int num_components,
|
||||
qpGeomVertexColumn::NumericType numeric_type,
|
||||
qpGeomVertexColumn::Contents contents, int start) {
|
||||
if (start < 0) {
|
||||
start = _total_bytes;
|
||||
|
||||
qpGeomVertexDataType temp_data_type
|
||||
qpGeomVertexColumn temp_column
|
||||
(name, num_components, numeric_type, contents, 0);
|
||||
int pad_to = temp_data_type.get_component_bytes();
|
||||
int pad_to = temp_column.get_component_bytes();
|
||||
start = ((start + pad_to - 1) / pad_to) * pad_to;
|
||||
}
|
||||
|
||||
return add_data_type(qpGeomVertexDataType(name, num_components,
|
||||
return add_column(qpGeomVertexColumn(name, num_components,
|
||||
numeric_type, contents, start));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexArrayFormat::add_data_type
|
||||
// Function: qpGeomVertexArrayFormat::add_column
|
||||
// Access: Published
|
||||
// Description: Adds a new data type to the specification. This is a
|
||||
// Description: Adds a new column to the specification. This is a
|
||||
// table of per-vertex floating-point numbers such as
|
||||
// "vertex" or "normal"; you must specify where in each
|
||||
// record the table starts, and how many components
|
||||
// (dimensions) exist per vertex.
|
||||
//
|
||||
// Adding a data type with the same name as a previous
|
||||
// Adding a column with the same name as a previous
|
||||
// type, or that overlaps with one or more previous
|
||||
// types, quietly removes the previous type(s).
|
||||
//
|
||||
|
|
@ -237,118 +237,118 @@ add_data_type(const InternalName *name, int num_components,
|
|||
// type.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int qpGeomVertexArrayFormat::
|
||||
add_data_type(const qpGeomVertexDataType &data_type) {
|
||||
add_column(const qpGeomVertexColumn &column) {
|
||||
nassertr(!_is_registered, -1);
|
||||
|
||||
// Make sure there isn't already a data type with this name.
|
||||
remove_data_type(data_type.get_name());
|
||||
// Make sure there isn't already a column with this name.
|
||||
remove_column(column.get_name());
|
||||
|
||||
// Also make sure there aren't any data types that overlap with this
|
||||
// Also make sure there aren't any columns that overlap with this
|
||||
// one.
|
||||
const qpGeomVertexDataType *orig_data_type = get_data_type(data_type.get_start(), data_type.get_total_bytes());
|
||||
while (orig_data_type != (const qpGeomVertexDataType *)NULL) {
|
||||
remove_data_type(orig_data_type->get_name());
|
||||
orig_data_type = get_data_type(data_type.get_start(), data_type.get_total_bytes());
|
||||
const qpGeomVertexColumn *orig_column = get_column(column.get_start(), column.get_total_bytes());
|
||||
while (orig_column != (const qpGeomVertexColumn *)NULL) {
|
||||
remove_column(orig_column->get_name());
|
||||
orig_column = get_column(column.get_start(), column.get_total_bytes());
|
||||
}
|
||||
|
||||
_total_bytes = max(_total_bytes, data_type.get_start() + data_type.get_total_bytes());
|
||||
_pad_to = max(_pad_to, data_type.get_component_bytes());
|
||||
_total_bytes = max(_total_bytes, column.get_start() + column.get_total_bytes());
|
||||
_pad_to = max(_pad_to, column.get_component_bytes());
|
||||
_stride = max(_stride, ((_total_bytes + _pad_to - 1) / _pad_to) * _pad_to);
|
||||
|
||||
qpGeomVertexDataType *new_data_type = new qpGeomVertexDataType(data_type);
|
||||
qpGeomVertexColumn *new_column = new qpGeomVertexColumn(column);
|
||||
|
||||
if (!_data_types.empty() && *new_data_type < *_data_types.back()) {
|
||||
_data_types_unsorted = true;
|
||||
if (!_columns.empty() && *new_column < *_columns.back()) {
|
||||
_columns_unsorted = true;
|
||||
}
|
||||
|
||||
int new_index = (int)_data_types.size();
|
||||
_data_types.push_back(new_data_type);
|
||||
_data_types_by_name.insert(DataTypesByName::value_type(new_data_type->get_name(), new_data_type));
|
||||
int new_index = (int)_columns.size();
|
||||
_columns.push_back(new_column);
|
||||
_columns_by_name.insert(DataTypesByName::value_type(new_column->get_name(), new_column));
|
||||
|
||||
return new_index;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexArrayFormat::remove_data_type
|
||||
// Function: qpGeomVertexArrayFormat::remove_column
|
||||
// Access: Published
|
||||
// Description: Removes the data type with the indicated name, if
|
||||
// Description: Removes the column with the indicated name, if
|
||||
// any. This leaves a gap in the byte structure.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexArrayFormat::
|
||||
remove_data_type(const InternalName *name) {
|
||||
remove_column(const InternalName *name) {
|
||||
nassertv(!_is_registered);
|
||||
DataTypesByName::iterator ni;
|
||||
ni = _data_types_by_name.find(name);
|
||||
if (ni != _data_types_by_name.end()) {
|
||||
qpGeomVertexDataType *data_type = (*ni).second;
|
||||
_data_types_by_name.erase(ni);
|
||||
ni = _columns_by_name.find(name);
|
||||
if (ni != _columns_by_name.end()) {
|
||||
qpGeomVertexColumn *column = (*ni).second;
|
||||
_columns_by_name.erase(ni);
|
||||
|
||||
DataTypes::iterator dti;
|
||||
dti = find(_data_types.begin(), _data_types.end(), data_type);
|
||||
nassertv(dti != _data_types.end());
|
||||
_data_types.erase(dti);
|
||||
dti = find(_columns.begin(), _columns.end(), column);
|
||||
nassertv(dti != _columns.end());
|
||||
_columns.erase(dti);
|
||||
|
||||
delete data_type;
|
||||
delete column;
|
||||
|
||||
// Maybe we just removed the tail data_type. If that's so, we
|
||||
// Maybe we just removed the tail column. If that's so, we
|
||||
// should recompute _total_bytes to reflect the new tail.
|
||||
if (_data_types.empty()) {
|
||||
if (_columns.empty()) {
|
||||
_total_bytes = 0;
|
||||
} else {
|
||||
consider_sort_data_types();
|
||||
qpGeomVertexDataType *last = _data_types.back();
|
||||
consider_sort_columns();
|
||||
qpGeomVertexColumn *last = _columns.back();
|
||||
_total_bytes = last->get_start() + last->get_total_bytes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexArrayFormat::clear_data_types
|
||||
// Function: qpGeomVertexArrayFormat::clear_columns
|
||||
// Access: Published
|
||||
// Description: Removes all data types previously added, sets the
|
||||
// Description: Removes all columns previously added, sets the
|
||||
// stride to zero, and prepares to start over.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexArrayFormat::
|
||||
clear_data_types() {
|
||||
_data_types.clear();
|
||||
_data_types_by_name.clear();
|
||||
_data_types_unsorted = false;
|
||||
clear_columns() {
|
||||
_columns.clear();
|
||||
_columns_by_name.clear();
|
||||
_columns_unsorted = false;
|
||||
_stride = 0;
|
||||
_total_bytes = 0;
|
||||
_pad_to = 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexArrayFormat::get_data_type
|
||||
// Function: qpGeomVertexArrayFormat::get_column
|
||||
// Access: Published
|
||||
// Description: Returns the specification with the indicated name, or
|
||||
// NULL if the name is not used.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const qpGeomVertexDataType *qpGeomVertexArrayFormat::
|
||||
get_data_type(const InternalName *name) const {
|
||||
const qpGeomVertexColumn *qpGeomVertexArrayFormat::
|
||||
get_column(const InternalName *name) const {
|
||||
DataTypesByName::const_iterator ni;
|
||||
ni = _data_types_by_name.find(name);
|
||||
if (ni != _data_types_by_name.end()) {
|
||||
ni = _columns_by_name.find(name);
|
||||
if (ni != _columns_by_name.end()) {
|
||||
return (*ni).second;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexArrayFormat::get_data_type
|
||||
// Function: qpGeomVertexArrayFormat::get_column
|
||||
// Access: Published
|
||||
// Description: Returns the first specification that overlaps with
|
||||
// any of the indicated bytes in the range, or NULL if
|
||||
// none do.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const qpGeomVertexDataType *qpGeomVertexArrayFormat::
|
||||
get_data_type(int start_byte, int num_bytes) const {
|
||||
consider_sort_data_types();
|
||||
const qpGeomVertexColumn *qpGeomVertexArrayFormat::
|
||||
get_column(int start_byte, int num_bytes) const {
|
||||
consider_sort_columns();
|
||||
DataTypes::const_iterator dti;
|
||||
for (dti = _data_types.begin(); dti != _data_types.end(); ++dti) {
|
||||
const qpGeomVertexDataType *data_type = (*dti);
|
||||
if (data_type->overlaps_with(start_byte, num_bytes)) {
|
||||
return data_type;
|
||||
for (dti = _columns.begin(); dti != _columns.end(); ++dti) {
|
||||
const qpGeomVertexColumn *column = (*dti);
|
||||
if (column->overlaps_with(start_byte, num_bytes)) {
|
||||
return column;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -367,24 +367,24 @@ get_data_type(int start_byte, int num_bytes) const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
bool qpGeomVertexArrayFormat::
|
||||
is_data_subset_of(const qpGeomVertexArrayFormat &other) const {
|
||||
if (_data_types.size() > other._data_types.size() ||
|
||||
if (_columns.size() > other._columns.size() ||
|
||||
get_stride() != other.get_stride()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
consider_sort_data_types();
|
||||
other.consider_sort_data_types();
|
||||
consider_sort_columns();
|
||||
other.consider_sort_columns();
|
||||
size_t i = 0;
|
||||
size_t j = 0;
|
||||
while (i < _data_types.size() && j < other._data_types.size()) {
|
||||
if (*_data_types[i] == *other._data_types[j]) {
|
||||
while (i < _columns.size() && j < other._columns.size()) {
|
||||
if (*_columns[i] == *other._columns[j]) {
|
||||
++i;
|
||||
}
|
||||
++j;
|
||||
}
|
||||
|
||||
// If we reached the end of our list, all fields matched.
|
||||
return (i == _data_types.size());
|
||||
return (i == _columns.size());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -396,9 +396,9 @@ void qpGeomVertexArrayFormat::
|
|||
output(ostream &out) const {
|
||||
DataTypes::const_iterator dti;
|
||||
out << "[";
|
||||
for (dti = _data_types.begin(); dti != _data_types.end(); ++dti) {
|
||||
const qpGeomVertexDataType *data_type = (*dti);
|
||||
out << " " << *data_type;
|
||||
for (dti = _columns.begin(); dti != _columns.end(); ++dti) {
|
||||
const qpGeomVertexColumn *column = (*dti);
|
||||
out << " " << *column;
|
||||
}
|
||||
out << " ]";
|
||||
}
|
||||
|
|
@ -412,12 +412,12 @@ void qpGeomVertexArrayFormat::
|
|||
write(ostream &out, int indent_level) const {
|
||||
indent(out, indent_level)
|
||||
<< "Array format (stride = " << get_stride() << "):\n";
|
||||
consider_sort_data_types();
|
||||
consider_sort_columns();
|
||||
DataTypes::const_iterator dti;
|
||||
for (dti = _data_types.begin(); dti != _data_types.end(); ++dti) {
|
||||
const qpGeomVertexDataType *data_type = (*dti);
|
||||
for (dti = _columns.begin(); dti != _columns.end(); ++dti) {
|
||||
const qpGeomVertexColumn *column = (*dti);
|
||||
indent(out, indent_level + 2)
|
||||
<< *data_type << " start at " << data_type->get_start() << "\n";
|
||||
<< *column << " start at " << column->get_start() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -429,7 +429,7 @@ write(ostream &out, int indent_level) const {
|
|||
void qpGeomVertexArrayFormat::
|
||||
write_with_data(ostream &out, int indent_level,
|
||||
const qpGeomVertexData *data, int array_index) const {
|
||||
consider_sort_data_types();
|
||||
consider_sort_columns();
|
||||
int num_vertices = data->get_num_vertices();
|
||||
|
||||
qpGeomVertexReader reader(data);
|
||||
|
|
@ -439,14 +439,14 @@ write_with_data(ostream &out, int indent_level,
|
|||
<< "vertex index " << i << ":\n";
|
||||
reader.set_vertex(i);
|
||||
DataTypes::const_iterator dti;
|
||||
for (dti = _data_types.begin(); dti != _data_types.end(); ++dti) {
|
||||
const qpGeomVertexDataType *data_type = (*dti);
|
||||
int num_values = min(data_type->get_num_values(), 4);
|
||||
reader.set_data_type(array_index, data_type);
|
||||
for (dti = _columns.begin(); dti != _columns.end(); ++dti) {
|
||||
const qpGeomVertexColumn *column = (*dti);
|
||||
int num_values = min(column->get_num_values(), 4);
|
||||
reader.set_column(array_index, column);
|
||||
const LVecBase4f &d = reader.get_data4f();
|
||||
|
||||
indent(out, indent_level + 2)
|
||||
<< *data_type->get_name();
|
||||
<< *column->get_name();
|
||||
for (int v = 0; v < num_values; v++) {
|
||||
out << " " << d[v];
|
||||
}
|
||||
|
|
@ -471,13 +471,13 @@ compare_to(const qpGeomVertexArrayFormat &other) const {
|
|||
if (_pad_to != other._pad_to) {
|
||||
return _pad_to - other._pad_to;
|
||||
}
|
||||
if (_data_types.size() != other._data_types.size()) {
|
||||
return (int)_data_types.size() - (int)other._data_types.size();
|
||||
if (_columns.size() != other._columns.size()) {
|
||||
return (int)_columns.size() - (int)other._columns.size();
|
||||
}
|
||||
consider_sort_data_types();
|
||||
other.consider_sort_data_types();
|
||||
for (size_t i = 0; i < _data_types.size(); i++) {
|
||||
int compare = _data_types[i]->compare_to(*other._data_types[i]);
|
||||
consider_sort_columns();
|
||||
other.consider_sort_columns();
|
||||
for (size_t i = 0; i < _columns.size(); i++) {
|
||||
int compare = _columns[i]->compare_to(*other._columns[i]);
|
||||
if (compare != 0) {
|
||||
return compare;
|
||||
}
|
||||
|
|
@ -487,15 +487,15 @@ compare_to(const qpGeomVertexArrayFormat &other) const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexArrayFormat::sort_data_types
|
||||
// Function: qpGeomVertexArrayFormat::sort_columns
|
||||
// Access: Private
|
||||
// Description: Resorts the _data_types vector so that the data types
|
||||
// Description: Resorts the _columns vector so that the columns
|
||||
// are listed in the same order they appear in the
|
||||
// record.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexArrayFormat::
|
||||
sort_data_types() {
|
||||
sort(_data_types.begin(), _data_types.end(), IndirectLess<qpGeomVertexDataType>());
|
||||
sort_columns() {
|
||||
sort(_columns.begin(), _columns.end(), IndirectLess<qpGeomVertexColumn>());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "pandabase.h"
|
||||
#include "typedWritableReferenceCount.h"
|
||||
#include "qpgeomVertexDataType.h"
|
||||
#include "qpgeomVertexColumn.h"
|
||||
#include "pvector.h"
|
||||
#include "pmap.h"
|
||||
|
||||
|
|
@ -38,13 +38,15 @@ class FactoryParams;
|
|||
// GeomVertexArrayFormat objects.
|
||||
//
|
||||
// A particular array may include any number of standard
|
||||
// or user-defined data types. All data types consist
|
||||
// of a sequence of one or more floating-point numbers;
|
||||
// the semantic meaning of the data type is implicit
|
||||
// from its name. The standard array types are named
|
||||
// "vertex", "normal", "texcoord", "color", "tangent",
|
||||
// and "binormal"; other data may be stored simply by
|
||||
// choosing a different name.
|
||||
// or user-defined columns. All columns consist of a
|
||||
// sequence of one or more numeric values, packed in any
|
||||
// of a variety of formats; the semantic meaning of each
|
||||
// column is defined in general with its contents
|
||||
// member, and in particular by its name. The standard
|
||||
// array types used most often are named "vertex",
|
||||
// "normal", "texcoord", and "color"; other kinds of
|
||||
// data may be piggybacked into the data record simply
|
||||
// by choosing a unique name.
|
||||
//
|
||||
// This is part of the experimental Geom rewrite.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -53,35 +55,35 @@ PUBLISHED:
|
|||
qpGeomVertexArrayFormat();
|
||||
qpGeomVertexArrayFormat(const qpGeomVertexArrayFormat ©);
|
||||
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
|
||||
qpGeomVertexDataType::NumericType numeric_type0,
|
||||
qpGeomVertexDataType::Contents contents0);
|
||||
qpGeomVertexColumn::NumericType numeric_type0,
|
||||
qpGeomVertexColumn::Contents contents0);
|
||||
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
|
||||
qpGeomVertexDataType::NumericType numeric_type0,
|
||||
qpGeomVertexDataType::Contents contents0,
|
||||
qpGeomVertexColumn::NumericType numeric_type0,
|
||||
qpGeomVertexColumn::Contents contents0,
|
||||
const InternalName *name1, int num_components1,
|
||||
qpGeomVertexDataType::NumericType numeric_type1,
|
||||
qpGeomVertexDataType::Contents contents1);
|
||||
qpGeomVertexColumn::NumericType numeric_type1,
|
||||
qpGeomVertexColumn::Contents contents1);
|
||||
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
|
||||
qpGeomVertexDataType::NumericType numeric_type0,
|
||||
qpGeomVertexDataType::Contents contents0,
|
||||
qpGeomVertexColumn::NumericType numeric_type0,
|
||||
qpGeomVertexColumn::Contents contents0,
|
||||
const InternalName *name1, int num_components1,
|
||||
qpGeomVertexDataType::NumericType numeric_type1,
|
||||
qpGeomVertexDataType::Contents contents1,
|
||||
qpGeomVertexColumn::NumericType numeric_type1,
|
||||
qpGeomVertexColumn::Contents contents1,
|
||||
const InternalName *name2, int num_components2,
|
||||
qpGeomVertexDataType::NumericType numeric_type2,
|
||||
qpGeomVertexDataType::Contents contents2);
|
||||
qpGeomVertexColumn::NumericType numeric_type2,
|
||||
qpGeomVertexColumn::Contents contents2);
|
||||
qpGeomVertexArrayFormat(const InternalName *name0, int num_components0,
|
||||
qpGeomVertexDataType::NumericType numeric_type0,
|
||||
qpGeomVertexDataType::Contents contents0,
|
||||
qpGeomVertexColumn::NumericType numeric_type0,
|
||||
qpGeomVertexColumn::Contents contents0,
|
||||
const InternalName *name1, int num_components1,
|
||||
qpGeomVertexDataType::NumericType numeric_type1,
|
||||
qpGeomVertexDataType::Contents contents1,
|
||||
qpGeomVertexColumn::NumericType numeric_type1,
|
||||
qpGeomVertexColumn::Contents contents1,
|
||||
const InternalName *name2, int num_components2,
|
||||
qpGeomVertexDataType::NumericType numeric_type2,
|
||||
qpGeomVertexDataType::Contents contents2,
|
||||
qpGeomVertexColumn::NumericType numeric_type2,
|
||||
qpGeomVertexColumn::Contents contents2,
|
||||
const InternalName *name3, int num_components3,
|
||||
qpGeomVertexDataType::NumericType numeric_type3,
|
||||
qpGeomVertexDataType::Contents contents3);
|
||||
qpGeomVertexColumn::NumericType numeric_type3,
|
||||
qpGeomVertexColumn::Contents contents3);
|
||||
void operator = (const qpGeomVertexArrayFormat ©);
|
||||
~qpGeomVertexArrayFormat();
|
||||
|
||||
|
|
@ -93,20 +95,20 @@ PUBLISHED:
|
|||
INLINE int get_total_bytes() const;
|
||||
INLINE int get_pad_to() const;
|
||||
|
||||
int add_data_type(const InternalName *name, int num_components,
|
||||
qpGeomVertexDataType::NumericType numeric_type,
|
||||
qpGeomVertexDataType::Contents contents,
|
||||
int start = -1);
|
||||
int add_data_type(const qpGeomVertexDataType &data_type);
|
||||
void remove_data_type(const InternalName *name);
|
||||
void clear_data_types();
|
||||
int add_column(const InternalName *name, int num_components,
|
||||
qpGeomVertexColumn::NumericType numeric_type,
|
||||
qpGeomVertexColumn::Contents contents,
|
||||
int start = -1);
|
||||
int add_column(const qpGeomVertexColumn &column);
|
||||
void remove_column(const InternalName *name);
|
||||
void clear_columns();
|
||||
|
||||
INLINE int get_num_data_types() const;
|
||||
INLINE const qpGeomVertexDataType *get_data_type(int i) const;
|
||||
INLINE int get_num_columns() const;
|
||||
INLINE const qpGeomVertexColumn *get_column(int i) const;
|
||||
|
||||
const qpGeomVertexDataType *get_data_type(const InternalName *name) const;
|
||||
const qpGeomVertexDataType *get_data_type(int start_byte, int num_bytes) const;
|
||||
INLINE bool has_data_type(const InternalName *name) const;
|
||||
const qpGeomVertexColumn *get_column(const InternalName *name) const;
|
||||
const qpGeomVertexColumn *get_column(int start_byte, int num_bytes) const;
|
||||
INLINE bool has_column(const InternalName *name) const;
|
||||
|
||||
bool is_data_subset_of(const qpGeomVertexArrayFormat &other) const;
|
||||
|
||||
|
|
@ -119,8 +121,8 @@ public:
|
|||
int compare_to(const qpGeomVertexArrayFormat &other) const;
|
||||
|
||||
private:
|
||||
INLINE void consider_sort_data_types() const;
|
||||
void sort_data_types();
|
||||
INLINE void consider_sort_columns() const;
|
||||
void sort_columns();
|
||||
void do_register();
|
||||
|
||||
bool _is_registered;
|
||||
|
|
@ -131,12 +133,12 @@ private:
|
|||
int _total_bytes;
|
||||
int _pad_to;
|
||||
|
||||
typedef pvector<qpGeomVertexDataType *> DataTypes;
|
||||
DataTypes _data_types;
|
||||
bool _data_types_unsorted;
|
||||
typedef pvector<qpGeomVertexColumn *> DataTypes;
|
||||
DataTypes _columns;
|
||||
bool _columns_unsorted;
|
||||
|
||||
typedef pmap<const InternalName *, qpGeomVertexDataType *> DataTypesByName;
|
||||
DataTypesByName _data_types_by_name;
|
||||
typedef pmap<const InternalName *, qpGeomVertexColumn *> DataTypesByName;
|
||||
DataTypesByName _columns_by_name;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Filename: qpgeomVertexDataType.I
|
||||
// Filename: qpgeomVertexColumn.I
|
||||
// Created by: drose (06Mar05)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::Copy Constructor
|
||||
// Function: qpGeomVertexColumn::Copy Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE qpGeomVertexDataType::
|
||||
qpGeomVertexDataType(const qpGeomVertexDataType ©) :
|
||||
INLINE qpGeomVertexColumn::
|
||||
qpGeomVertexColumn(const qpGeomVertexColumn ©) :
|
||||
_name(copy._name),
|
||||
_num_components(copy._num_components),
|
||||
_num_values(copy._num_values),
|
||||
|
|
@ -36,12 +36,12 @@ qpGeomVertexDataType(const qpGeomVertexDataType ©) :
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::Copy Assignment Operator
|
||||
// Function: qpGeomVertexColumn::Copy Assignment Operator
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexDataType::
|
||||
operator = (const qpGeomVertexDataType ©) {
|
||||
INLINE void qpGeomVertexColumn::
|
||||
operator = (const qpGeomVertexColumn ©) {
|
||||
_name = copy._name;
|
||||
_num_components = copy._num_components;
|
||||
_num_values = copy._num_values;
|
||||
|
|
@ -53,7 +53,7 @@ operator = (const qpGeomVertexDataType ©) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::get_name
|
||||
// Function: qpGeomVertexColumn::get_name
|
||||
// Access: Published
|
||||
// Description: Returns the name of this particular data field,
|
||||
// e.g. "vertex" or "normal". The name may be a
|
||||
|
|
@ -61,98 +61,98 @@ operator = (const qpGeomVertexDataType ©) {
|
|||
// system-defined field types. Only the system-defined
|
||||
// field types are used for the actual rendering.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const InternalName *qpGeomVertexDataType::
|
||||
INLINE const InternalName *qpGeomVertexColumn::
|
||||
get_name() const {
|
||||
return _name;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::get_num_components
|
||||
// Function: qpGeomVertexColumn::get_num_components
|
||||
// Access: Published
|
||||
// Description: Returns the number of components of each data type:
|
||||
// Description: Returns the number of components of the column:
|
||||
// the number of instances of the NumericType in each
|
||||
// element. This is usually, but not always, the same
|
||||
// thing as get_num_values().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexDataType::
|
||||
INLINE int qpGeomVertexColumn::
|
||||
get_num_components() const {
|
||||
return _num_components;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::get_num_values
|
||||
// Function: qpGeomVertexColumn::get_num_values
|
||||
// Access: Published
|
||||
// Description: Returns the number of numeric values of each data
|
||||
// type: the number of distinct numeric values that go
|
||||
// into each element. This is usually, but not always,
|
||||
// the same thing as get_num_components(); the
|
||||
// difference is in the case of a composite numeric type
|
||||
// like NT_packed_dcba, which has four numeric values
|
||||
// per component.
|
||||
// Description: Returns the number of numeric values of the column:
|
||||
// the number of distinct numeric values that go into
|
||||
// each element. This is usually, but not always, the
|
||||
// same thing as get_num_components(); the difference is
|
||||
// in the case of a composite numeric type like
|
||||
// NT_packed_dcba, which has four numeric values per
|
||||
// component.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexDataType::
|
||||
INLINE int qpGeomVertexColumn::
|
||||
get_num_values() const {
|
||||
return _num_values;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::get_numeric_type
|
||||
// Function: qpGeomVertexColumn::get_numeric_type
|
||||
// Access: Published
|
||||
// Description: Returns the token representing the numeric type of
|
||||
// the data storage.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE qpGeomVertexDataType::NumericType qpGeomVertexDataType::
|
||||
INLINE qpGeomVertexColumn::NumericType qpGeomVertexColumn::
|
||||
get_numeric_type() const {
|
||||
return _numeric_type;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::get_contents
|
||||
// Function: qpGeomVertexColumn::get_contents
|
||||
// Access: Published
|
||||
// Description: Returns the token representing the semantic meaning of
|
||||
// the stored value.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE qpGeomVertexDataType::Contents qpGeomVertexDataType::
|
||||
INLINE qpGeomVertexColumn::Contents qpGeomVertexColumn::
|
||||
get_contents() const {
|
||||
return _contents;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::get_start
|
||||
// Function: qpGeomVertexColumn::get_start
|
||||
// Access: Published
|
||||
// Description: Returns the byte within the array record at which
|
||||
// this data type starts. This can be set to non-zero
|
||||
// this column starts. This can be set to non-zero
|
||||
// to implement interleaved arrays.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexDataType::
|
||||
INLINE int qpGeomVertexColumn::
|
||||
get_start() const {
|
||||
return _start;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::get_component_bytes
|
||||
// Function: qpGeomVertexColumn::get_component_bytes
|
||||
// Access: Published
|
||||
// Description: Returns the number of bytes used by each component
|
||||
// (that is, by one element of the numeric type).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexDataType::
|
||||
INLINE int qpGeomVertexColumn::
|
||||
get_component_bytes() const {
|
||||
return _component_bytes;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::get_total_bytes
|
||||
// Function: qpGeomVertexColumn::get_total_bytes
|
||||
// Access: Published
|
||||
// Description: Returns the number of bytes used by the data type:
|
||||
// component_bytes * num_components.
|
||||
// Description: Returns the number of bytes used by each element of
|
||||
// the column: component_bytes * num_components.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexDataType::
|
||||
INLINE int qpGeomVertexColumn::
|
||||
get_total_bytes() const {
|
||||
return _total_bytes;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::has_homogeneous_coord
|
||||
// Function: qpGeomVertexColumn::has_homogeneous_coord
|
||||
// Access: Published
|
||||
// Description: Returns true if this Contents type is one that
|
||||
// includes a homogeneous coordinate in the fourth
|
||||
|
|
@ -163,7 +163,7 @@ get_total_bytes() const {
|
|||
// you use the 3-component or smaller forms of
|
||||
// get_data() and set_data()).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexDataType::
|
||||
INLINE bool qpGeomVertexColumn::
|
||||
has_homogeneous_coord() const {
|
||||
switch (_contents) {
|
||||
case C_point:
|
||||
|
|
@ -176,27 +176,27 @@ has_homogeneous_coord() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::overlaps_with
|
||||
// Function: qpGeomVertexColumn::overlaps_with
|
||||
// Access: Published
|
||||
// Description: Returns true if this data type overlaps with any of
|
||||
// Description: Returns true if this column overlaps with any of
|
||||
// the bytes in the indicated range, false if it does
|
||||
// not.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexDataType::
|
||||
INLINE bool qpGeomVertexColumn::
|
||||
overlaps_with(int start_byte, int num_bytes) const {
|
||||
return (_start < start_byte + num_bytes &&
|
||||
_start + _total_bytes > start_byte);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::is_bytewise_equivalent
|
||||
// Function: qpGeomVertexColumn::is_bytewise_equivalent
|
||||
// Access: Published
|
||||
// Description: Returns true if the data store of this data type is
|
||||
// Description: Returns true if the data store of this column is
|
||||
// exactly the same as that of the other, irrespective
|
||||
// of name or start position within the record.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexDataType::
|
||||
is_bytewise_equivalent(const qpGeomVertexDataType &other) const {
|
||||
INLINE bool qpGeomVertexColumn::
|
||||
is_bytewise_equivalent(const qpGeomVertexColumn &other) const {
|
||||
// Not sure if the contents are relevant, but let's say that they
|
||||
// are.
|
||||
return (_num_components == other._num_components &&
|
||||
|
|
@ -205,13 +205,13 @@ is_bytewise_equivalent(const qpGeomVertexDataType &other) const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::is_packed_argb
|
||||
// Function: qpGeomVertexColumn::is_packed_argb
|
||||
// Access: Public
|
||||
// Description: Returns true if this data type is the standard
|
||||
// Description: Returns true if this column is the standard
|
||||
// DirectX representation of 4-component color: C_color,
|
||||
// in NT_packed_dabc, with 1 component (4 values).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexDataType::
|
||||
INLINE bool qpGeomVertexColumn::
|
||||
is_packed_argb() const {
|
||||
return (_num_components == 1 &&
|
||||
_numeric_type == NT_packed_dabc &&
|
||||
|
|
@ -219,13 +219,13 @@ is_packed_argb() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::is_uint8_rgba
|
||||
// Function: qpGeomVertexColumn::is_uint8_rgba
|
||||
// Access: Public
|
||||
// Description: Returns true if this data type is the standard
|
||||
// Description: Returns true if this column is the standard
|
||||
// OpenGL representation of 4-component color: C_color,
|
||||
// in NT_uint8, with 4 components.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexDataType::
|
||||
INLINE bool qpGeomVertexColumn::
|
||||
is_uint8_rgba() const {
|
||||
return (_num_components == 4 &&
|
||||
_numeric_type == NT_uint8 &&
|
||||
|
|
@ -233,13 +233,13 @@ is_uint8_rgba() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::compare_to
|
||||
// Function: qpGeomVertexColumn::compare_to
|
||||
// Access: Public
|
||||
// Description: This is used to unquify data types, and hence
|
||||
// Description: This is used to unquify columns, and hence
|
||||
// formats, for the GeomVertexFormat registry.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexDataType::
|
||||
compare_to(const qpGeomVertexDataType &other) const {
|
||||
INLINE int qpGeomVertexColumn::
|
||||
compare_to(const qpGeomVertexColumn &other) const {
|
||||
if (_name != other._name) {
|
||||
return _name < other._name ? -1 : 1;
|
||||
}
|
||||
|
|
@ -259,36 +259,36 @@ compare_to(const qpGeomVertexDataType &other) const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::operator ==
|
||||
// Function: qpGeomVertexColumn::operator ==
|
||||
// Access: Public
|
||||
// Description: Returns true if the two data types are exactly
|
||||
// Description: Returns true if the two columns are exactly
|
||||
// equivalent, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexDataType::
|
||||
operator == (const qpGeomVertexDataType &other) const {
|
||||
INLINE bool qpGeomVertexColumn::
|
||||
operator == (const qpGeomVertexColumn &other) const {
|
||||
return compare_to(other) == 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::operator !=
|
||||
// Function: qpGeomVertexColumn::operator !=
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexDataType::
|
||||
operator != (const qpGeomVertexDataType &other) const {
|
||||
INLINE bool qpGeomVertexColumn::
|
||||
operator != (const qpGeomVertexColumn &other) const {
|
||||
return compare_to(other) != 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::operator <
|
||||
// Function: qpGeomVertexColumn::operator <
|
||||
// Access: Public
|
||||
// Description: This is used to put data types in order within a
|
||||
// Description: This is used to put columns in order within a
|
||||
// particular GeomVertexArrayFormat. Note that it is
|
||||
// *not* in the same space as operator == and operator
|
||||
// !=.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexDataType::
|
||||
operator < (const qpGeomVertexDataType &other) const {
|
||||
INLINE bool qpGeomVertexColumn::
|
||||
operator < (const qpGeomVertexColumn &other) const {
|
||||
if (_start != other._start) {
|
||||
return _start < other._start;
|
||||
}
|
||||
|
|
@ -299,7 +299,7 @@ operator < (const qpGeomVertexDataType &other) const {
|
|||
}
|
||||
|
||||
INLINE ostream &
|
||||
operator << (ostream &out, const qpGeomVertexDataType &obj) {
|
||||
operator << (ostream &out, const qpGeomVertexColumn &obj) {
|
||||
obj.output(out);
|
||||
return out;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Filename: qpgeomVertexDataType.cxx
|
||||
// Filename: qpgeomVertexColumn.cxx
|
||||
// Created by: drose (06Mar05)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -16,15 +16,15 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "qpgeomVertexDataType.h"
|
||||
#include "qpgeomVertexColumn.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::Constructor
|
||||
// Function: qpGeomVertexColumn::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
qpGeomVertexDataType::
|
||||
qpGeomVertexDataType(const InternalName *name, int num_components,
|
||||
qpGeomVertexColumn::
|
||||
qpGeomVertexColumn(const InternalName *name, int num_components,
|
||||
NumericType numeric_type, Contents contents,
|
||||
int start) :
|
||||
_name(name),
|
||||
|
|
@ -60,24 +60,11 @@ qpGeomVertexDataType(const InternalName *name, int num_components,
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::error named constructor
|
||||
// Access: Published
|
||||
// Description: Returns a data type specifically to represent an
|
||||
// error condition.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const qpGeomVertexDataType &qpGeomVertexDataType::
|
||||
error() {
|
||||
static qpGeomVertexDataType error_result
|
||||
(InternalName::get_error(), 1, NT_uint8, C_other, 0);
|
||||
return error_result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexDataType::output
|
||||
// Function: qpGeomVertexColumn::output
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexDataType::
|
||||
void qpGeomVertexColumn::
|
||||
output(ostream &out) const {
|
||||
out << *get_name() << "(" << get_num_components() << ")";
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Filename: qpgeomVertexDataType.h
|
||||
// Filename: qpgeomVertexColumn.h
|
||||
// Created by: drose (06Mar05)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -16,23 +16,23 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef qpGEOMVERTEXDATATYPE_H
|
||||
#define qpGEOMVERTEXDATATYPE_H
|
||||
#ifndef qpGEOMVERTEXCOLUMN_H
|
||||
#define qpGEOMVERTEXCOLUMN_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "internalName.h"
|
||||
#include "pointerTo.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : qpGeomVertexDataType
|
||||
// Description : This defines how a single data type is interleaved
|
||||
// Class : qpGeomVertexColumn
|
||||
// Description : This defines how a single column is interleaved
|
||||
// within a vertex array stored within a Geom. The
|
||||
// GeomVertexArrayFormat class maintains a list of these
|
||||
// to completely define a particular array structure.
|
||||
//
|
||||
// This is part of the experimental Geom rewrite.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA qpGeomVertexDataType {
|
||||
class EXPCL_PANDA qpGeomVertexColumn {
|
||||
PUBLISHED:
|
||||
enum NumericType {
|
||||
NT_uint8, // An integer 0..255
|
||||
|
|
@ -52,13 +52,11 @@ PUBLISHED:
|
|||
C_morph_delta, // A delta from some base value, defining a blend shape
|
||||
};
|
||||
|
||||
INLINE qpGeomVertexDataType(const InternalName *name, int num_components,
|
||||
INLINE qpGeomVertexColumn(const InternalName *name, int num_components,
|
||||
NumericType numeric_type, Contents contents,
|
||||
int start);
|
||||
INLINE qpGeomVertexDataType(const qpGeomVertexDataType ©);
|
||||
INLINE void operator = (const qpGeomVertexDataType ©);
|
||||
|
||||
static const qpGeomVertexDataType &error();
|
||||
INLINE qpGeomVertexColumn(const qpGeomVertexColumn ©);
|
||||
INLINE void operator = (const qpGeomVertexColumn ©);
|
||||
|
||||
INLINE const InternalName *get_name() const;
|
||||
INLINE int get_num_components() const;
|
||||
|
|
@ -71,7 +69,7 @@ PUBLISHED:
|
|||
INLINE bool has_homogeneous_coord() const;
|
||||
|
||||
INLINE bool overlaps_with(int start_byte, int num_bytes) const;
|
||||
INLINE bool is_bytewise_equivalent(const qpGeomVertexDataType &other) const;
|
||||
INLINE bool is_bytewise_equivalent(const qpGeomVertexColumn &other) const;
|
||||
|
||||
void output(ostream &out) const;
|
||||
|
||||
|
|
@ -79,10 +77,10 @@ public:
|
|||
INLINE bool is_packed_argb() const;
|
||||
INLINE bool is_uint8_rgba() const;
|
||||
|
||||
INLINE int compare_to(const qpGeomVertexDataType &other) const;
|
||||
INLINE bool operator == (const qpGeomVertexDataType &other) const;
|
||||
INLINE bool operator != (const qpGeomVertexDataType &other) const;
|
||||
INLINE bool operator < (const qpGeomVertexDataType &other) const;
|
||||
INLINE int compare_to(const qpGeomVertexColumn &other) const;
|
||||
INLINE bool operator == (const qpGeomVertexColumn &other) const;
|
||||
INLINE bool operator != (const qpGeomVertexColumn &other) const;
|
||||
INLINE bool operator < (const qpGeomVertexColumn &other) const;
|
||||
|
||||
private:
|
||||
CPT(InternalName) _name;
|
||||
|
|
@ -95,8 +93,8 @@ private:
|
|||
int _total_bytes;
|
||||
};
|
||||
|
||||
INLINE ostream &operator << (ostream &out, const qpGeomVertexDataType &obj);
|
||||
INLINE ostream &operator << (ostream &out, const qpGeomVertexColumn &obj);
|
||||
|
||||
#include "qpgeomVertexDataType.I"
|
||||
#include "qpgeomVertexColumn.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -420,61 +420,61 @@ copy_from(const qpGeomVertexData &source, bool keep_data_objects) {
|
|||
for (source_i = 0; source_i < num_arrays; ++source_i) {
|
||||
CPTA_uchar array_data = source.get_array(source_i)->get_data();
|
||||
const qpGeomVertexArrayFormat *source_array_format = source_format->get_array(source_i);
|
||||
int num_data_types = source_array_format->get_num_data_types();
|
||||
for (int di = 0; di < num_data_types; ++di) {
|
||||
const qpGeomVertexDataType *source_data_type = source_array_format->get_data_type(di);
|
||||
int num_columns = source_array_format->get_num_columns();
|
||||
for (int di = 0; di < num_columns; ++di) {
|
||||
const qpGeomVertexColumn *source_column = source_array_format->get_column(di);
|
||||
|
||||
int dest_i = dest_format->get_array_with(source_data_type->get_name());
|
||||
int dest_i = dest_format->get_array_with(source_column->get_name());
|
||||
if (dest_i >= 0 && done_arrays.count(dest_i) == 0) {
|
||||
// The data type exists in the new format; we have to copy it.
|
||||
const qpGeomVertexArrayFormat *dest_array_format =
|
||||
dest_format->get_array(dest_i);
|
||||
const qpGeomVertexDataType *dest_data_type =
|
||||
dest_array_format->get_data_type(source_data_type->get_name());
|
||||
const qpGeomVertexColumn *dest_column =
|
||||
dest_array_format->get_column(source_column->get_name());
|
||||
|
||||
if (dest_data_type->is_bytewise_equivalent(*source_data_type)) {
|
||||
if (dest_column->is_bytewise_equivalent(*source_column)) {
|
||||
// We can do a quick bytewise copy.
|
||||
PTA_uchar dest_array_data = modify_array(dest_i)->modify_data();
|
||||
|
||||
bytewise_copy(dest_array_data + dest_data_type->get_start(),
|
||||
bytewise_copy(dest_array_data + dest_column->get_start(),
|
||||
dest_array_format->get_stride(),
|
||||
array_data + source_data_type->get_start(), source_array_format->get_stride(),
|
||||
source_data_type, num_vertices);
|
||||
array_data + source_column->get_start(), source_array_format->get_stride(),
|
||||
source_column, num_vertices);
|
||||
|
||||
} else if (dest_data_type->is_packed_argb() &&
|
||||
source_data_type->is_uint8_rgba()) {
|
||||
} else if (dest_column->is_packed_argb() &&
|
||||
source_column->is_uint8_rgba()) {
|
||||
// A common special case: OpenGL color to DirectX color.
|
||||
PTA_uchar dest_array_data = modify_array(dest_i)->modify_data();
|
||||
|
||||
uint8_rgba_to_packed_argb
|
||||
(dest_array_data + dest_data_type->get_start(),
|
||||
(dest_array_data + dest_column->get_start(),
|
||||
dest_array_format->get_stride(),
|
||||
array_data + source_data_type->get_start(), source_array_format->get_stride(),
|
||||
array_data + source_column->get_start(), source_array_format->get_stride(),
|
||||
num_vertices);
|
||||
|
||||
} else if (dest_data_type->is_uint8_rgba() &&
|
||||
source_data_type->is_packed_argb()) {
|
||||
} else if (dest_column->is_uint8_rgba() &&
|
||||
source_column->is_packed_argb()) {
|
||||
// Another common special case: DirectX color to OpenGL
|
||||
// color.
|
||||
PTA_uchar dest_array_data = modify_array(dest_i)->modify_data();
|
||||
|
||||
packed_argb_to_uint8_rgba
|
||||
(dest_array_data + dest_data_type->get_start(),
|
||||
(dest_array_data + dest_column->get_start(),
|
||||
dest_array_format->get_stride(),
|
||||
array_data + source_data_type->get_start(), source_array_format->get_stride(),
|
||||
array_data + source_column->get_start(), source_array_format->get_stride(),
|
||||
num_vertices);
|
||||
|
||||
} else {
|
||||
// A generic copy.
|
||||
if (gobj_cat.is_debug()) {
|
||||
gobj_cat.debug()
|
||||
<< "generic copy " << *dest_data_type << " from "
|
||||
<< *source_data_type << "\n";
|
||||
<< "generic copy " << *dest_column << " from "
|
||||
<< *source_column << "\n";
|
||||
}
|
||||
qpGeomVertexWriter to(this);
|
||||
to.set_data_type(dest_i, dest_data_type);
|
||||
to.set_column(dest_i, dest_column);
|
||||
qpGeomVertexReader from(&source);
|
||||
from.set_data_type(source_i, source_data_type);
|
||||
from.set_column(source_i, source_column);
|
||||
|
||||
while (!from.is_at_end()) {
|
||||
to.set_data4f(from.get_data4f());
|
||||
|
|
@ -586,8 +586,8 @@ convert_to(const qpGeomVertexFormat *new_format) const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
CPT(qpGeomVertexData) qpGeomVertexData::
|
||||
scale_color(const LVecBase4f &color_scale, int num_components,
|
||||
qpGeomVertexDataType::NumericType numeric_type,
|
||||
qpGeomVertexDataType::Contents contents) const {
|
||||
qpGeomVertexColumn::NumericType numeric_type,
|
||||
qpGeomVertexColumn::Contents contents) const {
|
||||
int old_color_array = _format->get_array_with(InternalName::get_color());
|
||||
if (old_color_array == -1) {
|
||||
// Oops, no color anyway.
|
||||
|
|
@ -603,7 +603,7 @@ scale_color(const LVecBase4f &color_scale, int num_components,
|
|||
}
|
||||
PStatTimer timer(_scale_color_pcollector);
|
||||
|
||||
PT(qpGeomVertexData) new_data = replace_data_type
|
||||
PT(qpGeomVertexData) new_data = replace_column
|
||||
(InternalName::get_color(), num_components, numeric_type,
|
||||
contents, get_usage_hint(), true);
|
||||
|
||||
|
|
@ -634,8 +634,8 @@ scale_color(const LVecBase4f &color_scale, int num_components,
|
|||
////////////////////////////////////////////////////////////////////
|
||||
CPT(qpGeomVertexData) qpGeomVertexData::
|
||||
set_color(const Colorf &color, int num_components,
|
||||
qpGeomVertexDataType::NumericType numeric_type,
|
||||
qpGeomVertexDataType::Contents contents) const {
|
||||
qpGeomVertexColumn::NumericType numeric_type,
|
||||
qpGeomVertexColumn::Contents contents) const {
|
||||
int num_vertices = get_num_vertices();
|
||||
|
||||
if (gobj_cat.is_debug()) {
|
||||
|
|
@ -645,7 +645,7 @@ set_color(const Colorf &color, int num_components,
|
|||
}
|
||||
PStatTimer timer(_set_color_pcollector);
|
||||
|
||||
PT(qpGeomVertexData) new_data = replace_data_type
|
||||
PT(qpGeomVertexData) new_data = replace_column
|
||||
(InternalName::get_color(), num_components, numeric_type,
|
||||
contents, get_usage_hint(), true);
|
||||
|
||||
|
|
@ -660,7 +660,7 @@ set_color(const Colorf &color, int num_components,
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexData::replace_data_type
|
||||
// Function: qpGeomVertexData::replace_column
|
||||
// Access: Published
|
||||
// Description: Returns a new GeomVertexData object, suitable for
|
||||
// modification, with the indicated data type replaced
|
||||
|
|
@ -674,9 +674,9 @@ set_color(const Colorf &color, int num_components,
|
|||
// anything else.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PT(qpGeomVertexData) qpGeomVertexData::
|
||||
replace_data_type(const InternalName *name, int num_components,
|
||||
qpGeomVertexDataType::NumericType numeric_type,
|
||||
qpGeomVertexDataType::Contents contents,
|
||||
replace_column(const InternalName *name, int num_components,
|
||||
qpGeomVertexColumn::NumericType numeric_type,
|
||||
qpGeomVertexColumn::Contents contents,
|
||||
qpGeomUsageHint::UsageHint usage_hint,
|
||||
bool keep_animation) const {
|
||||
PT(qpGeomVertexFormat) new_format = new qpGeomVertexFormat(*_format);
|
||||
|
|
@ -686,7 +686,7 @@ replace_data_type(const InternalName *name, int num_components,
|
|||
int old_type_array = _format->get_array_with(name);
|
||||
if (old_type_array != -1) {
|
||||
qpGeomVertexArrayFormat *array_format = new_format->modify_array(old_type_array);
|
||||
if (array_format->get_num_data_types() == 1) {
|
||||
if (array_format->get_num_columns() == 1) {
|
||||
// Actually, this array didn't have any other data types, so
|
||||
// just drop the whole array.
|
||||
new_format->remove_array(old_type_array);
|
||||
|
|
@ -695,7 +695,7 @@ replace_data_type(const InternalName *name, int num_components,
|
|||
} else {
|
||||
// Remove the description for the type, but don't bother to
|
||||
// repack the array.
|
||||
array_format->remove_data_type(name);
|
||||
array_format->remove_column(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -799,16 +799,16 @@ bool qpGeomVertexData::
|
|||
get_array_info(const InternalName *name,
|
||||
const qpGeomVertexArrayData *&array_data,
|
||||
int &num_values,
|
||||
qpGeomVertexDataType::NumericType &numeric_type,
|
||||
qpGeomVertexColumn::NumericType &numeric_type,
|
||||
int &start, int &stride) const {
|
||||
int array_index;
|
||||
const qpGeomVertexDataType *data_type;
|
||||
if (_format->get_array_info(name, array_index, data_type)) {
|
||||
const qpGeomVertexColumn *column;
|
||||
if (_format->get_array_info(name, array_index, column)) {
|
||||
CDReader cdata(_cycler);
|
||||
array_data = cdata->_arrays[array_index];
|
||||
num_values = data_type->get_num_values();
|
||||
numeric_type = data_type->get_numeric_type();
|
||||
start = data_type->get_start();
|
||||
num_values = column->get_num_values();
|
||||
numeric_type = column->get_numeric_type();
|
||||
start = column->get_start();
|
||||
stride = _format->get_array(array_index)->get_stride();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -868,7 +868,7 @@ do_animate_vertices(bool from_app) const {
|
|||
void qpGeomVertexData::
|
||||
bytewise_copy(unsigned char *to, int to_stride,
|
||||
const unsigned char *from, int from_stride,
|
||||
const qpGeomVertexDataType *from_type,
|
||||
const qpGeomVertexColumn *from_type,
|
||||
int num_records) {
|
||||
if (gobj_cat.is_debug()) {
|
||||
gobj_cat.debug()
|
||||
|
|
@ -1033,8 +1033,8 @@ update_animated_vertices(qpGeomVertexData::CDWriter &cdata, bool from_app) {
|
|||
qpGeomVertexRewriter data(new_data, base_name);
|
||||
qpGeomVertexReader delta(this, delta_name);
|
||||
|
||||
if (data.get_data_type()->get_num_values() == 4) {
|
||||
if (data.get_data_type()->has_homogeneous_coord()) {
|
||||
if (data.get_column()->get_num_values() == 4) {
|
||||
if (data.get_column()->has_homogeneous_coord()) {
|
||||
for (int i = 0; i < num_vertices; i++) {
|
||||
// Scale the delta by the homogeneous coordinate.
|
||||
LPoint4f vertex = data.get_data4f();
|
||||
|
|
@ -1080,28 +1080,49 @@ update_animated_vertices(qpGeomVertexData::CDWriter &cdata, bool from_app) {
|
|||
}
|
||||
|
||||
// Now go through and apply the transforms.
|
||||
qpGeomVertexRewriter data(new_data, InternalName::get_vertex());
|
||||
qpGeomVertexReader blendi(this, InternalName::get_transform_blend());
|
||||
int ci;
|
||||
for (ci = 0; ci < _format->get_num_points(); ci++) {
|
||||
qpGeomVertexRewriter data(new_data, _format->get_point(ci));
|
||||
qpGeomVertexReader blendi(this, InternalName::get_transform_blend());
|
||||
|
||||
if (!blendi.has_data_type()) {
|
||||
gobj_cat.warning()
|
||||
<< "Vertex data " << get_name()
|
||||
<< " has a transform_blend_palette, but no transform_blend data.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.get_data_type()->get_num_values() == 4) {
|
||||
for (int i = 0; i < num_vertices; i++) {
|
||||
LPoint4f vertex = data.get_data4f();
|
||||
int bi = blendi.get_data1i();
|
||||
palette->get_blend(bi).transform_point(vertex);
|
||||
data.set_data4f(vertex);
|
||||
if (!blendi.has_column()) {
|
||||
gobj_cat.warning()
|
||||
<< "Vertex data " << get_name()
|
||||
<< " has a transform_blend_palette, but no transform_blend data.\n";
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (data.get_column()->get_num_values() == 4) {
|
||||
for (int i = 0; i < num_vertices; i++) {
|
||||
LPoint4f vertex = data.get_data4f();
|
||||
int bi = blendi.get_data1i();
|
||||
palette->get_blend(bi).transform_point(vertex);
|
||||
data.set_data4f(vertex);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < num_vertices; i++) {
|
||||
LPoint3f vertex = data.get_data3f();
|
||||
int bi = blendi.get_data1i();
|
||||
palette->get_blend(bi).transform_point(vertex);
|
||||
data.set_data3f(vertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ci = 0; ci < _format->get_num_vectors(); ci++) {
|
||||
qpGeomVertexRewriter data(new_data, _format->get_vector(ci));
|
||||
qpGeomVertexReader blendi(this, InternalName::get_transform_blend());
|
||||
|
||||
if (!blendi.has_column()) {
|
||||
gobj_cat.warning()
|
||||
<< "Vertex data " << get_name()
|
||||
<< " has a transform_blend_palette, but no transform_blend data.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_vertices; i++) {
|
||||
LPoint3f vertex = data.get_data3f();
|
||||
LVector3f vertex = data.get_data3f();
|
||||
int bi = blendi.get_data1i();
|
||||
palette->get_blend(bi).transform_point(vertex);
|
||||
palette->get_blend(bi).transform_vector(vertex);
|
||||
data.set_data3f(vertex);
|
||||
}
|
||||
}
|
||||
|
|
@ -1120,12 +1141,12 @@ CPT(qpGeomVertexFormat) qpGeomVertexData::
|
|||
get_post_animated_format() const {
|
||||
PT(qpGeomVertexFormat) new_format = new qpGeomVertexFormat(*_format);
|
||||
|
||||
new_format->remove_data_type(InternalName::get_transform_blend());
|
||||
new_format->remove_column(InternalName::get_transform_blend());
|
||||
|
||||
int num_morphs = _format->get_num_morphs();
|
||||
for (int mi = 0; mi < num_morphs; mi++) {
|
||||
CPT(InternalName) delta_name = _format->get_morph_delta(mi);
|
||||
new_format->remove_data_type(delta_name);
|
||||
new_format->remove_column(delta_name);
|
||||
}
|
||||
|
||||
return qpGeomVertexFormat::register_format(new_format);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include "pandabase.h"
|
||||
#include "typedWritableReferenceCount.h"
|
||||
#include "qpgeomVertexFormat.h"
|
||||
#include "qpgeomVertexDataType.h"
|
||||
#include "qpgeomVertexColumn.h"
|
||||
#include "qpgeomVertexArrayData.h"
|
||||
#include "qpgeomUsageHint.h"
|
||||
#include "transformPalette.h"
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
#include "pvector.h"
|
||||
|
||||
class FactoryParams;
|
||||
class qpGeomVertexDataType;
|
||||
class qpGeomVertexColumn;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : qpGeomVertexData
|
||||
|
|
@ -47,18 +47,22 @@ class qpGeomVertexDataType;
|
|||
// a Geom, in the structure defined by a particular
|
||||
// GeomVertexFormat object.
|
||||
//
|
||||
// The data consists of one or more arrays of floats.
|
||||
// Typically, there will be only one array per Geom, and
|
||||
// the various data types defined in the
|
||||
// GeomVertexFormat will be interleaved throughout that
|
||||
// array. However, it is possible to have multiple
|
||||
// different arrays, with different combinations of data
|
||||
// types through each one.
|
||||
// The data consists of one or more arrays, each of
|
||||
// which in turn consists of a series of rows, one per
|
||||
// vertex. All arrays should have the same number of
|
||||
// rows; each vertex is defined by the column data from
|
||||
// a particular row across all arrays.
|
||||
//
|
||||
// Often, there will be only one array per Geom, and the
|
||||
// various columns defined in the GeomVertexFormat will
|
||||
// be interleaved within that array. However, it is
|
||||
// also possible to have multiple different arrays, with
|
||||
// a certain subset of the total columns defined in each
|
||||
// array.
|
||||
//
|
||||
// However the data is distributed, the effect is of a
|
||||
// table of vertices, with a value for each of the
|
||||
// GeomVertexFormat's data types, stored for each
|
||||
// vertex.
|
||||
// single table of vertices, where each vertex is
|
||||
// represented by one row of the table.
|
||||
//
|
||||
// This is part of the experimental Geom rewrite.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -110,19 +114,19 @@ PUBLISHED:
|
|||
CPT(qpGeomVertexData) convert_to(const qpGeomVertexFormat *new_format) const;
|
||||
CPT(qpGeomVertexData)
|
||||
scale_color(const LVecBase4f &color_scale, int num_components,
|
||||
qpGeomVertexDataType::NumericType numeric_type,
|
||||
qpGeomVertexDataType::Contents contents) const;
|
||||
qpGeomVertexColumn::NumericType numeric_type,
|
||||
qpGeomVertexColumn::Contents contents) const;
|
||||
CPT(qpGeomVertexData)
|
||||
set_color(const Colorf &color, int num_components,
|
||||
qpGeomVertexDataType::NumericType numeric_type,
|
||||
qpGeomVertexDataType::Contents contents) const;
|
||||
qpGeomVertexColumn::NumericType numeric_type,
|
||||
qpGeomVertexColumn::Contents contents) const;
|
||||
|
||||
INLINE CPT(qpGeomVertexData) animate_vertices() const;
|
||||
|
||||
PT(qpGeomVertexData)
|
||||
replace_data_type(const InternalName *name, int num_components,
|
||||
qpGeomVertexDataType::NumericType numeric_type,
|
||||
qpGeomVertexDataType::Contents contents,
|
||||
replace_column(const InternalName *name, int num_components,
|
||||
qpGeomVertexColumn::NumericType numeric_type,
|
||||
qpGeomVertexColumn::Contents contents,
|
||||
qpGeomUsageHint::UsageHint usage_hint,
|
||||
bool keep_animation) const;
|
||||
|
||||
|
|
@ -135,7 +139,7 @@ public:
|
|||
bool get_array_info(const InternalName *name,
|
||||
const qpGeomVertexArrayData *&array_data,
|
||||
int &num_values,
|
||||
qpGeomVertexDataType::NumericType &numeric_type,
|
||||
qpGeomVertexColumn::NumericType &numeric_type,
|
||||
int &start, int &stride) const;
|
||||
|
||||
static INLINE PN_uint32 pack_abcd(unsigned int a, unsigned int b,
|
||||
|
|
@ -150,7 +154,7 @@ private:
|
|||
|
||||
static void bytewise_copy(unsigned char *to, int to_stride,
|
||||
const unsigned char *from, int from_stride,
|
||||
const qpGeomVertexDataType *from_type,
|
||||
const qpGeomVertexColumn *from_type,
|
||||
int num_records);
|
||||
static void
|
||||
packed_argb_to_uint8_rgba(unsigned char *to, int to_stride,
|
||||
|
|
|
|||
|
|
@ -122,20 +122,85 @@ get_array(int array) const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::has_data_type
|
||||
// Function: qpGeomVertexFormat::has_column
|
||||
// Access: Published
|
||||
// Description: Returns true if the format has the named data type,
|
||||
// Description: Returns true if the format has the named column,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexFormat::
|
||||
has_data_type(const InternalName *name) const {
|
||||
return (get_data_type(name) != (qpGeomVertexDataType *)NULL);
|
||||
has_column(const InternalName *name) const {
|
||||
return (get_column(name) != (qpGeomVertexColumn *)NULL);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::get_num_points
|
||||
// Access: Published
|
||||
// Description: Returns the number of columns within the format
|
||||
// that represent points in space.
|
||||
//
|
||||
// This may only be called after the format has been
|
||||
// registered.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexFormat::
|
||||
get_num_points() const {
|
||||
nassertr(_is_registered, 0);
|
||||
return _points.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::get_point
|
||||
// Access: Published
|
||||
// Description: Returns the name of the nth point column. This
|
||||
// represents a point in space, which should be
|
||||
// transformed by any spatial transform matrix.
|
||||
//
|
||||
// This may only be called after the format has been
|
||||
// registered.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const InternalName *qpGeomVertexFormat::
|
||||
get_point(int n) const {
|
||||
nassertr(_is_registered, NULL);
|
||||
nassertr(n >= 0 && n < (int)_points.size(), NULL);
|
||||
return _points[n];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::get_num_vectors
|
||||
// Access: Published
|
||||
// Description: Returns the number of columns within the format
|
||||
// that represent directional vectors.
|
||||
//
|
||||
// This may only be called after the format has been
|
||||
// registered.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexFormat::
|
||||
get_num_vectors() const {
|
||||
nassertr(_is_registered, 0);
|
||||
return _vectors.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::get_vector
|
||||
// Access: Published
|
||||
// Description: Returns the name of the nth vector column. This
|
||||
// represents a directional vector, which should be
|
||||
// transformed by any spatial transform matrix as a
|
||||
// vector.
|
||||
//
|
||||
// This may only be called after the format has been
|
||||
// registered.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const InternalName *qpGeomVertexFormat::
|
||||
get_vector(int n) const {
|
||||
nassertr(_is_registered, NULL);
|
||||
nassertr(n >= 0 && n < (int)_vectors.size(), NULL);
|
||||
return _vectors[n];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::get_num_morphs
|
||||
// Access: Published
|
||||
// Description: Returns the number of data types within the format
|
||||
// Description: Returns the number of columns within the format
|
||||
// that represent morph deltas.
|
||||
//
|
||||
// This may only be called after the format has been
|
||||
|
|
@ -152,7 +217,7 @@ get_num_morphs() const {
|
|||
// Function: qpGeomVertexFormat::get_morph_slider
|
||||
// Access: Published
|
||||
// Description: Returns the slider name associated with the nth morph
|
||||
// data type. This is the name of the slider that will
|
||||
// column. This is the name of the slider that will
|
||||
// control the morph, and should be defined within the
|
||||
// SliderTable associated with the GeomVertexData.
|
||||
//
|
||||
|
|
@ -170,10 +235,10 @@ get_morph_slider(int n) const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::get_morph_base
|
||||
// Access: Published
|
||||
// Description: Returns the name of the base data type that the nth
|
||||
// morph modifies. This data type will also be defined
|
||||
// Description: Returns the name of the base column that the nth
|
||||
// morph modifies. This column will also be defined
|
||||
// within the format, and can be retrieved via
|
||||
// get_array_with() and/or get_data_type().
|
||||
// get_array_with() and/or get_column().
|
||||
//
|
||||
// This may only be called after the format has been
|
||||
// registered.
|
||||
|
|
@ -189,12 +254,12 @@ get_morph_base(int n) const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::get_morph_delta
|
||||
// Access: Published
|
||||
// Description: Returns the name of the data type that defines the
|
||||
// Description: Returns the name of the column that defines the
|
||||
// nth morph. This contains the delta offsets that are
|
||||
// to be applied to the data type defined by
|
||||
// get_morph_base(). This data type will be defined
|
||||
// to be applied to the column defined by
|
||||
// get_morph_base(). This column will be defined
|
||||
// within the format, and can be retrieved via
|
||||
// get_array_with() and/or get_data_type().
|
||||
// get_array_with() and/or get_column().
|
||||
//
|
||||
// This may only be called after the format has been
|
||||
// registered.
|
||||
|
|
|
|||
|
|
@ -198,35 +198,35 @@ clear_arrays() {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::get_num_data_types
|
||||
// Function: qpGeomVertexFormat::get_num_columns
|
||||
// Access: Published
|
||||
// Description: Returns the total number of different data types in
|
||||
// Description: Returns the total number of different columns in
|
||||
// the specification, across all arrays.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int qpGeomVertexFormat::
|
||||
get_num_data_types() const {
|
||||
int num_data_types = 0;
|
||||
get_num_columns() const {
|
||||
int num_columns = 0;
|
||||
Arrays::const_iterator ai;
|
||||
for (ai = _arrays.begin(); ai != _arrays.end(); ++ai) {
|
||||
num_data_types += (*ai)->get_num_data_types();
|
||||
num_columns += (*ai)->get_num_columns();
|
||||
}
|
||||
return num_data_types;
|
||||
return num_columns;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::get_data_type
|
||||
// Function: qpGeomVertexFormat::get_column
|
||||
// Access: Published
|
||||
// Description: Returns the ith data type of the specification,
|
||||
// Description: Returns the ith column of the specification,
|
||||
// across all arrays.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const qpGeomVertexDataType *qpGeomVertexFormat::
|
||||
get_data_type(int i) const {
|
||||
const qpGeomVertexColumn *qpGeomVertexFormat::
|
||||
get_column(int i) const {
|
||||
Arrays::const_iterator ai;
|
||||
for (ai = _arrays.begin(); ai != _arrays.end(); ++ai) {
|
||||
if (i < (*ai)->get_num_data_types()) {
|
||||
return (*ai)->get_data_type(i);
|
||||
if (i < (*ai)->get_num_columns()) {
|
||||
return (*ai)->get_column(i);
|
||||
}
|
||||
i -= (*ai)->get_num_data_types();
|
||||
i -= (*ai)->get_num_columns();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
@ -236,7 +236,7 @@ get_data_type(int i) const {
|
|||
// Function: qpGeomVertexFormat::get_array_with
|
||||
// Access: Published
|
||||
// Description: Returns the index number of the array with the
|
||||
// ith data type.
|
||||
// ith column.
|
||||
//
|
||||
// The return value can be passed to get_array_format()
|
||||
// to get the format of the array. It may also be
|
||||
|
|
@ -248,10 +248,10 @@ int qpGeomVertexFormat::
|
|||
get_array_with(int i) const {
|
||||
int array_index = 0;
|
||||
for (array_index = 0; array_index < (int)_arrays.size(); array_index++) {
|
||||
if (i < _arrays[array_index]->get_num_data_types()) {
|
||||
if (i < _arrays[array_index]->get_num_columns()) {
|
||||
return array_index;
|
||||
}
|
||||
i -= _arrays[array_index]->get_num_data_types();
|
||||
i -= _arrays[array_index]->get_num_columns();
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
@ -261,7 +261,7 @@ get_array_with(int i) const {
|
|||
// Function: qpGeomVertexFormat::get_array_with
|
||||
// Access: Published
|
||||
// Description: Returns the index number of the array with the
|
||||
// indicated data type, or -1 if no arrays contained
|
||||
// indicated column, or -1 if no arrays contained
|
||||
// that name.
|
||||
//
|
||||
// The return value can be passed to get_array_format()
|
||||
|
|
@ -278,65 +278,65 @@ get_array_with(const InternalName *name) const {
|
|||
nassertr(_is_registered, -1);
|
||||
|
||||
DataTypesByName::const_iterator ai;
|
||||
ai = _data_types_by_name.find(name);
|
||||
if (ai != _data_types_by_name.end()) {
|
||||
ai = _columns_by_name.find(name);
|
||||
if (ai != _columns_by_name.end()) {
|
||||
return (*ai).second._array_index;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::get_data_type
|
||||
// Function: qpGeomVertexFormat::get_column
|
||||
// Access: Published
|
||||
// Description: Returns the specification with the indicated name, or
|
||||
// NULL if the name is not used. Use get_array_with()
|
||||
// to determine which array this data type is associated
|
||||
// to determine which array this column is associated
|
||||
// with.
|
||||
//
|
||||
// This may only be called after the format has been
|
||||
// registered.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const qpGeomVertexDataType *qpGeomVertexFormat::
|
||||
get_data_type(const InternalName *name) const {
|
||||
const qpGeomVertexColumn *qpGeomVertexFormat::
|
||||
get_column(const InternalName *name) const {
|
||||
nassertr(_is_registered, NULL);
|
||||
|
||||
DataTypesByName::const_iterator ai;
|
||||
ai = _data_types_by_name.find(name);
|
||||
if (ai != _data_types_by_name.end()) {
|
||||
ai = _columns_by_name.find(name);
|
||||
if (ai != _columns_by_name.end()) {
|
||||
int array_index = (*ai).second._array_index;
|
||||
int data_type_index = (*ai).second._data_type_index;
|
||||
int column_index = (*ai).second._column_index;
|
||||
|
||||
nassertr(array_index >= 0 && array_index < (int)_arrays.size(), NULL);
|
||||
return _arrays[array_index]->get_data_type(data_type_index);
|
||||
return _arrays[array_index]->get_column(column_index);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::remove_data_type
|
||||
// Function: qpGeomVertexFormat::remove_column
|
||||
// Access: Published
|
||||
// Description: Removes the named data type from the format, from
|
||||
// Description: Removes the named column from the format, from
|
||||
// whichever array it exists in. If there are other
|
||||
// data types remaining in the array, the array is left
|
||||
// with a gap where the data type used to be; if this
|
||||
// was the only data type in the array, the array is
|
||||
// columns remaining in the array, the array is left
|
||||
// with a gap where the column used to be; if this
|
||||
// was the only column in the array, the array is
|
||||
// removed.
|
||||
//
|
||||
// This may not be called once the format has been
|
||||
// registered.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexFormat::
|
||||
remove_data_type(const InternalName *name) {
|
||||
remove_column(const InternalName *name) {
|
||||
nassertv(!_is_registered);
|
||||
|
||||
// Since the format's not registered, it doesn't yet have an index
|
||||
// of data types--so we have to search all of the arrays, one at a
|
||||
// of columns--so we have to search all of the arrays, one at a
|
||||
// time, until we find it.
|
||||
for (int array = 0; array < (int)_arrays.size(); ++array) {
|
||||
qpGeomVertexArrayFormat *array_format = _arrays[array];
|
||||
|
||||
if (array_format->get_data_type(name) != (qpGeomVertexDataType *)NULL) {
|
||||
// Here's the array with the named data type!
|
||||
if (array_format->get_column(name) != (qpGeomVertexColumn *)NULL) {
|
||||
// Here's the array with the named column!
|
||||
if (array_format->is_registered() ||
|
||||
array_format->get_ref_count() > 1) {
|
||||
// Get a safe-to-modify copy of the array format.
|
||||
|
|
@ -344,10 +344,10 @@ remove_data_type(const InternalName *name) {
|
|||
array_format = _arrays[array];
|
||||
}
|
||||
|
||||
array_format->remove_data_type(name);
|
||||
array_format->remove_column(name);
|
||||
|
||||
// Are there any data types remaining in the array?
|
||||
if (array_format->get_num_data_types() == 0) {
|
||||
// Are there any columns remaining in the array?
|
||||
if (array_format->get_num_columns() == 0) {
|
||||
// Remove the whole array.
|
||||
remove_array(array);
|
||||
}
|
||||
|
|
@ -355,7 +355,7 @@ remove_data_type(const InternalName *name) {
|
|||
}
|
||||
}
|
||||
|
||||
// It appears that data type wasn't part of the format anyway. No
|
||||
// It appears that column wasn't part of the format anyway. No
|
||||
// problem; quietly return.
|
||||
}
|
||||
|
||||
|
|
@ -420,9 +420,9 @@ write_with_data(ostream &out, int indent_level,
|
|||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::get_array_info
|
||||
// Access: Public
|
||||
// Description: Quickly looks up the indicated data type within all
|
||||
// Description: Quickly looks up the indicated column within all
|
||||
// of the nested arrays and sets array_index and
|
||||
// data_type appropriately. Returns true if the data
|
||||
// column appropriately. Returns true if the data
|
||||
// type exists in this format, false if it does not.
|
||||
//
|
||||
// This may only be called after the format has been
|
||||
|
|
@ -430,14 +430,14 @@ write_with_data(ostream &out, int indent_level,
|
|||
////////////////////////////////////////////////////////////////////
|
||||
bool qpGeomVertexFormat::
|
||||
get_array_info(const InternalName *name, int &array_index,
|
||||
const qpGeomVertexDataType *&data_type) const {
|
||||
const qpGeomVertexColumn *&column) const {
|
||||
nassertr(_is_registered, false);
|
||||
|
||||
DataTypesByName::const_iterator ai;
|
||||
ai = _data_types_by_name.find(name);
|
||||
if (ai != _data_types_by_name.end()) {
|
||||
ai = _columns_by_name.find(name);
|
||||
if (ai != _columns_by_name.end()) {
|
||||
array_index = (*ai).second._array_index;
|
||||
data_type = _arrays[array_index]->get_data_type((*ai).second._data_type_index);
|
||||
column = _arrays[array_index]->get_column((*ai).second._column_index);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -489,7 +489,7 @@ make_registry() {
|
|||
void qpGeomVertexFormat::
|
||||
do_register() {
|
||||
nassertv(!_is_registered);
|
||||
nassertv(_data_types_by_name.empty());
|
||||
nassertv(_columns_by_name.empty());
|
||||
|
||||
for (int array = 0; array < (int)_arrays.size(); ++array) {
|
||||
const qpGeomVertexArrayFormat *array_format = _arrays[array];
|
||||
|
|
@ -498,54 +498,74 @@ do_register() {
|
|||
}
|
||||
|
||||
// Now add the names to the index.
|
||||
int num_data_types = array_format->get_num_data_types();
|
||||
for (int i = 0; i < num_data_types; i++) {
|
||||
const qpGeomVertexDataType *data_type = array_format->get_data_type(i);
|
||||
int num_columns = array_format->get_num_columns();
|
||||
for (int i = 0; i < num_columns; i++) {
|
||||
const qpGeomVertexColumn *column = array_format->get_column(i);
|
||||
pair<DataTypesByName::iterator, bool> result;
|
||||
result = _data_types_by_name.insert(DataTypesByName::value_type(data_type->get_name(), DataTypeRecord()));
|
||||
result = _columns_by_name.insert(DataTypesByName::value_type(column->get_name(), DataTypeRecord()));
|
||||
if (!result.second) {
|
||||
gobj_cat.warning()
|
||||
<< "Data type " << data_type->get_name() << " repeated in format.\n";
|
||||
<< "Column " << column->get_name() << " repeated in format.\n";
|
||||
} else {
|
||||
DataTypeRecord &record = (*result.first).second;
|
||||
record._array_index = array;
|
||||
record._data_type_index = i;
|
||||
record._column_index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Go back through the index now and look for morph descriptions.
|
||||
// Go back through the index now and identify the points, vectors,
|
||||
// and morph descriptions, so we can quickly look these up later.
|
||||
DataTypesByName::iterator ni;
|
||||
for (ni = _data_types_by_name.begin();
|
||||
ni != _data_types_by_name.end();
|
||||
for (ni = _columns_by_name.begin();
|
||||
ni != _columns_by_name.end();
|
||||
++ni) {
|
||||
const DataTypeRecord &record = (*ni).second;
|
||||
const qpGeomVertexDataType *data_type = _arrays[record._array_index]->get_data_type(record._data_type_index);
|
||||
const qpGeomVertexColumn *column = _arrays[record._array_index]->get_column(record._column_index);
|
||||
|
||||
// Is it a morph description?
|
||||
if (data_type->get_contents() == qpGeomVertexDataType::C_morph_delta) {
|
||||
MorphRecord morph;
|
||||
morph._delta = data_type->get_name();
|
||||
|
||||
// The delta name must be of the form "basename.morph.slidername".
|
||||
int n = morph._delta->find_ancestor("morph");
|
||||
if (n < 0) {
|
||||
gobj_cat.warning()
|
||||
<< "vertex format defines " << *data_type->get_name()
|
||||
<< ", which is stored as a C_morph_delta, but its name does not include \"morph\".\n";
|
||||
} else {
|
||||
morph._slider = InternalName::make(morph._delta->get_net_basename(n - 1));
|
||||
morph._base = morph._delta->get_ancestor(n + 1);
|
||||
switch (column->get_contents()) {
|
||||
case qpGeomVertexColumn::C_point:
|
||||
// It's a point.
|
||||
_points.push_back(column->get_name());
|
||||
break;
|
||||
|
||||
if (_data_types_by_name.find(morph._base) == _data_types_by_name.end()) {
|
||||
case qpGeomVertexColumn::C_vector:
|
||||
// It's a vector.
|
||||
_vectors.push_back(column->get_name());
|
||||
break;
|
||||
|
||||
case qpGeomVertexColumn::C_morph_delta:
|
||||
{
|
||||
// It's a morph description.
|
||||
MorphRecord morph;
|
||||
morph._delta = column->get_name();
|
||||
|
||||
// The delta name must be of the form "basename.morph.slidername".
|
||||
int n = morph._delta->find_ancestor("morph");
|
||||
if (n < 0) {
|
||||
gobj_cat.warning()
|
||||
<< "vertex format defines "
|
||||
<< *data_type->get_name() << " but does not define "
|
||||
<< *morph._base << "\n";
|
||||
<< "vertex format defines " << *column->get_name()
|
||||
<< ", which is stored as a C_morph_delta, but its name does not include \"morph\".\n";
|
||||
} else {
|
||||
_morphs.push_back(morph);
|
||||
morph._slider = InternalName::make(morph._delta->get_net_basename(n - 1));
|
||||
morph._base = morph._delta->get_ancestor(n + 1);
|
||||
|
||||
if (_columns_by_name.find(morph._base) == _columns_by_name.end()) {
|
||||
gobj_cat.warning()
|
||||
<< "vertex format defines "
|
||||
<< *column->get_name() << " but does not define "
|
||||
<< *morph._base << "\n";
|
||||
} else {
|
||||
_morphs.push_back(morph);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Some other type of value we don't care about caching a
|
||||
// pointer to.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -563,7 +583,10 @@ do_unregister() {
|
|||
nassertv(_is_registered);
|
||||
_is_registered = false;
|
||||
|
||||
_data_types_by_name.clear();
|
||||
_columns_by_name.clear();
|
||||
_points.clear();
|
||||
_vectors.clear();
|
||||
_morphs.clear();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -644,127 +667,127 @@ qpGeomVertexFormat::Registry::
|
|||
Registry() {
|
||||
_v3 = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point));
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point));
|
||||
|
||||
_v3n3 = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_normal(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_vector));
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_vector));
|
||||
|
||||
_v3t2 = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_texcoord(), 2,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_texcoord));
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_texcoord));
|
||||
|
||||
_v3n3t2 = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_normal(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_vector,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_vector,
|
||||
InternalName::get_texcoord(), 2,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_texcoord));
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_texcoord));
|
||||
|
||||
// Define the DirectX-style packed color formats
|
||||
_v3cp = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_color(), 1,
|
||||
qpGeomVertexDataType::NT_packed_dabc,
|
||||
qpGeomVertexDataType::C_color));
|
||||
qpGeomVertexColumn::NT_packed_dabc,
|
||||
qpGeomVertexColumn::C_color));
|
||||
|
||||
_v3n3cp = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_normal(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_color(), 1,
|
||||
qpGeomVertexDataType::NT_packed_dabc,
|
||||
qpGeomVertexDataType::C_color));
|
||||
qpGeomVertexColumn::NT_packed_dabc,
|
||||
qpGeomVertexColumn::C_color));
|
||||
|
||||
_v3cpt2 = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_color(), 1,
|
||||
qpGeomVertexDataType::NT_packed_dabc,
|
||||
qpGeomVertexDataType::C_color,
|
||||
qpGeomVertexColumn::NT_packed_dabc,
|
||||
qpGeomVertexColumn::C_color,
|
||||
InternalName::get_texcoord(), 2,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_texcoord));
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_texcoord));
|
||||
|
||||
_v3n3cpt2 = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_normal(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_color(), 1,
|
||||
qpGeomVertexDataType::NT_packed_dabc,
|
||||
qpGeomVertexDataType::C_color,
|
||||
qpGeomVertexColumn::NT_packed_dabc,
|
||||
qpGeomVertexColumn::C_color,
|
||||
InternalName::get_texcoord(), 2,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_texcoord));
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::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,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_color(), 4,
|
||||
qpGeomVertexDataType::NT_uint8,
|
||||
qpGeomVertexDataType::C_color));
|
||||
qpGeomVertexColumn::NT_uint8,
|
||||
qpGeomVertexColumn::C_color));
|
||||
|
||||
_v3n3c4 = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_normal(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_color(), 4,
|
||||
qpGeomVertexDataType::NT_uint8,
|
||||
qpGeomVertexDataType::C_color));
|
||||
qpGeomVertexColumn::NT_uint8,
|
||||
qpGeomVertexColumn::C_color));
|
||||
|
||||
_v3c4t2 = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_color(), 4,
|
||||
qpGeomVertexDataType::NT_uint8,
|
||||
qpGeomVertexDataType::C_color,
|
||||
qpGeomVertexColumn::NT_uint8,
|
||||
qpGeomVertexColumn::C_color,
|
||||
InternalName::get_texcoord(), 2,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_texcoord));
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_texcoord));
|
||||
|
||||
_v3n3c4t2 = register_format(new qpGeomVertexArrayFormat
|
||||
(InternalName::get_vertex(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_normal(), 3,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_point,
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_point,
|
||||
InternalName::get_color(), 4,
|
||||
qpGeomVertexDataType::NT_uint8,
|
||||
qpGeomVertexDataType::C_color,
|
||||
qpGeomVertexColumn::NT_uint8,
|
||||
qpGeomVertexColumn::C_color,
|
||||
InternalName::get_texcoord(), 2,
|
||||
qpGeomVertexDataType::NT_float32,
|
||||
qpGeomVertexDataType::C_texcoord));
|
||||
qpGeomVertexColumn::NT_float32,
|
||||
qpGeomVertexColumn::C_texcoord));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -39,19 +39,28 @@ class qpGeomMunger;
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : qpGeomVertexFormat
|
||||
// Description : This class defines the layout of the vertex data
|
||||
// arrays stored within a Geom. The data within a Geom
|
||||
// is typically stored within a single interleaved
|
||||
// array, but it may also be distributed among multiple
|
||||
// different arrays. Each array is described by a
|
||||
// qpGeomVertexArrayFormat object, referenced within
|
||||
// this object.
|
||||
// Description : This class defines the physical layout of the vertex
|
||||
// data stored within a Geom. The layout consists of a
|
||||
// list of named columns, each of which has a numeric
|
||||
// type and a size.
|
||||
//
|
||||
// There are a number of standard pre-defined
|
||||
// The columns are typically interleaved within a single
|
||||
// array, but they may also be distributed among
|
||||
// multiple different arrays; at the extreme, each
|
||||
// column may be alone within its own array (which
|
||||
// amounts to a parallel-array definition).
|
||||
//
|
||||
// Thus, a GeomVertexFormat is really a list of
|
||||
// GeomVertexArrayFormats, each of which contains a list
|
||||
// of columns. However, a particular column name should
|
||||
// not appear more than once in the format, even between
|
||||
// different arrays.
|
||||
//
|
||||
// There are a handful of standard pre-defined
|
||||
// GeomVertexFormat objects, or you may define your own
|
||||
// as needed. You may also record any combination of
|
||||
// standard and/or user-defined data types in your
|
||||
// custom GeomVertexFormat constructions.
|
||||
// as needed. You may record any combination of
|
||||
// standard and/or user-defined columns in your custom
|
||||
// GeomVertexFormat constructions.
|
||||
//
|
||||
// This is part of the experimental Geom rewrite.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -79,15 +88,21 @@ PUBLISHED:
|
|||
void insert_array(int array, qpGeomVertexArrayFormat *array_format);
|
||||
void clear_arrays();
|
||||
|
||||
int get_num_data_types() const;
|
||||
int get_num_columns() const;
|
||||
int get_array_with(int i) const;
|
||||
const qpGeomVertexDataType *get_data_type(int i) const;
|
||||
const qpGeomVertexColumn *get_column(int i) const;
|
||||
|
||||
int get_array_with(const InternalName *name) const;
|
||||
const qpGeomVertexDataType *get_data_type(const InternalName *name) const;
|
||||
INLINE bool has_data_type(const InternalName *name) const;
|
||||
const qpGeomVertexColumn *get_column(const InternalName *name) const;
|
||||
INLINE bool has_column(const InternalName *name) const;
|
||||
|
||||
void remove_data_type(const InternalName *name);
|
||||
void remove_column(const InternalName *name);
|
||||
|
||||
INLINE int get_num_points() const;
|
||||
INLINE const InternalName *get_point(int n) const;
|
||||
|
||||
INLINE int get_num_vectors() const;
|
||||
INLINE const InternalName *get_vector(int n) const;
|
||||
|
||||
INLINE int get_num_morphs() const;
|
||||
INLINE const InternalName *get_morph_slider(int n) const;
|
||||
|
|
@ -130,7 +145,7 @@ PUBLISHED:
|
|||
public:
|
||||
bool get_array_info(const InternalName *name,
|
||||
int &array_index,
|
||||
const qpGeomVertexDataType *&data_type) const;
|
||||
const qpGeomVertexColumn *&column) const;
|
||||
|
||||
int compare_to(const qpGeomVertexFormat &other) const;
|
||||
|
||||
|
|
@ -152,11 +167,15 @@ private:
|
|||
class DataTypeRecord {
|
||||
public:
|
||||
int _array_index;
|
||||
int _data_type_index;
|
||||
int _column_index;
|
||||
};
|
||||
|
||||
typedef pmap<const InternalName *, DataTypeRecord> DataTypesByName;
|
||||
DataTypesByName _data_types_by_name;
|
||||
DataTypesByName _columns_by_name;
|
||||
|
||||
typedef pvector< CPT(InternalName) > Columns;
|
||||
Columns _points;
|
||||
Columns _vectors;
|
||||
|
||||
class MorphRecord {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ INLINE qpGeomVertexReader::
|
|||
qpGeomVertexReader(const qpGeomVertexData *vertex_data) :
|
||||
_vertex_data(vertex_data),
|
||||
_array(0),
|
||||
_data_type(NULL),
|
||||
_column(NULL),
|
||||
_pointer(NULL),
|
||||
_start_vertex(0),
|
||||
_read_vertex(0),
|
||||
|
|
@ -47,14 +47,14 @@ INLINE qpGeomVertexReader::
|
|||
qpGeomVertexReader(const qpGeomVertexData *vertex_data, const string &name) :
|
||||
_vertex_data(vertex_data),
|
||||
_array(0),
|
||||
_data_type(NULL),
|
||||
_column(NULL),
|
||||
_pointer(NULL),
|
||||
_start_vertex(0),
|
||||
_read_vertex(0),
|
||||
_num_vertices(0),
|
||||
_reader(NULL)
|
||||
{
|
||||
set_data_type(name);
|
||||
set_column(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -69,14 +69,14 @@ qpGeomVertexReader(const qpGeomVertexData *vertex_data,
|
|||
const InternalName *name) :
|
||||
_vertex_data(vertex_data),
|
||||
_array(0),
|
||||
_data_type(NULL),
|
||||
_column(NULL),
|
||||
_pointer(NULL),
|
||||
_start_vertex(0),
|
||||
_read_vertex(0),
|
||||
_num_vertices(0),
|
||||
_reader(NULL)
|
||||
{
|
||||
set_data_type(name);
|
||||
set_column(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -104,7 +104,7 @@ get_vertex_data() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexReader::set_data_type
|
||||
// Function: qpGeomVertexReader::set_column
|
||||
// Access: Published
|
||||
// Description: Sets up the reader to use the nth data type of the
|
||||
// GeomVertexFormat, numbering from 0.
|
||||
|
|
@ -117,13 +117,13 @@ get_vertex_data() const {
|
|||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexReader::
|
||||
set_data_type(int data_type) {
|
||||
return set_data_type(_vertex_data->get_format()->get_array_with(data_type),
|
||||
_vertex_data->get_format()->get_data_type(data_type));
|
||||
set_column(int column) {
|
||||
return set_column(_vertex_data->get_format()->get_array_with(column),
|
||||
_vertex_data->get_format()->get_column(column));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexReader::set_data_type
|
||||
// Function: qpGeomVertexReader::set_column
|
||||
// Access: Published
|
||||
// Description: Sets up the reader to use the data type with the
|
||||
// indicated name.
|
||||
|
|
@ -136,12 +136,12 @@ set_data_type(int data_type) {
|
|||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexReader::
|
||||
set_data_type(const string &name) {
|
||||
return set_data_type(InternalName::make(name));
|
||||
set_column(const string &name) {
|
||||
return set_column(InternalName::make(name));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexReader::set_data_type
|
||||
// Function: qpGeomVertexReader::set_column
|
||||
// Access: Published
|
||||
// Description: Sets up the reader to use the data type with the
|
||||
// indicated name.
|
||||
|
|
@ -154,21 +154,21 @@ set_data_type(const string &name) {
|
|||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexReader::
|
||||
set_data_type(const InternalName *name) {
|
||||
return set_data_type(_vertex_data->get_format()->get_array_with(name),
|
||||
_vertex_data->get_format()->get_data_type(name));
|
||||
set_column(const InternalName *name) {
|
||||
return set_column(_vertex_data->get_format()->get_array_with(name),
|
||||
_vertex_data->get_format()->get_column(name));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexReader::has_data_type
|
||||
// Function: qpGeomVertexReader::has_column
|
||||
// Access: Published
|
||||
// Description: Returns true if a valid data type has been
|
||||
// successfully set, or false if the data type does not
|
||||
// exist.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexReader::
|
||||
has_data_type() const {
|
||||
return (_data_type != (qpGeomVertexDataType *)NULL);
|
||||
has_column() const {
|
||||
return (_column != (qpGeomVertexColumn *)NULL);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -183,14 +183,14 @@ get_array() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexReader::get_data_type
|
||||
// Function: qpGeomVertexReader::get_column
|
||||
// Access: Published
|
||||
// Description: Returns the description of the data type that the
|
||||
// reader is working on.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const qpGeomVertexDataType *qpGeomVertexReader::
|
||||
get_data_type() const {
|
||||
return _data_type;
|
||||
INLINE const qpGeomVertexColumn *qpGeomVertexReader::
|
||||
get_column() const {
|
||||
return _column;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -203,7 +203,7 @@ get_data_type() const {
|
|||
INLINE void qpGeomVertexReader::
|
||||
set_vertex(int vertex) {
|
||||
_start_vertex = vertex;
|
||||
if (_data_type != (qpGeomVertexDataType *)NULL) {
|
||||
if (_column != (qpGeomVertexColumn *)NULL) {
|
||||
set_pointer(_start_vertex);
|
||||
}
|
||||
}
|
||||
|
|
@ -213,7 +213,7 @@ set_vertex(int vertex) {
|
|||
// Access: Published
|
||||
// Description: Returns the vertex index at which the reader
|
||||
// started. It will return to this vertex if you reset
|
||||
// the current data_type.
|
||||
// the current column.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexReader::
|
||||
get_start_vertex() const {
|
||||
|
|
@ -264,7 +264,7 @@ is_at_end() const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE float qpGeomVertexReader::
|
||||
get_data1f() {
|
||||
nassertr(_data_type != (qpGeomVertexDataType *)NULL, 0.0f);
|
||||
nassertr(_column != (qpGeomVertexColumn *)NULL, 0.0f);
|
||||
return _reader->get_data1f(inc_pointer());
|
||||
}
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ get_data1f() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const LVecBase2f &qpGeomVertexReader::
|
||||
get_data2f() {
|
||||
nassertr(_data_type != (qpGeomVertexDataType *)NULL, LVecBase2f::zero());
|
||||
nassertr(_column != (qpGeomVertexColumn *)NULL, LVecBase2f::zero());
|
||||
return _reader->get_data2f(inc_pointer());
|
||||
}
|
||||
|
||||
|
|
@ -290,7 +290,7 @@ get_data2f() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const LVecBase3f &qpGeomVertexReader::
|
||||
get_data3f() {
|
||||
nassertr(_data_type != (qpGeomVertexDataType *)NULL, LVecBase3f::zero());
|
||||
nassertr(_column != (qpGeomVertexColumn *)NULL, LVecBase3f::zero());
|
||||
return _reader->get_data3f(inc_pointer());
|
||||
}
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ get_data3f() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const LVecBase4f &qpGeomVertexReader::
|
||||
get_data4f() {
|
||||
nassertr(_data_type != (qpGeomVertexDataType *)NULL, LVecBase4f::zero());
|
||||
nassertr(_column != (qpGeomVertexColumn *)NULL, LVecBase4f::zero());
|
||||
return _reader->get_data4f(inc_pointer());
|
||||
}
|
||||
|
||||
|
|
@ -316,7 +316,7 @@ get_data4f() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexReader::
|
||||
get_data1i() {
|
||||
nassertr(_data_type != (qpGeomVertexDataType *)NULL, 0);
|
||||
nassertr(_column != (qpGeomVertexColumn *)NULL, 0);
|
||||
return _reader->get_data1i(inc_pointer());
|
||||
}
|
||||
|
||||
|
|
@ -329,7 +329,7 @@ get_data1i() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const int *qpGeomVertexReader::
|
||||
get_data2i() {
|
||||
nassertr(_data_type != (qpGeomVertexDataType *)NULL, 0);
|
||||
nassertr(_column != (qpGeomVertexColumn *)NULL, 0);
|
||||
return _reader->get_data2i(inc_pointer());
|
||||
}
|
||||
|
||||
|
|
@ -342,7 +342,7 @@ get_data2i() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const int *qpGeomVertexReader::
|
||||
get_data3i() {
|
||||
nassertr(_data_type != (qpGeomVertexDataType *)NULL, 0);
|
||||
nassertr(_column != (qpGeomVertexColumn *)NULL, 0);
|
||||
return _reader->get_data3i(inc_pointer());
|
||||
}
|
||||
|
||||
|
|
@ -355,7 +355,7 @@ get_data3i() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const int *qpGeomVertexReader::
|
||||
get_data4i() {
|
||||
nassertr(_data_type != (qpGeomVertexDataType *)NULL, 0);
|
||||
nassertr(_column != (qpGeomVertexColumn *)NULL, 0);
|
||||
return _reader->get_data4i(inc_pointer());
|
||||
}
|
||||
|
||||
|
|
@ -367,10 +367,10 @@ get_data4i() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexReader::
|
||||
set_pointer(int vertex) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_read_vertex = vertex;
|
||||
CPT(qpGeomVertexArrayData) array_data = _vertex_data->get_array(_array);
|
||||
_pointer = array_data->get_data() + _data_type->get_start() + _stride * _read_vertex;
|
||||
_pointer = array_data->get_data() + _column->get_start() + _stride * _read_vertex;
|
||||
_num_vertices = array_data->get_num_vertices();
|
||||
}
|
||||
|
||||
|
|
@ -383,7 +383,7 @@ set_pointer(int vertex) {
|
|||
INLINE const unsigned char *qpGeomVertexReader::
|
||||
inc_pointer() {
|
||||
nassertr(_read_vertex < _num_vertices, NULL);
|
||||
nassertr(_pointer == _vertex_data->get_array(_array)->get_data() + _data_type->get_start() + _stride * _read_vertex, NULL);
|
||||
nassertr(_pointer == _vertex_data->get_array(_array)->get_data() + _column->get_start() + _stride * _read_vertex, NULL);
|
||||
|
||||
const unsigned char *orig_pointer = _pointer;
|
||||
_pointer += _stride;
|
||||
|
|
@ -401,7 +401,7 @@ inc_pointer() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE float qpGeomVertexReader::Reader::
|
||||
maybe_scale_color(unsigned int value) {
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
if (_column->get_contents() == qpGeomVertexColumn::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 (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
if (_column->get_contents() == qpGeomVertexColumn::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 (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
if (_column->get_contents() == qpGeomVertexColumn::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 (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
|
||||
_v4.set((float)a / 255.0f,
|
||||
(float)b / 255.0f,
|
||||
(float)c / 255.0f,
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@
|
|||
#include "qpgeomVertexReader.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexReader::set_data_type
|
||||
// Function: qpGeomVertexReader::set_column
|
||||
// Access: Published
|
||||
// Description: Sets up the reader to use the indicated data_type
|
||||
// Description: Sets up the reader to use the indicated column
|
||||
// description on the given array.
|
||||
//
|
||||
// This also resets the current read vertex numbers to
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool qpGeomVertexReader::
|
||||
set_data_type(int array, const qpGeomVertexDataType *data_type) {
|
||||
set_column(int array, const qpGeomVertexColumn *column) {
|
||||
// Delete the old reader, if we've got one.
|
||||
if (_reader != (Reader *)NULL) {
|
||||
delete _reader;
|
||||
|
|
@ -41,10 +41,10 @@ set_data_type(int array, const qpGeomVertexDataType *data_type) {
|
|||
}
|
||||
|
||||
if (array < 0 || array >= _vertex_data->get_num_arrays() ||
|
||||
data_type == (qpGeomVertexDataType *)NULL) {
|
||||
column == (qpGeomVertexColumn *)NULL) {
|
||||
// Clear the data type.
|
||||
_array = -1;
|
||||
_data_type = NULL;
|
||||
_column = NULL;
|
||||
_stride = 0;
|
||||
_read_vertex = _start_vertex;
|
||||
_num_vertices = 0;
|
||||
|
|
@ -53,14 +53,14 @@ set_data_type(int array, const qpGeomVertexDataType *data_type) {
|
|||
|
||||
} else {
|
||||
_array = array;
|
||||
_data_type = data_type;
|
||||
_column = column;
|
||||
_stride = _vertex_data->get_format()->get_array(_array)->get_stride();
|
||||
|
||||
set_pointer(_start_vertex);
|
||||
|
||||
// Now set up a new reader.
|
||||
_reader = make_reader();
|
||||
_reader->_data_type = _data_type;
|
||||
_reader->_column = _column;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -74,16 +74,16 @@ set_data_type(int array, const qpGeomVertexDataType *data_type) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
qpGeomVertexReader::Reader *qpGeomVertexReader::
|
||||
make_reader() const {
|
||||
switch (_data_type->get_contents()) {
|
||||
case qpGeomVertexDataType::C_point:
|
||||
case qpGeomVertexDataType::C_texcoord:
|
||||
switch (_column->get_contents()) {
|
||||
case qpGeomVertexColumn::C_point:
|
||||
case qpGeomVertexColumn::C_texcoord:
|
||||
// These types are read as a 4-d homogeneous point.
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
if (sizeof(float) == sizeof(PN_float32)) {
|
||||
// Use the native float type implementation for a tiny bit
|
||||
// more optimization.
|
||||
switch (_data_type->get_num_components()) {
|
||||
switch (_column->get_num_components()) {
|
||||
case 2:
|
||||
return new Reader_point_nativefloat_2;
|
||||
case 3:
|
||||
|
|
@ -92,7 +92,7 @@ make_reader() const {
|
|||
return new Reader_point_nativefloat_4;
|
||||
}
|
||||
} else {
|
||||
switch (_data_type->get_num_components()) {
|
||||
switch (_column->get_num_components()) {
|
||||
case 2:
|
||||
return new Reader_point_float32_2;
|
||||
case 3:
|
||||
|
|
@ -107,10 +107,10 @@ make_reader() const {
|
|||
}
|
||||
return new Reader_point;
|
||||
|
||||
case qpGeomVertexDataType::C_color:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_data_type->get_num_components()) {
|
||||
case qpGeomVertexColumn::C_color:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
switch (_column->get_num_components()) {
|
||||
case 4:
|
||||
return new Reader_rgba_uint8_4;
|
||||
|
||||
|
|
@ -118,8 +118,8 @@ make_reader() const {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
switch (_data_type->get_num_components()) {
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
switch (_column->get_num_components()) {
|
||||
case 1:
|
||||
return new Reader_argb_packed;
|
||||
|
||||
|
|
@ -127,8 +127,8 @@ make_reader() const {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
switch (_data_type->get_num_components()) {
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
switch (_column->get_num_components()) {
|
||||
case 4:
|
||||
if (sizeof(float) == sizeof(PN_float32)) {
|
||||
// Use the native float type implementation for a tiny bit
|
||||
|
|
@ -149,9 +149,9 @@ make_reader() const {
|
|||
|
||||
default:
|
||||
// Otherwise, we just read it as a generic value.
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
switch (_data_type->get_num_components()) {
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
switch (_column->get_num_components()) {
|
||||
case 3:
|
||||
if (sizeof(float) == sizeof(PN_float32)) {
|
||||
// Use the native float type implementation for a tiny bit
|
||||
|
|
@ -188,26 +188,26 @@ qpGeomVertexReader::Reader::
|
|||
////////////////////////////////////////////////////////////////////
|
||||
float qpGeomVertexReader::Reader::
|
||||
get_data1f(const unsigned char *pointer) {
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
return maybe_scale_color(*pointer);
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
return *(const PN_uint16 *)pointer;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
return maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword));
|
||||
}
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
return maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword));
|
||||
}
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
return *(const PN_float32 *)pointer;
|
||||
}
|
||||
|
||||
|
|
@ -221,24 +221,24 @@ get_data1f(const unsigned char *pointer) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
const LVecBase2f &qpGeomVertexReader::Reader::
|
||||
get_data2f(const unsigned char *pointer) {
|
||||
if (_data_type->get_num_values() == 1) {
|
||||
if (_column->get_num_values() == 1) {
|
||||
_v2.set(get_data1i(pointer), 0.0f);
|
||||
return _v2;
|
||||
|
||||
} else {
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
maybe_scale_color(pointer[0], pointer[1]);
|
||||
return _v2;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
const PN_uint16 *pi = (const PN_uint16 *)pointer;
|
||||
_v2.set(pi[0], pi[1]);
|
||||
}
|
||||
return _v2;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
|
||||
|
|
@ -246,7 +246,7 @@ get_data2f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v2;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
|
||||
|
|
@ -254,7 +254,7 @@ get_data2f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v2;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
const PN_float32 *pi = (const PN_float32 *)pointer;
|
||||
_v2.set(pi[0], pi[1]);
|
||||
|
|
@ -273,7 +273,7 @@ get_data2f(const unsigned char *pointer) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
const LVecBase3f &qpGeomVertexReader::Reader::
|
||||
get_data3f(const unsigned char *pointer) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
_v3.set(get_data1f(pointer), 0.0f, 0.0f);
|
||||
return _v3;
|
||||
|
|
@ -286,19 +286,19 @@ get_data3f(const unsigned char *pointer) {
|
|||
return _v3;
|
||||
|
||||
default:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
maybe_scale_color(pointer[0], pointer[1], pointer[2]);
|
||||
return _v3;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
const PN_uint16 *pi = (const PN_uint16 *)pointer;
|
||||
_v3.set(pi[0], pi[1], pi[2]);
|
||||
}
|
||||
return _v3;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
|
||||
|
|
@ -307,7 +307,7 @@ get_data3f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v3;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
|
||||
|
|
@ -316,7 +316,7 @@ get_data3f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v3;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
const PN_float32 *pi = (const PN_float32 *)pointer;
|
||||
_v3.set(pi[0], pi[1], pi[2]);
|
||||
|
|
@ -335,7 +335,7 @@ get_data3f(const unsigned char *pointer) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
const LVecBase4f &qpGeomVertexReader::Reader::
|
||||
get_data4f(const unsigned char *pointer) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
_v4.set(get_data1i(pointer), 0.0f, 0.0f, 0.0f);
|
||||
return _v4;
|
||||
|
|
@ -355,19 +355,19 @@ get_data4f(const unsigned char *pointer) {
|
|||
return _v4;
|
||||
|
||||
default:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
maybe_scale_color(pointer[0], pointer[1], pointer[2], pointer[3]);
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
const PN_uint16 *pi = (const PN_uint16 *)pointer;
|
||||
_v4.set(pi[0], pi[1], pi[2], pi[3]);
|
||||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
|
||||
|
|
@ -377,7 +377,7 @@ get_data4f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
|
||||
|
|
@ -387,7 +387,7 @@ get_data4f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
const PN_float32 *pi = (const PN_float32 *)pointer;
|
||||
_v4.set(pi[0], pi[1], pi[2], pi[3]);
|
||||
|
|
@ -406,28 +406,28 @@ get_data4f(const unsigned char *pointer) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
int qpGeomVertexReader::Reader::
|
||||
get_data1i(const unsigned char *pointer) {
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
return *pointer;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
return *(const PN_uint16 *)pointer;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
return qpGeomVertexData::unpack_abcd_d(dword);
|
||||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
return qpGeomVertexData::unpack_abcd_b(dword);
|
||||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
return (int)*(const PN_float32 *)pointer;
|
||||
}
|
||||
|
||||
|
|
@ -441,20 +441,20 @@ get_data1i(const unsigned char *pointer) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
const int *qpGeomVertexReader::Reader::
|
||||
get_data2i(const unsigned char *pointer) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
_i[0] = get_data1i(pointer);
|
||||
_i[1] = 0;
|
||||
return _i;
|
||||
|
||||
default:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
_i[0] = pointer[0];
|
||||
_i[1] = pointer[1];
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
const PN_uint16 *pi = (const PN_uint16 *)pointer;
|
||||
_i[0] = pi[0];
|
||||
|
|
@ -462,7 +462,7 @@ get_data2i(const unsigned char *pointer) {
|
|||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
_i[0] = qpGeomVertexData::unpack_abcd_d(dword);
|
||||
|
|
@ -470,7 +470,7 @@ get_data2i(const unsigned char *pointer) {
|
|||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
_i[0] = qpGeomVertexData::unpack_abcd_b(dword);
|
||||
|
|
@ -478,7 +478,7 @@ get_data2i(const unsigned char *pointer) {
|
|||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
const PN_float32 *pi = (const PN_float32 *)pointer;
|
||||
_i[0] = (int)pi[0];
|
||||
|
|
@ -498,7 +498,7 @@ get_data2i(const unsigned char *pointer) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
const int *qpGeomVertexReader::Reader::
|
||||
get_data3i(const unsigned char *pointer) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
_i[0] = get_data1i(pointer);
|
||||
_i[1] = 0;
|
||||
|
|
@ -515,14 +515,14 @@ get_data3i(const unsigned char *pointer) {
|
|||
return _i;
|
||||
|
||||
default:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
_i[0] = pointer[0];
|
||||
_i[1] = pointer[1];
|
||||
_i[2] = pointer[2];
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
const PN_uint16 *pi = (const PN_uint16 *)pointer;
|
||||
_i[0] = pi[0];
|
||||
|
|
@ -531,7 +531,7 @@ get_data3i(const unsigned char *pointer) {
|
|||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
_i[0] = qpGeomVertexData::unpack_abcd_d(dword);
|
||||
|
|
@ -540,7 +540,7 @@ get_data3i(const unsigned char *pointer) {
|
|||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
_i[0] = qpGeomVertexData::unpack_abcd_b(dword);
|
||||
|
|
@ -549,7 +549,7 @@ get_data3i(const unsigned char *pointer) {
|
|||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
const PN_float32 *pi = (const PN_float32 *)pointer;
|
||||
_i[0] = (int)pi[0];
|
||||
|
|
@ -570,7 +570,7 @@ get_data3i(const unsigned char *pointer) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
const int *qpGeomVertexReader::Reader::
|
||||
get_data4i(const unsigned char *pointer) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
_i[0] = get_data1i(pointer);
|
||||
_i[1] = 0;
|
||||
|
|
@ -599,15 +599,15 @@ get_data4i(const unsigned char *pointer) {
|
|||
return _i;
|
||||
|
||||
default:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
_i[0] = pointer[0];
|
||||
_i[1] = pointer[1];
|
||||
_i[2] = pointer[2];
|
||||
_i[3] = pointer[3];
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
const PN_uint16 *pi = (const PN_uint16 *)pointer;
|
||||
_i[0] = pi[0];
|
||||
|
|
@ -617,7 +617,7 @@ get_data4i(const unsigned char *pointer) {
|
|||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
_i[0] = qpGeomVertexData::unpack_abcd_d(dword);
|
||||
|
|
@ -627,7 +627,7 @@ get_data4i(const unsigned char *pointer) {
|
|||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
_i[0] = qpGeomVertexData::unpack_abcd_b(dword);
|
||||
|
|
@ -637,7 +637,7 @@ get_data4i(const unsigned char *pointer) {
|
|||
}
|
||||
return _i;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
const PN_float32 *pi = (const PN_float32 *)pointer;
|
||||
_i[0] = (int)pi[0];
|
||||
|
|
@ -659,7 +659,7 @@ get_data4i(const unsigned char *pointer) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
float qpGeomVertexReader::Reader_point::
|
||||
get_data1f(const unsigned char *pointer) {
|
||||
if (_data_type->get_num_values() == 4) {
|
||||
if (_column->get_num_values() == 4) {
|
||||
const LVecBase4f &v4 = get_data4f(pointer);
|
||||
return v4[0] / v4[3];
|
||||
} else {
|
||||
|
|
@ -674,7 +674,7 @@ get_data1f(const unsigned char *pointer) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
const LVecBase2f &qpGeomVertexReader::Reader_point::
|
||||
get_data2f(const unsigned char *pointer) {
|
||||
if (_data_type->get_num_values() == 4) {
|
||||
if (_column->get_num_values() == 4) {
|
||||
const LVecBase4f &v4 = get_data4f(pointer);
|
||||
_v2.set(v4[0] / v4[3], v4[1] / v4[3]);
|
||||
return _v2;
|
||||
|
|
@ -690,7 +690,7 @@ get_data2f(const unsigned char *pointer) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
const LVecBase3f &qpGeomVertexReader::Reader_point::
|
||||
get_data3f(const unsigned char *pointer) {
|
||||
if (_data_type->get_num_values() == 4) {
|
||||
if (_column->get_num_values() == 4) {
|
||||
const LVecBase4f &v4 = get_data4f(pointer);
|
||||
_v3.set(v4[0] / v4[3], v4[1] / v4[3], v4[2] / v4[3]);
|
||||
return _v3;
|
||||
|
|
@ -706,7 +706,7 @@ get_data3f(const unsigned char *pointer) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
const LVecBase4f &qpGeomVertexReader::Reader_point::
|
||||
get_data4f(const unsigned char *pointer) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
_v4.set(get_data1i(pointer), 0.0f, 0.0f, 1.0f);
|
||||
return _v4;
|
||||
|
|
@ -726,19 +726,19 @@ get_data4f(const unsigned char *pointer) {
|
|||
return _v4;
|
||||
|
||||
default:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
maybe_scale_color(pointer[0], pointer[1], pointer[2], pointer[3]);
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
const PN_uint16 *pi = (const PN_uint16 *)pointer;
|
||||
_v4.set(pi[0], pi[1], pi[2], pi[3]);
|
||||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
|
||||
|
|
@ -748,7 +748,7 @@ get_data4f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
|
||||
|
|
@ -758,7 +758,7 @@ get_data4f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
const PN_float32 *pi = (const PN_float32 *)pointer;
|
||||
_v4.set(pi[0], pi[1], pi[2], pi[3]);
|
||||
|
|
@ -777,7 +777,7 @@ get_data4f(const unsigned char *pointer) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
const LVecBase4f &qpGeomVertexReader::Reader_color::
|
||||
get_data4f(const unsigned char *pointer) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
_v4.set(get_data1i(pointer), 0.0f, 0.0f, 1.0f);
|
||||
return _v4;
|
||||
|
|
@ -797,19 +797,19 @@ get_data4f(const unsigned char *pointer) {
|
|||
return _v4;
|
||||
|
||||
default:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
maybe_scale_color(pointer[0], pointer[1], pointer[2], pointer[3]);
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
const PN_uint16 *pi = (const PN_uint16 *)pointer;
|
||||
_v4.set(pi[0], pi[1], pi[2], pi[3]);
|
||||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_d(dword),
|
||||
|
|
@ -819,7 +819,7 @@ get_data4f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
{
|
||||
PN_uint32 dword = *(const PN_uint32 *)pointer;
|
||||
maybe_scale_color(qpGeomVertexData::unpack_abcd_b(dword),
|
||||
|
|
@ -829,7 +829,7 @@ get_data4f(const unsigned char *pointer) {
|
|||
}
|
||||
return _v4;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
const PN_float32 *pi = (const PN_float32 *)pointer;
|
||||
_v4.set(pi[0], pi[1], pi[2], pi[3]);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "pandabase.h"
|
||||
#include "qpgeomVertexData.h"
|
||||
#include "qpgeomVertexDataType.h"
|
||||
#include "qpgeomVertexColumn.h"
|
||||
#include "internalName.h"
|
||||
#include "luse.h"
|
||||
#include "pointerTo.h"
|
||||
|
|
@ -32,19 +32,20 @@
|
|||
// quickly reading a sequence of numeric values from a
|
||||
// vertex table.
|
||||
//
|
||||
// It is particularly optimized for reading a column of
|
||||
// data values for a series of vertices, without
|
||||
// changing data types between each number. Although
|
||||
// you can use one GeomVertexReader to read one complete
|
||||
// row at a time, by calling set_data_type() repeatedly
|
||||
// for each vertex, it is faster to use a different
|
||||
// GeomVertexReader for each data type.
|
||||
// It is particularly optimized for reading a single
|
||||
// column of data values for a series of vertices,
|
||||
// without changing columns between each number.
|
||||
// Although you can also use one GeomVertexReader to
|
||||
// read across the columns if it is convenient, by
|
||||
// calling set_column() repeatedly at each vertex, it is
|
||||
// faster to read down the columns, and to use a
|
||||
// different GeomVertexReader for each column.
|
||||
//
|
||||
// Note that a GeomVertexReader does not keep a
|
||||
// reference count to the actual vertex data buffer (it
|
||||
// grabs the current data buffer from the GeomVertexData
|
||||
// whenever set_data_type() is called). This means that
|
||||
// it is important not to keep a GeomVertexReader object
|
||||
// whenever set_column() is called). This means that it
|
||||
// is important not to keep a GeomVertexReader object
|
||||
// around over a long period of time in which the data
|
||||
// buffer is likely to be deallocated; it is intended
|
||||
// for making a quick pass over the data in one session.
|
||||
|
|
@ -69,14 +70,14 @@ PUBLISHED:
|
|||
|
||||
INLINE const qpGeomVertexData *get_vertex_data() const;
|
||||
|
||||
INLINE bool set_data_type(int data_type);
|
||||
INLINE bool set_data_type(const string &name);
|
||||
INLINE bool set_data_type(const InternalName *name);
|
||||
bool set_data_type(int array, const qpGeomVertexDataType *data_type);
|
||||
INLINE bool set_column(int column);
|
||||
INLINE bool set_column(const string &name);
|
||||
INLINE bool set_column(const InternalName *name);
|
||||
bool set_column(int array, const qpGeomVertexColumn *column);
|
||||
|
||||
INLINE bool has_data_type() const;
|
||||
INLINE bool has_column() const;
|
||||
INLINE int get_array() const;
|
||||
INLINE const qpGeomVertexDataType *get_data_type() const;
|
||||
INLINE const qpGeomVertexColumn *get_column() const;
|
||||
|
||||
INLINE void set_vertex(int vertex);
|
||||
|
||||
|
|
@ -104,7 +105,7 @@ private:
|
|||
|
||||
CPT(qpGeomVertexData) _vertex_data;
|
||||
int _array;
|
||||
const qpGeomVertexDataType *_data_type;
|
||||
const qpGeomVertexColumn *_column;
|
||||
int _stride;
|
||||
|
||||
const unsigned char *_pointer;
|
||||
|
|
@ -138,7 +139,7 @@ private:
|
|||
INLINE void maybe_scale_color(unsigned int a, unsigned int b,
|
||||
unsigned int c, unsigned int d);
|
||||
|
||||
const qpGeomVertexDataType *_data_type;
|
||||
const qpGeomVertexColumn *_column;
|
||||
LVecBase2f _v2;
|
||||
LVecBase3f _v3;
|
||||
LVecBase4f _v4;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ qpGeomVertexRewriter(qpGeomVertexData *vertex_data, const string &name) :
|
|||
qpGeomVertexWriter(vertex_data),
|
||||
qpGeomVertexReader(vertex_data)
|
||||
{
|
||||
set_data_type(name);
|
||||
set_column(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -57,7 +57,7 @@ qpGeomVertexRewriter(qpGeomVertexData *vertex_data, const InternalName *name) :
|
|||
qpGeomVertexWriter(vertex_data),
|
||||
qpGeomVertexReader(vertex_data)
|
||||
{
|
||||
set_data_type(name);
|
||||
set_column(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -83,7 +83,7 @@ get_vertex_data() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexRewriter::set_data_type
|
||||
// Function: qpGeomVertexRewriter::set_column
|
||||
// Access: Published
|
||||
// Description: Sets up the rewriter to use the nth data type of the
|
||||
// GeomVertexFormat, numbering from 0.
|
||||
|
|
@ -97,15 +97,15 @@ get_vertex_data() const {
|
|||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexRewriter::
|
||||
set_data_type(int data_type) {
|
||||
set_column(int column) {
|
||||
// It's important to invoke the writer first, then the reader. See
|
||||
// set_vertex().
|
||||
qpGeomVertexWriter::set_data_type(data_type);
|
||||
return qpGeomVertexReader::set_data_type(data_type);
|
||||
qpGeomVertexWriter::set_column(column);
|
||||
return qpGeomVertexReader::set_column(column);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexRewriter::set_data_type
|
||||
// Function: qpGeomVertexRewriter::set_column
|
||||
// Access: Published
|
||||
// Description: Sets up the rewriter to use the data type with the
|
||||
// indicated name.
|
||||
|
|
@ -119,12 +119,12 @@ set_data_type(int data_type) {
|
|||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexRewriter::
|
||||
set_data_type(const string &name) {
|
||||
return set_data_type(InternalName::make(name));
|
||||
set_column(const string &name) {
|
||||
return set_column(InternalName::make(name));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexRewriter::set_data_type
|
||||
// Function: qpGeomVertexRewriter::set_column
|
||||
// Access: Published
|
||||
// Description: Sets up the rewriter to use the data type with the
|
||||
// indicated name.
|
||||
|
|
@ -138,17 +138,17 @@ set_data_type(const string &name) {
|
|||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexRewriter::
|
||||
set_data_type(const InternalName *name) {
|
||||
set_column(const InternalName *name) {
|
||||
// It's important to invoke the writer first, then the reader. See
|
||||
// set_vertex().
|
||||
qpGeomVertexWriter::set_data_type(name);
|
||||
return qpGeomVertexReader::set_data_type(name);
|
||||
qpGeomVertexWriter::set_column(name);
|
||||
return qpGeomVertexReader::set_column(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexRewriter::set_data_type
|
||||
// Function: qpGeomVertexRewriter::set_column
|
||||
// Access: Published
|
||||
// Description: Sets up the rewriter to use the indicated data_type
|
||||
// Description: Sets up the rewriter to use the indicated column
|
||||
// description on the given array.
|
||||
//
|
||||
// This also resets both the read and write vertex
|
||||
|
|
@ -160,25 +160,25 @@ set_data_type(const InternalName *name) {
|
|||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool qpGeomVertexRewriter::
|
||||
set_data_type(int array, const qpGeomVertexDataType *data_type) {
|
||||
set_column(int array, const qpGeomVertexColumn *column) {
|
||||
// It's important to invoke the writer first, then the reader. See
|
||||
// set_vertex().
|
||||
qpGeomVertexWriter::set_data_type(array, data_type);
|
||||
return qpGeomVertexReader::set_data_type(array, data_type);
|
||||
qpGeomVertexWriter::set_column(array, column);
|
||||
return qpGeomVertexReader::set_column(array, column);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexRewriter::has_data_type
|
||||
// Function: qpGeomVertexRewriter::has_column
|
||||
// Access: Published
|
||||
// Description: Returns true if a valid data type has been
|
||||
// successfully set, or false if the data type does not
|
||||
// exist.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexRewriter::
|
||||
has_data_type() const {
|
||||
nassertr(qpGeomVertexWriter::get_data_type() ==
|
||||
qpGeomVertexReader::get_data_type(), false);
|
||||
return qpGeomVertexWriter::has_data_type();
|
||||
has_column() const {
|
||||
nassertr(qpGeomVertexWriter::get_column() ==
|
||||
qpGeomVertexReader::get_column(), false);
|
||||
return qpGeomVertexWriter::has_column();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -195,16 +195,16 @@ get_array() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexRewriter::get_data_type
|
||||
// Function: qpGeomVertexRewriter::get_column
|
||||
// Access: Published
|
||||
// Description: Returns the description of the data type that the
|
||||
// rewriter is working on.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const qpGeomVertexDataType *qpGeomVertexRewriter::
|
||||
get_data_type() const {
|
||||
nassertr(qpGeomVertexWriter::get_data_type() ==
|
||||
qpGeomVertexReader::get_data_type(), NULL);
|
||||
return qpGeomVertexWriter::get_data_type();
|
||||
INLINE const qpGeomVertexColumn *qpGeomVertexRewriter::
|
||||
get_column() const {
|
||||
nassertr(qpGeomVertexWriter::get_column() ==
|
||||
qpGeomVertexReader::get_column(), NULL);
|
||||
return qpGeomVertexWriter::get_column();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -228,7 +228,7 @@ set_vertex(int vertex) {
|
|||
// Access: Published
|
||||
// Description: Returns the vertex index at which the rewriter
|
||||
// started. It will return to this vertex if you reset
|
||||
// the current data_type.
|
||||
// the current column.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexRewriter::
|
||||
get_start_vertex() const {
|
||||
|
|
|
|||
|
|
@ -32,12 +32,13 @@
|
|||
// object, modifying vertices as it goes.
|
||||
//
|
||||
// Although it doesn't provide any real performance
|
||||
// benefit over using a separate reader and writer
|
||||
// object, it should probably be used in preference to
|
||||
// separate objects, because it makes an effort to
|
||||
// manage the reference counts properly between the
|
||||
// reader and the writer to avoid accidentally
|
||||
// dereferencing either array while recopying.
|
||||
// benefit over using a separate reader and writer on
|
||||
// the same data, it should probably be used in
|
||||
// preference to a separate reader and writer, because
|
||||
// it makes an effort to manage the reference counts
|
||||
// properly between the reader and the writer to avoid
|
||||
// accidentally dereferencing either array while
|
||||
// recopying.
|
||||
//
|
||||
// This is part of the experimental Geom rewrite.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -52,14 +53,14 @@ PUBLISHED:
|
|||
|
||||
INLINE qpGeomVertexData *get_vertex_data() const;
|
||||
|
||||
INLINE bool set_data_type(int data_type);
|
||||
INLINE bool set_data_type(const string &name);
|
||||
INLINE bool set_data_type(const InternalName *name);
|
||||
INLINE bool set_data_type(int array, const qpGeomVertexDataType *data_type);
|
||||
INLINE bool set_column(int column);
|
||||
INLINE bool set_column(const string &name);
|
||||
INLINE bool set_column(const InternalName *name);
|
||||
INLINE bool set_column(int array, const qpGeomVertexColumn *column);
|
||||
|
||||
INLINE bool has_data_type() const;
|
||||
INLINE bool has_column() const;
|
||||
INLINE int get_array() const;
|
||||
INLINE const qpGeomVertexDataType *get_data_type() const;
|
||||
INLINE const qpGeomVertexColumn *get_column() const;
|
||||
|
||||
INLINE void set_vertex(int vertex);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ INLINE qpGeomVertexWriter::
|
|||
qpGeomVertexWriter(qpGeomVertexData *vertex_data) :
|
||||
_vertex_data(vertex_data),
|
||||
_array(0),
|
||||
_data_type(NULL),
|
||||
_column(NULL),
|
||||
_pointer(NULL),
|
||||
_start_vertex(0),
|
||||
_write_vertex(0),
|
||||
|
|
@ -47,14 +47,14 @@ INLINE qpGeomVertexWriter::
|
|||
qpGeomVertexWriter(qpGeomVertexData *vertex_data, const string &name) :
|
||||
_vertex_data(vertex_data),
|
||||
_array(0),
|
||||
_data_type(NULL),
|
||||
_column(NULL),
|
||||
_pointer(NULL),
|
||||
_start_vertex(0),
|
||||
_write_vertex(0),
|
||||
_num_vertices(0),
|
||||
_writer(NULL)
|
||||
{
|
||||
set_data_type(name);
|
||||
set_column(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -68,14 +68,14 @@ INLINE qpGeomVertexWriter::
|
|||
qpGeomVertexWriter(qpGeomVertexData *vertex_data, const InternalName *name) :
|
||||
_vertex_data(vertex_data),
|
||||
_array(0),
|
||||
_data_type(NULL),
|
||||
_column(NULL),
|
||||
_pointer(NULL),
|
||||
_start_vertex(0),
|
||||
_write_vertex(0),
|
||||
_num_vertices(0),
|
||||
_writer(NULL)
|
||||
{
|
||||
set_data_type(name);
|
||||
set_column(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -103,7 +103,7 @@ get_vertex_data() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexWriter::set_data_type
|
||||
// Function: qpGeomVertexWriter::set_column
|
||||
// Access: Published
|
||||
// Description: Sets up the writer to use the nth data type of the
|
||||
// GeomVertexFormat, numbering from 0.
|
||||
|
|
@ -116,13 +116,13 @@ get_vertex_data() const {
|
|||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexWriter::
|
||||
set_data_type(int data_type) {
|
||||
return set_data_type(_vertex_data->get_format()->get_array_with(data_type),
|
||||
_vertex_data->get_format()->get_data_type(data_type));
|
||||
set_column(int column) {
|
||||
return set_column(_vertex_data->get_format()->get_array_with(column),
|
||||
_vertex_data->get_format()->get_column(column));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexWriter::set_data_type
|
||||
// Function: qpGeomVertexWriter::set_column
|
||||
// Access: Published
|
||||
// Description: Sets up the writer to use the data type with the
|
||||
// indicated name.
|
||||
|
|
@ -135,12 +135,12 @@ set_data_type(int data_type) {
|
|||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexWriter::
|
||||
set_data_type(const string &name) {
|
||||
return set_data_type(InternalName::make(name));
|
||||
set_column(const string &name) {
|
||||
return set_column(InternalName::make(name));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexWriter::set_data_type
|
||||
// Function: qpGeomVertexWriter::set_column
|
||||
// Access: Published
|
||||
// Description: Sets up the writer to use the data type with the
|
||||
// indicated name.
|
||||
|
|
@ -153,21 +153,21 @@ set_data_type(const string &name) {
|
|||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexWriter::
|
||||
set_data_type(const InternalName *name) {
|
||||
return set_data_type(_vertex_data->get_format()->get_array_with(name),
|
||||
_vertex_data->get_format()->get_data_type(name));
|
||||
set_column(const InternalName *name) {
|
||||
return set_column(_vertex_data->get_format()->get_array_with(name),
|
||||
_vertex_data->get_format()->get_column(name));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexWriter::has_data_type
|
||||
// Function: qpGeomVertexWriter::has_column
|
||||
// Access: Published
|
||||
// Description: Returns true if a valid data type has been
|
||||
// successfully set, or false if the data type does not
|
||||
// exist.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool qpGeomVertexWriter::
|
||||
has_data_type() const {
|
||||
return (_data_type != (qpGeomVertexDataType *)NULL);
|
||||
has_column() const {
|
||||
return (_column != (qpGeomVertexColumn *)NULL);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -182,14 +182,14 @@ get_array() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexWriter::get_data_type
|
||||
// Function: qpGeomVertexWriter::get_column
|
||||
// Access: Published
|
||||
// Description: Returns the description of the data type that the
|
||||
// writer is working on.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const qpGeomVertexDataType *qpGeomVertexWriter::
|
||||
get_data_type() const {
|
||||
return _data_type;
|
||||
INLINE const qpGeomVertexColumn *qpGeomVertexWriter::
|
||||
get_column() const {
|
||||
return _column;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -202,7 +202,7 @@ get_data_type() const {
|
|||
INLINE void qpGeomVertexWriter::
|
||||
set_vertex(int vertex) {
|
||||
_start_vertex = vertex;
|
||||
if (_data_type != (qpGeomVertexDataType *)NULL) {
|
||||
if (_column != (qpGeomVertexColumn *)NULL) {
|
||||
set_pointer(_start_vertex);
|
||||
}
|
||||
}
|
||||
|
|
@ -212,7 +212,7 @@ set_vertex(int vertex) {
|
|||
// Access: Published
|
||||
// Description: Returns the vertex index at which the writer
|
||||
// started. It will return to this vertex if you reset
|
||||
// the current data_type.
|
||||
// the current column.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int qpGeomVertexWriter::
|
||||
get_start_vertex() const {
|
||||
|
|
@ -266,7 +266,7 @@ is_at_end() const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
set_data1f(float data) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data1f(inc_pointer(), data);
|
||||
}
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ set_data2f(float x, float y) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
set_data2f(const LVecBase2f &data) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data2f(inc_pointer(), data);
|
||||
}
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ set_data3f(float x, float y, float z) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
set_data3f(const LVecBase3f &data) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data3f(inc_pointer(), data);
|
||||
}
|
||||
|
||||
|
|
@ -353,7 +353,7 @@ set_data4f(float x, float y, float z, float w) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
set_data4f(const LVecBase4f &data) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data4f(inc_pointer(), data);
|
||||
}
|
||||
|
||||
|
|
@ -368,7 +368,7 @@ set_data4f(const LVecBase4f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
set_data1i(int data) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data1i(inc_pointer(), data);
|
||||
}
|
||||
|
||||
|
|
@ -383,7 +383,7 @@ set_data1i(int data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
set_data2i(int a, int b) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data2i(inc_pointer(), a, b);
|
||||
}
|
||||
|
||||
|
|
@ -412,7 +412,7 @@ set_data2i(const int data[2]) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
set_data3i(int a, int b, int c) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data3i(inc_pointer(), a, b, c);
|
||||
}
|
||||
|
||||
|
|
@ -441,7 +441,7 @@ set_data3i(const int data[3]) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
set_data4i(int a, int b, int c, int d) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data4i(inc_pointer(), a, b, c, d);
|
||||
}
|
||||
|
||||
|
|
@ -470,7 +470,7 @@ set_data4i(const int data[4]) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
add_data1f(float data) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data1f(inc_add_pointer(), data);
|
||||
}
|
||||
|
||||
|
|
@ -499,7 +499,7 @@ add_data2f(float x, float y) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
add_data2f(const LVecBase2f &data) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data2f(inc_add_pointer(), data);
|
||||
}
|
||||
|
||||
|
|
@ -528,7 +528,7 @@ add_data3f(float x, float y, float z) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
add_data3f(const LVecBase3f &data) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data3f(inc_add_pointer(), data);
|
||||
}
|
||||
|
||||
|
|
@ -557,7 +557,7 @@ add_data4f(float x, float y, float z, float w) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
add_data4f(const LVecBase4f &data) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data4f(inc_add_pointer(), data);
|
||||
}
|
||||
|
||||
|
|
@ -572,7 +572,7 @@ add_data4f(const LVecBase4f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
add_data1i(int data) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data1i(inc_add_pointer(), data);
|
||||
}
|
||||
|
||||
|
|
@ -587,7 +587,7 @@ add_data1i(int data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
add_data2i(int a, int b) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data2i(inc_add_pointer(), a, b);
|
||||
}
|
||||
|
||||
|
|
@ -616,7 +616,7 @@ add_data2i(const int data[2]) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
add_data3i(int a, int b, int c) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data3i(inc_add_pointer(), a, b, c);
|
||||
}
|
||||
|
||||
|
|
@ -645,7 +645,7 @@ add_data3i(const int data[3]) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
add_data4i(int a, int b, int c, int d) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_writer->set_data4i(inc_add_pointer(), a, b, c, d);
|
||||
}
|
||||
|
||||
|
|
@ -671,10 +671,10 @@ add_data4i(const int data[4]) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::
|
||||
set_pointer(int vertex) {
|
||||
nassertv(_data_type != (qpGeomVertexDataType *)NULL);
|
||||
nassertv(_column != (qpGeomVertexColumn *)NULL);
|
||||
_write_vertex = vertex;
|
||||
PT(qpGeomVertexArrayData) array_data = _vertex_data->modify_array(_array);
|
||||
_pointer = array_data->modify_data() + _data_type->get_start() + _stride * _write_vertex;
|
||||
_pointer = array_data->modify_data() + _column->get_start() + _stride * _write_vertex;
|
||||
_num_vertices = array_data->get_num_vertices();
|
||||
}
|
||||
|
||||
|
|
@ -687,7 +687,7 @@ set_pointer(int vertex) {
|
|||
INLINE unsigned char *qpGeomVertexWriter::
|
||||
inc_pointer() {
|
||||
nassertr(_write_vertex < _num_vertices, NULL);
|
||||
nassertr(_pointer == _vertex_data->get_array(_array)->get_data() + _data_type->get_start() + _stride * _write_vertex, NULL);
|
||||
nassertr(_pointer == _vertex_data->get_array(_array)->get_data() + _column->get_start() + _stride * _write_vertex, NULL);
|
||||
|
||||
unsigned char *orig_pointer = _pointer;
|
||||
_pointer += _stride;
|
||||
|
|
@ -723,7 +723,7 @@ inc_add_pointer() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE unsigned int qpGeomVertexWriter::Writer::
|
||||
maybe_scale_color(float data) {
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
|
||||
return (unsigned int)(data * 255.0f);
|
||||
} else {
|
||||
return (unsigned int)data;
|
||||
|
|
@ -739,7 +739,7 @@ maybe_scale_color(float data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::Writer::
|
||||
maybe_scale_color(const LVecBase2f &data) {
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
|
||||
_a = (unsigned int)(data[0] * 255.0f);
|
||||
_b = (unsigned int)(data[1] * 255.0f);
|
||||
} else {
|
||||
|
|
@ -757,7 +757,7 @@ maybe_scale_color(const LVecBase2f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::Writer::
|
||||
maybe_scale_color(const LVecBase3f &data) {
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
|
||||
_a = (unsigned int)(data[0] * 255.0f);
|
||||
_b = (unsigned int)(data[1] * 255.0f);
|
||||
_c = (unsigned int)(data[2] * 255.0f);
|
||||
|
|
@ -777,7 +777,7 @@ maybe_scale_color(const LVecBase3f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpGeomVertexWriter::Writer::
|
||||
maybe_scale_color(const LVecBase4f &data) {
|
||||
if (_data_type->get_contents() == qpGeomVertexDataType::C_color) {
|
||||
if (_column->get_contents() == qpGeomVertexColumn::C_color) {
|
||||
_a = (unsigned int)(data[0] * 255.0f);
|
||||
_b = (unsigned int)(data[1] * 255.0f);
|
||||
_c = (unsigned int)(data[2] * 255.0f);
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@
|
|||
#include "qpgeomVertexWriter.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexWriter::set_data_type
|
||||
// Function: qpGeomVertexWriter::set_column
|
||||
// Access: Published
|
||||
// Description: Sets up the writer to use the indicated data_type
|
||||
// Description: Sets up the writer to use the indicated column
|
||||
// description on the given array.
|
||||
//
|
||||
// This also resets the current write vertex numbers to
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool qpGeomVertexWriter::
|
||||
set_data_type(int array, const qpGeomVertexDataType *data_type) {
|
||||
set_column(int array, const qpGeomVertexColumn *column) {
|
||||
// Delete the old writer, if we've got one.
|
||||
if (_writer != (Writer *)NULL) {
|
||||
delete _writer;
|
||||
|
|
@ -41,10 +41,10 @@ set_data_type(int array, const qpGeomVertexDataType *data_type) {
|
|||
}
|
||||
|
||||
if (array < 0 || array >= _vertex_data->get_num_arrays() ||
|
||||
data_type == (qpGeomVertexDataType *)NULL) {
|
||||
column == (qpGeomVertexColumn *)NULL) {
|
||||
// Clear the data type.
|
||||
_array = -1;
|
||||
_data_type = NULL;
|
||||
_column = NULL;
|
||||
_stride = 0;
|
||||
_write_vertex = _start_vertex;
|
||||
_num_vertices = 0;
|
||||
|
|
@ -53,14 +53,14 @@ set_data_type(int array, const qpGeomVertexDataType *data_type) {
|
|||
|
||||
} else {
|
||||
_array = array;
|
||||
_data_type = data_type;
|
||||
_column = column;
|
||||
_stride = _vertex_data->get_format()->get_array(_array)->get_stride();
|
||||
|
||||
set_pointer(_start_vertex);
|
||||
|
||||
// Now set up a new writer.
|
||||
_writer = make_writer();
|
||||
_writer->_data_type = _data_type;
|
||||
_writer->_column = _column;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -74,13 +74,13 @@ set_data_type(int array, const qpGeomVertexDataType *data_type) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
qpGeomVertexWriter::Writer *qpGeomVertexWriter::
|
||||
make_writer() const {
|
||||
switch (_data_type->get_contents()) {
|
||||
case qpGeomVertexDataType::C_point:
|
||||
case qpGeomVertexDataType::C_texcoord:
|
||||
switch (_column->get_contents()) {
|
||||
case qpGeomVertexColumn::C_point:
|
||||
case qpGeomVertexColumn::C_texcoord:
|
||||
// These types are written as a 4-d homogeneous point.
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
switch (_data_type->get_num_components()) {
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
switch (_column->get_num_components()) {
|
||||
case 2:
|
||||
return new Writer_point_float32_2;
|
||||
case 3:
|
||||
|
|
@ -97,10 +97,10 @@ make_writer() const {
|
|||
}
|
||||
return new Writer_point;
|
||||
|
||||
case qpGeomVertexDataType::C_color:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_data_type->get_num_components()) {
|
||||
case qpGeomVertexColumn::C_color:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
switch (_column->get_num_components()) {
|
||||
case 4:
|
||||
return new Writer_rgba_uint8_4;
|
||||
|
||||
|
|
@ -108,8 +108,8 @@ make_writer() const {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
switch (_data_type->get_num_components()) {
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
switch (_column->get_num_components()) {
|
||||
case 1:
|
||||
return new Writer_argb_packed;
|
||||
|
||||
|
|
@ -117,8 +117,8 @@ make_writer() const {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
switch (_data_type->get_num_components()) {
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
switch (_column->get_num_components()) {
|
||||
case 4:
|
||||
return new Writer_rgba_float32_4;
|
||||
|
||||
|
|
@ -133,9 +133,9 @@ make_writer() const {
|
|||
|
||||
default:
|
||||
// Otherwise, we just write it as a generic value.
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
switch (_data_type->get_num_components()) {
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
switch (_column->get_num_components()) {
|
||||
case 3:
|
||||
return new Writer_float32_3;
|
||||
|
||||
|
|
@ -166,23 +166,23 @@ qpGeomVertexWriter::Writer::
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer::
|
||||
set_data1f(unsigned char *pointer, float data) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
*pointer = maybe_scale_color(data);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
*(PN_uint16 *)pointer = (unsigned int)data;
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
nassertv(false);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
*(PN_float32 *)pointer = data;
|
||||
break;
|
||||
}
|
||||
|
|
@ -209,19 +209,19 @@ set_data1f(unsigned char *pointer, float data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer::
|
||||
set_data2f(unsigned char *pointer, const LVecBase2f &data) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
set_data1f(pointer, data[0]);
|
||||
|
||||
case 2:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
maybe_scale_color(data);
|
||||
pointer[0] = _a;
|
||||
pointer[1] = _b;
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
PN_uint16 *pi = (PN_uint16 *)pointer;
|
||||
pi[0] = (unsigned int)data[0];
|
||||
|
|
@ -229,12 +229,12 @@ set_data2f(unsigned char *pointer, const LVecBase2f &data) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
nassertv(false);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
PN_float32 *pi = (PN_float32 *)pointer;
|
||||
pi[0] = data[0];
|
||||
|
|
@ -261,7 +261,7 @@ set_data2f(unsigned char *pointer, const LVecBase2f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer::
|
||||
set_data3f(unsigned char *pointer, const LVecBase3f &data) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
set_data1f(pointer, data[0]);
|
||||
break;
|
||||
|
|
@ -271,15 +271,15 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) {
|
|||
break;
|
||||
|
||||
case 3:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
maybe_scale_color(data);
|
||||
pointer[0] = _a;
|
||||
pointer[1] = _b;
|
||||
pointer[2] = _c;
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
PN_uint16 *pi = (PN_uint16 *)pointer;
|
||||
pi[0] = (unsigned int)data[0];
|
||||
|
|
@ -288,12 +288,12 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
nassertv(false);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
PN_float32 *pi = (PN_float32 *)pointer;
|
||||
pi[0] = data[0];
|
||||
|
|
@ -317,7 +317,7 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer::
|
||||
set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
set_data1f(pointer, data[0]);
|
||||
break;
|
||||
|
|
@ -331,8 +331,8 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
|||
break;
|
||||
|
||||
default:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
maybe_scale_color(data);
|
||||
pointer[0] = _a;
|
||||
pointer[1] = _b;
|
||||
|
|
@ -340,7 +340,7 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
|||
pointer[3] = _d;
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
PN_uint16 *pi = (PN_uint16 *)pointer;
|
||||
pi[0] = (unsigned int)data[0];
|
||||
|
|
@ -350,17 +350,17 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
maybe_scale_color(data);
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(_d, _c, _b, _a);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
maybe_scale_color(data);
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(_d, _a, _b, _c);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
PN_float32 *pi = (PN_float32 *)pointer;
|
||||
pi[0] = data[0];
|
||||
|
|
@ -381,23 +381,23 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer::
|
||||
set_data1i(unsigned char *pointer, int a) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
*pointer = a;
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
*(PN_uint16 *)pointer = a;
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
nassertv(false);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
*(PN_float32 *)pointer = (float)a;
|
||||
break;
|
||||
}
|
||||
|
|
@ -424,19 +424,19 @@ set_data1i(unsigned char *pointer, int a) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer::
|
||||
set_data2i(unsigned char *pointer, int a, int b) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
set_data1i(pointer, a);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
pointer[0] = a;
|
||||
pointer[1] = b;
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
PN_uint16 *pi = (PN_uint16 *)pointer;
|
||||
pi[0] = a;
|
||||
|
|
@ -444,12 +444,12 @@ set_data2i(unsigned char *pointer, int a, int b) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
nassertv(false);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
PN_float32 *pi = (PN_float32 *)pointer;
|
||||
pi[0] = a;
|
||||
|
|
@ -476,7 +476,7 @@ set_data2i(unsigned char *pointer, int a, int b) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer::
|
||||
set_data3i(unsigned char *pointer, int a, int b, int c) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
set_data1i(pointer, a);
|
||||
break;
|
||||
|
|
@ -486,14 +486,14 @@ set_data3i(unsigned char *pointer, int a, int b, int c) {
|
|||
break;
|
||||
|
||||
case 3:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
pointer[0] = a;
|
||||
pointer[1] = b;
|
||||
pointer[2] = c;
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
PN_uint16 *pi = (PN_uint16 *)pointer;
|
||||
pi[0] = a;
|
||||
|
|
@ -502,12 +502,12 @@ set_data3i(unsigned char *pointer, int a, int b, int c) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
nassertv(false);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
PN_float32 *pi = (PN_float32 *)pointer;
|
||||
pi[0] = a;
|
||||
|
|
@ -531,7 +531,7 @@ set_data3i(unsigned char *pointer, int a, int b, int c) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer::
|
||||
set_data4i(unsigned char *pointer, int a, int b, int c, int d) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
set_data1i(pointer, a);
|
||||
break;
|
||||
|
|
@ -545,15 +545,15 @@ set_data4i(unsigned char *pointer, int a, int b, int c, int d) {
|
|||
break;
|
||||
|
||||
default:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
pointer[0] = a;
|
||||
pointer[1] = b;
|
||||
pointer[2] = c;
|
||||
pointer[3] = d;
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
PN_uint16 *pi = (PN_uint16 *)pointer;
|
||||
pi[0] = a;
|
||||
|
|
@ -563,15 +563,15 @@ set_data4i(unsigned char *pointer, int a, int b, int c, int d) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(d, c, b, a);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(d, a, b, c);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
PN_float32 *pi = (PN_float32 *)pointer;
|
||||
pi[0] = a;
|
||||
|
|
@ -592,7 +592,7 @@ set_data4i(unsigned char *pointer, int a, int b, int c, int d) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer_point::
|
||||
set_data1f(unsigned char *pointer, float data) {
|
||||
if (_data_type->get_num_values() == 4) {
|
||||
if (_column->get_num_values() == 4) {
|
||||
set_data4f(pointer, LVecBase4f(data, 0.0f, 0.0f, 1.0f));
|
||||
} else {
|
||||
Writer::set_data1f(pointer, data);
|
||||
|
|
@ -606,7 +606,7 @@ set_data1f(unsigned char *pointer, float data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer_point::
|
||||
set_data2f(unsigned char *pointer, const LVecBase2f &data) {
|
||||
if (_data_type->get_num_values() == 4) {
|
||||
if (_column->get_num_values() == 4) {
|
||||
set_data4f(pointer, LVecBase4f(data[0], data[1], 0.0f, 1.0f));
|
||||
} else {
|
||||
Writer::set_data2f(pointer, data);
|
||||
|
|
@ -620,7 +620,7 @@ set_data2f(unsigned char *pointer, const LVecBase2f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer_point::
|
||||
set_data3f(unsigned char *pointer, const LVecBase3f &data) {
|
||||
if (_data_type->get_num_values() == 4) {
|
||||
if (_column->get_num_values() == 4) {
|
||||
set_data4f(pointer, LVecBase4f(data[0], data[1], data[2], 1.0f));
|
||||
} else {
|
||||
Writer::set_data3f(pointer, data);
|
||||
|
|
@ -634,7 +634,7 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer_point::
|
||||
set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
||||
switch (_data_type->get_num_values()) {
|
||||
switch (_column->get_num_values()) {
|
||||
case 1:
|
||||
set_data1f(pointer, data[0] / data[3]);
|
||||
break;
|
||||
|
|
@ -648,8 +648,8 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
|||
break;
|
||||
|
||||
default:
|
||||
switch (_data_type->get_numeric_type()) {
|
||||
case qpGeomVertexDataType::NT_uint8:
|
||||
switch (_column->get_numeric_type()) {
|
||||
case qpGeomVertexColumn::NT_uint8:
|
||||
maybe_scale_color(data);
|
||||
pointer[0] = _a;
|
||||
pointer[1] = _b;
|
||||
|
|
@ -657,7 +657,7 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
|||
pointer[3] = _d;
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_uint16:
|
||||
case qpGeomVertexColumn::NT_uint16:
|
||||
{
|
||||
PN_uint16 *pi = (PN_uint16 *)pointer;
|
||||
pi[0] = (unsigned int)data[0];
|
||||
|
|
@ -667,17 +667,17 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
|||
}
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dcba:
|
||||
case qpGeomVertexColumn::NT_packed_dcba:
|
||||
maybe_scale_color(data);
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(_d, _c, _b, _a);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_packed_dabc:
|
||||
case qpGeomVertexColumn::NT_packed_dabc:
|
||||
maybe_scale_color(data);
|
||||
*(PN_uint32 *)pointer = qpGeomVertexData::pack_abcd(_d, _a, _b, _c);
|
||||
break;
|
||||
|
||||
case qpGeomVertexDataType::NT_float32:
|
||||
case qpGeomVertexColumn::NT_float32:
|
||||
{
|
||||
PN_float32 *pi = (PN_float32 *)pointer;
|
||||
pi[0] = data[0];
|
||||
|
|
@ -698,7 +698,7 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer_color::
|
||||
set_data1f(unsigned char *pointer, float data) {
|
||||
if (_data_type->get_num_values() == 4) {
|
||||
if (_column->get_num_values() == 4) {
|
||||
set_data4f(pointer, LVecBase4f(data, 0.0f, 0.0f, 1.0f));
|
||||
} else {
|
||||
Writer::set_data1f(pointer, data);
|
||||
|
|
@ -712,7 +712,7 @@ set_data1f(unsigned char *pointer, float data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer_color::
|
||||
set_data2f(unsigned char *pointer, const LVecBase2f &data) {
|
||||
if (_data_type->get_num_values() == 4) {
|
||||
if (_column->get_num_values() == 4) {
|
||||
set_data4f(pointer, LVecBase4f(data[0], data[1], 0.0f, 1.0f));
|
||||
} else {
|
||||
Writer::set_data2f(pointer, data);
|
||||
|
|
@ -726,7 +726,7 @@ set_data2f(unsigned char *pointer, const LVecBase2f &data) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexWriter::Writer_color::
|
||||
set_data3f(unsigned char *pointer, const LVecBase3f &data) {
|
||||
if (_data_type->get_num_values() == 4) {
|
||||
if (_column->get_num_values() == 4) {
|
||||
set_data4f(pointer, LVecBase4f(data[0], data[1], data[2], 1.0f));
|
||||
} else {
|
||||
Writer::set_data3f(pointer, data);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "pandabase.h"
|
||||
#include "qpgeomVertexData.h"
|
||||
#include "qpgeomVertexDataType.h"
|
||||
#include "qpgeomVertexColumn.h"
|
||||
#include "internalName.h"
|
||||
#include "luse.h"
|
||||
#include "pointerTo.h"
|
||||
|
|
@ -42,16 +42,18 @@
|
|||
// you call set_vertex() into the middle of existing
|
||||
// data the add_data*() methods will behave like the
|
||||
// corresponding set_data*(), but if they run past the
|
||||
// end of existing data they will quietly add new data.
|
||||
// end of existing data they will quietly add new
|
||||
// vertices.
|
||||
//
|
||||
// Like GeomVertexReader, the writer is particularly
|
||||
// optimized for writing a column of data values for a
|
||||
// series of vertices, without changing data types
|
||||
// between each number. Although you can use one
|
||||
// GeomVertexWriter to write one complete row at a time,
|
||||
// by calling set_data_type() repeatedly for each
|
||||
// vertex, it is faster to use a different
|
||||
// GeomVertexWriter for each data type.
|
||||
// optimized for writing a single column of data values
|
||||
// for a series of vertices, without changing columns
|
||||
// between each number. Although you can also use one
|
||||
// GeomVertexWriter to write across the columns if it is
|
||||
// convenient, by calling set_column() repeatedly at
|
||||
// each vertex, it is faster to write down the columns,
|
||||
// and to use a different GeomVertexWriter for each
|
||||
// column.
|
||||
//
|
||||
// Note that, like a GeomVertexReader, a
|
||||
// GeomVertexWriter does not keep a reference count to
|
||||
|
|
@ -81,14 +83,14 @@ PUBLISHED:
|
|||
|
||||
INLINE qpGeomVertexData *get_vertex_data() const;
|
||||
|
||||
INLINE bool set_data_type(int data_type);
|
||||
INLINE bool set_data_type(const string &name);
|
||||
INLINE bool set_data_type(const InternalName *name);
|
||||
bool set_data_type(int array, const qpGeomVertexDataType *data_type);
|
||||
INLINE bool set_column(int column);
|
||||
INLINE bool set_column(const string &name);
|
||||
INLINE bool set_column(const InternalName *name);
|
||||
bool set_column(int array, const qpGeomVertexColumn *column);
|
||||
|
||||
INLINE bool has_data_type() const;
|
||||
INLINE bool has_column() const;
|
||||
INLINE int get_array() const;
|
||||
INLINE const qpGeomVertexDataType *get_data_type() const;
|
||||
INLINE const qpGeomVertexColumn *get_column() const;
|
||||
|
||||
INLINE void set_vertex(int vertex);
|
||||
|
||||
|
|
@ -139,7 +141,7 @@ private:
|
|||
|
||||
PT(qpGeomVertexData) _vertex_data;
|
||||
int _array;
|
||||
const qpGeomVertexDataType *_data_type;
|
||||
const qpGeomVertexColumn *_column;
|
||||
int _stride;
|
||||
|
||||
unsigned char *_pointer;
|
||||
|
|
@ -172,7 +174,7 @@ private:
|
|||
INLINE void maybe_scale_color(const LVecBase3f &data);
|
||||
INLINE void maybe_scale_color(const LVecBase4f &data);
|
||||
|
||||
const qpGeomVertexDataType *_data_type;
|
||||
const qpGeomVertexColumn *_column;
|
||||
unsigned int _a, _b, _c, _d;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -244,6 +244,23 @@ transform_point(LPoint3f &point) const {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TransformBlend::transform_vector
|
||||
// Access: Published
|
||||
// Description: Transforms the indicated vector by the blend matrix.
|
||||
//
|
||||
// You should call update_blend() to ensure that the
|
||||
// cache is up-to-date before calling this.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void TransformBlend::
|
||||
transform_vector(LVector3f &vector) const {
|
||||
if (!_entries.empty()) {
|
||||
CDReader cdata(_cycler);
|
||||
nassertv(cdata->_global_modified == VertexTransform::get_global_modified());
|
||||
vector = vector * cdata->_result;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TransformBlend::get_modified
|
||||
// Access: Published
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ PUBLISHED:
|
|||
INLINE void get_blend(LMatrix4f &result) const;
|
||||
INLINE void transform_point(LPoint4f &point) const;
|
||||
INLINE void transform_point(LPoint3f &point) const;
|
||||
INLINE void transform_vector(LVector3f &point) const;
|
||||
INLINE UpdateSeq get_modified() const;
|
||||
|
||||
void output(ostream &out) const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue