animate properly in dx
This commit is contained in:
parent
03e766a9ab
commit
bc56b6467b
|
|
@ -32,6 +32,7 @@ munge_format_impl(const qpGeomVertexFormat *orig) {
|
|||
// We have to build a completely new format that includes only the
|
||||
// appropriate components, in the appropriate order, in just one
|
||||
// array.
|
||||
PT(qpGeomVertexFormat) new_format = new qpGeomVertexFormat(*orig);
|
||||
PT(qpGeomVertexArrayFormat) new_array_format = new qpGeomVertexArrayFormat;
|
||||
|
||||
const qpGeomVertexDataType *vertex_type =
|
||||
|
|
@ -47,6 +48,7 @@ munge_format_impl(const qpGeomVertexFormat *orig) {
|
|||
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());
|
||||
} else {
|
||||
// If we don't have a vertex type, not much we can do.
|
||||
return orig;
|
||||
|
|
@ -56,12 +58,14 @@ munge_format_impl(const qpGeomVertexFormat *orig) {
|
|||
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 (color_type != (const qpGeomVertexDataType *)NULL) {
|
||||
new_array_format->add_data_type
|
||||
(InternalName::get_color(), 1, qpGeomVertexDataType::NT_packed_8888,
|
||||
qpGeomVertexDataType::C_argb);
|
||||
new_format->remove_data_type(color_type->get_name());
|
||||
}
|
||||
|
||||
// To support multitexture, we will need to add all of the relevant
|
||||
|
|
@ -71,9 +75,18 @@ munge_format_impl(const qpGeomVertexFormat *orig) {
|
|||
new_array_format->add_data_type
|
||||
(InternalName::get_texcoord(), texcoord_type->get_num_values(),
|
||||
qpGeomVertexDataType::NT_float32, qpGeomVertexDataType::C_texcoord);
|
||||
new_format->remove_data_type(texcoord_type->get_name());
|
||||
}
|
||||
|
||||
PT(qpGeomVertexFormat) new_format = new qpGeomVertexFormat(new_array_format);
|
||||
if (new_array_format->is_data_subset_of(*orig->get_array(0))) {
|
||||
// If the new array format we have built is essentially the same
|
||||
// as the first data array anyway, go ahead and keep the original.
|
||||
return orig;
|
||||
}
|
||||
|
||||
// Use the new format; make sure the DX8-friendly array is first in
|
||||
// the list.
|
||||
new_format->insert_array(0, new_array_format);
|
||||
return qpGeomVertexFormat::register_format(new_format);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -843,6 +843,13 @@ update_animated_vertices(qpGeomVertexData::CDWriter &cdata, bool from_app) {
|
|||
qpGeomVertexReader from(this, InternalName::get_vertex());
|
||||
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 (from.get_data_type()->get_num_values() == 4) {
|
||||
for (int i = 0; i < num_vertices; i++) {
|
||||
LPoint4f vertex = from.get_data4f();
|
||||
|
|
|
|||
|
|
@ -162,6 +162,25 @@ add_array(qpGeomVertexArrayFormat *array_format) {
|
|||
return new_array;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::insert_array
|
||||
// Access: Published
|
||||
// Description: Adds the indicated array definition to the list of
|
||||
// arrays at the indicated position. This works just
|
||||
// like add_array(), except that you can specify which
|
||||
// array index the new array should have.
|
||||
//
|
||||
// This may not be called once the format has been
|
||||
// registered.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void qpGeomVertexFormat::
|
||||
insert_array(int array, qpGeomVertexArrayFormat *array_format) {
|
||||
nassertv(!_is_registered);
|
||||
nassertv(array >= 0 && array <= (int)_arrays.size());
|
||||
|
||||
_arrays.insert(_arrays.begin() + array, array_format);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpGeomVertexFormat::clear_arrays
|
||||
// Access: Published
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ PUBLISHED:
|
|||
void set_array(int array, qpGeomVertexArrayFormat *format);
|
||||
void remove_array(int array);
|
||||
int add_array(qpGeomVertexArrayFormat *array_format);
|
||||
void insert_array(int array, qpGeomVertexArrayFormat *array_format);
|
||||
void clear_arrays();
|
||||
|
||||
int get_num_data_types() const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue