fix combining animated with unanimated vertices

This commit is contained in:
David Rose 2007-02-13 19:10:51 +00:00
parent 4be8e217f7
commit 1e6729a1e7
4 changed files with 52 additions and 5 deletions

View File

@ -99,5 +99,8 @@ operator < (const GeomTransformer::NewCollectedKey &other) const {
if (_usage_hint != other._usage_hint) {
return (int)_usage_hint < (int)other._usage_hint;
}
if (_animation_type != other._animation_type) {
return (int)_animation_type < (int)other._animation_type;
}
return _name < other._name;
}

View File

@ -28,6 +28,7 @@
#include "pStatCollector.h"
#include "pStatTimer.h"
#include "vector_int.h"
#include "userVertexTransform.h"
static PStatCollector apply_vertex_collector("*:Flatten:apply:vertex");
static PStatCollector apply_texcoord_collector("*:Flatten:apply:texcoord");
@ -414,7 +415,16 @@ collect_vertex_data(Geom *geom, int collect_bits) {
if ((collect_bits & SceneGraphReducer::CVD_format) != 0) {
key._format = format;
}
key._usage_hint = vdata->get_usage_hint();
if ((collect_bits & SceneGraphReducer::CVD_usage_hint) != 0) {
key._usage_hint = vdata->get_usage_hint();
} else {
key._usage_hint = Geom::UH_unspecified;
}
if ((collect_bits & SceneGraphReducer::CVD_animation_type) != 0) {
key._animation_type = format->get_animation().get_animation_type();
} else {
key._animation_type = Geom::AT_none;
}
AlreadyCollected::const_iterator ai;
ai = _already_collected.find(vdata);
@ -492,9 +502,20 @@ collect_vertex_data(Geom *geom, int collect_bits) {
// slightly different kinds of data.
typedef vector_int IndexMap;
if (vdata->get_transform_table() != (TransformTable *)NULL) {
if (vdata->get_transform_table() != (TransformTable *)NULL ||
new_data->get_transform_table() != (TransformTable *)NULL) {
// The TransformTable.
const TransformTable *old_table = vdata->get_transform_table();
CPT(TransformTable) old_table;
if (vdata->get_transform_table() != (TransformTable *)NULL) {
old_table = vdata->get_transform_table();
} else {
PT(TransformTable) temp_table = new TransformTable;
// There's an implicit identity transform for all nodes.
PT(VertexTransform) identity_transform = new UserVertexTransform("identity");
temp_table->add_transform(identity_transform);
old_table = TransformTable::register_table(temp_table);
}
// First, build a mapping of the transforms we already have in the
// current table. We must do this because the TransformTable
// doesn't automatically unquify index numbers for us (it doesn't
@ -560,11 +581,21 @@ collect_vertex_data(Geom *geom, int collect_bits) {
}
}
if (vdata->get_transform_blend_table() != (TransformBlendTable *)NULL) {
if (vdata->get_transform_blend_table() != (TransformBlendTable *)NULL ||
new_data->get_transform_blend_table() != (TransformBlendTable *)NULL) {
// The TransformBlendTable. This one is the easiest, because we
// can modify it directly, and it will uniquify blend objects for
// us.
const TransformBlendTable *old_btable = vdata->get_transform_blend_table();
CPT(TransformBlendTable) old_btable;
if (vdata->get_transform_blend_table() != (TransformBlendTable *)NULL) {
old_btable = vdata->get_transform_blend_table();
} else {
PT(TransformBlendTable) temp_btable;
temp_btable = new TransformBlendTable;
temp_btable->add_blend(TransformBlend());
old_btable = temp_btable;
}
PT(TransformBlendTable) new_btable;
if (new_data->get_transform_blend_table() != (TransformBlendTable *)NULL) {
new_btable = new_data->modify_transform_blend_table();

View File

@ -128,6 +128,7 @@ private:
string _name;
CPT(GeomVertexFormat) _format;
Geom::UsageHint _usage_hint;
Geom::AnimationType _animation_type;
};
typedef pmap< NewCollectedKey, PT(GeomVertexData) > NewCollectedData;
NewCollectedData _new_collected_data;

View File

@ -93,6 +93,18 @@ PUBLISHED:
// formats may be combined by expanding all GeomVertexDatas to the
// union of all defined columns.
CVD_format = 0x020,
// If set, two GeomVertexDatas with different usage hints (for
// instance, UH_static vs. UH_dynamic) will not be collected
// together.
CVD_usage_hint = 0x040,
// If set, GeomVertexDatas with unanimated vertices will not be
// combined with GeomVertexDatas with animated vertices. Although
// it is legal to mix unanimated and animated vertex datas, doing
// so will convert the unanimated vertices to animated vertices,
// which can result in additional processing requirements.
CVD_animation_type = 0x080,
};
enum MakeNonindexed {