mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
fix combining animated with unanimated vertices
This commit is contained in:
parent
4be8e217f7
commit
1e6729a1e7
@ -99,5 +99,8 @@ operator < (const GeomTransformer::NewCollectedKey &other) const {
|
|||||||
if (_usage_hint != other._usage_hint) {
|
if (_usage_hint != other._usage_hint) {
|
||||||
return (int)_usage_hint < (int)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;
|
return _name < other._name;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "pStatCollector.h"
|
#include "pStatCollector.h"
|
||||||
#include "pStatTimer.h"
|
#include "pStatTimer.h"
|
||||||
#include "vector_int.h"
|
#include "vector_int.h"
|
||||||
|
#include "userVertexTransform.h"
|
||||||
|
|
||||||
static PStatCollector apply_vertex_collector("*:Flatten:apply:vertex");
|
static PStatCollector apply_vertex_collector("*:Flatten:apply:vertex");
|
||||||
static PStatCollector apply_texcoord_collector("*:Flatten:apply:texcoord");
|
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) {
|
if ((collect_bits & SceneGraphReducer::CVD_format) != 0) {
|
||||||
key._format = format;
|
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;
|
AlreadyCollected::const_iterator ai;
|
||||||
ai = _already_collected.find(vdata);
|
ai = _already_collected.find(vdata);
|
||||||
@ -492,9 +502,20 @@ collect_vertex_data(Geom *geom, int collect_bits) {
|
|||||||
// slightly different kinds of data.
|
// slightly different kinds of data.
|
||||||
typedef vector_int IndexMap;
|
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.
|
// 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
|
// First, build a mapping of the transforms we already have in the
|
||||||
// current table. We must do this because the TransformTable
|
// current table. We must do this because the TransformTable
|
||||||
// doesn't automatically unquify index numbers for us (it doesn't
|
// 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
|
// The TransformBlendTable. This one is the easiest, because we
|
||||||
// can modify it directly, and it will uniquify blend objects for
|
// can modify it directly, and it will uniquify blend objects for
|
||||||
// us.
|
// 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;
|
PT(TransformBlendTable) new_btable;
|
||||||
if (new_data->get_transform_blend_table() != (TransformBlendTable *)NULL) {
|
if (new_data->get_transform_blend_table() != (TransformBlendTable *)NULL) {
|
||||||
new_btable = new_data->modify_transform_blend_table();
|
new_btable = new_data->modify_transform_blend_table();
|
||||||
|
@ -128,6 +128,7 @@ private:
|
|||||||
string _name;
|
string _name;
|
||||||
CPT(GeomVertexFormat) _format;
|
CPT(GeomVertexFormat) _format;
|
||||||
Geom::UsageHint _usage_hint;
|
Geom::UsageHint _usage_hint;
|
||||||
|
Geom::AnimationType _animation_type;
|
||||||
};
|
};
|
||||||
typedef pmap< NewCollectedKey, PT(GeomVertexData) > NewCollectedData;
|
typedef pmap< NewCollectedKey, PT(GeomVertexData) > NewCollectedData;
|
||||||
NewCollectedData _new_collected_data;
|
NewCollectedData _new_collected_data;
|
||||||
|
@ -93,6 +93,18 @@ PUBLISHED:
|
|||||||
// formats may be combined by expanding all GeomVertexDatas to the
|
// formats may be combined by expanding all GeomVertexDatas to the
|
||||||
// union of all defined columns.
|
// union of all defined columns.
|
||||||
CVD_format = 0x020,
|
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 {
|
enum MakeNonindexed {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user