15 #include "dxGeomMunger9.h"
16 #include "geomVertexReader.h"
17 #include "geomVertexWriter.h"
18 #include "config_dxgsg9.h"
20 GeomMunger *DXGeomMunger9::_deleted_chain = NULL;
30 if (_reffed_filtered_texture) {
31 unref_delete(_filtered_texture);
32 _reffed_filtered_texture =
false;
48 if (_reffed_filtered_texture) {
49 unref_delete(_filtered_texture);
50 _reffed_filtered_texture =
false;
61 munge_format_impl(const GeomVertexFormat *orig,
63 if (dxgsg9_cat.is_debug()) {
64 if (animation.get_animation_type() != AT_none) {
66 <<
"preparing animation type " << animation <<
" for " << *orig
73 PT(GeomVertexFormat) new_format = new GeomVertexFormat(*orig);
74 new_format->set_animation(animation);
75 PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat;
82 new_array_format->add_column
83 (InternalName::get_vertex(), 3, NT_float32,
84 vertex_type->get_contents());
85 new_format->remove_column(vertex_type->get_name());
92 if (animation.get_animation_type() == AT_hardware &&
93 animation.get_num_transforms() > 0) {
94 if (animation.get_num_transforms() > 1) {
97 new_array_format->add_column
98 (InternalName::get_transform_weight(), animation.get_num_transforms() - 1,
102 if (animation.get_indexed_transforms()) {
105 new_array_format->add_column
106 (InternalName::get_transform_index(), 1,
107 NT_packed_dcba, C_index);
112 new_format->remove_column(InternalName::get_transform_weight());
113 new_format->remove_column(InternalName::get_transform_index());
116 new_format->remove_column(InternalName::get_transform_blend());
120 new_array_format->add_column
121 (InternalName::get_normal(), 3, NT_float32, C_normal);
122 new_format->remove_column(normal_type->get_name());
126 new_array_format->add_column
127 (InternalName::get_color(), 1, NT_packed_dabc, C_color);
128 new_format->remove_column(color_type->get_name());
139 int num_stages = _filtered_texture->get_num_on_ff_stages();
140 vector_int ff_tc_index(num_stages, 0);
147 int max_tc_index = -1;
148 for (si = 0; si < num_stages; ++si) {
149 int tc_index = _filtered_texture->get_ff_tc_index(si);
150 nassertr(tc_index < num_stages, orig);
151 ff_tc_index[tc_index] = si;
152 max_tc_index = max(tc_index, max_tc_index);
158 for (tc_index = 0; tc_index <= max_tc_index; ++tc_index) {
159 si = ff_tc_index[tc_index];
160 TextureStage *stage = _filtered_texture->get_on_ff_stage(si);
166 new_array_format->add_column
171 new_array_format->add_column(name, 2, NT_float32, C_texcoord);
173 new_format->remove_column(name);
179 for (
int i = 0; i < new_format->get_num_arrays(); ++i) {
180 CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i);
181 if (orig_a->count_unused_space() != 0) {
182 PT(GeomVertexArrayFormat) new_a = new GeomVertexArrayFormat;
183 for (
int j = 0; j < orig_a->get_num_columns(); ++j) {
188 new_format->set_array(i, new_a);
194 new_format->insert_array(0, new_array_format);
196 return GeomVertexFormat::register_format(new_format);
206 premunge_format_impl(const GeomVertexFormat *orig) {
210 PT(GeomVertexFormat) new_format = new GeomVertexFormat(*orig);
211 PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat;
218 new_array_format->add_column
219 (InternalName::get_vertex(), 3, NT_float32,
220 vertex_type->get_contents());
221 new_format->remove_column(vertex_type->get_name());
229 new_array_format->add_column
230 (InternalName::get_normal(), 3, NT_float32, C_normal);
231 new_format->remove_column(normal_type->get_name());
235 new_array_format->add_column
236 (InternalName::get_color(), 1, NT_packed_dabc, C_color);
237 new_format->remove_column(color_type->get_name());
248 int num_stages = _filtered_texture->get_num_on_ff_stages();
249 vector_int ff_tc_index(num_stages, 0);
256 int max_tc_index = -1;
257 for (si = 0; si < num_stages; ++si) {
258 int tc_index = _filtered_texture->get_ff_tc_index(si);
259 nassertr(tc_index < num_stages, orig);
260 ff_tc_index[tc_index] = si;
261 max_tc_index = max(tc_index, max_tc_index);
267 for (tc_index = 0; tc_index <= max_tc_index; ++tc_index) {
268 si = ff_tc_index[tc_index];
269 TextureStage *stage = _filtered_texture->get_on_ff_stage(si);
275 new_array_format->add_column
280 new_array_format->add_column(name, 2, NT_float32, C_texcoord);
282 new_format->remove_column(name);
288 for (
int i = 0; i < new_format->get_num_arrays(); ++i) {
289 CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i);
290 if (orig_a->count_unused_space() != 0) {
291 PT(GeomVertexArrayFormat) new_a = new GeomVertexArrayFormat;
292 for (
int j = 0; j < orig_a->get_num_columns(); ++j) {
297 new_format->set_array(i, new_a);
303 new_format->insert_array(0, new_array_format);
305 return GeomVertexFormat::register_format(new_format);
317 compare_to_impl(
const GeomMunger *other)
const {
319 if (_filtered_texture != om->_filtered_texture) {
320 return _filtered_texture < om->_filtered_texture ? -1 : 1;
322 if (_tex_gen != om->_tex_gen) {
323 return _tex_gen < om->_tex_gen ? -1 : 1;
326 return StandardMunger::compare_to_impl(other);
338 geom_compare_to_impl(
const GeomMunger *other)
const {
344 if (_filtered_texture != om->_filtered_texture) {
345 return _filtered_texture < om->_filtered_texture ? -1 : 1;
347 if (_tex_gen != om->_tex_gen) {
348 return _tex_gen < om->_tex_gen ? -1 : 1;
351 return StandardMunger::geom_compare_to_impl(other);
virtual void wp_callback(void *)
This callback is set to be made whenever the associated _texture or _tex_gen attributes are destructe...
This object describes how the vertex animation, if any, represented in a GeomVertexData is encoded...
Objects of this class are used to convert vertex data from a Geom into a format suitable for passing ...
const InternalName * get_name() const
Returns the name of this particular data field, e.g.
int get_num_components() const
Returns the number of components of the column: the number of instances of the NumericType in each el...
This defines how a single column is interleaved within a vertex array stored within a Geom...
Indicates the set of TextureStages and their associated Textures that should be applied to (or remove...
InternalName * get_texcoord_name() const
See set_texcoord_name.
This specialization on GeomMunger finesses vertices for DirectX rendering.
int get_num_values() const
Returns the number of numeric values of the column: the number of distinct numeric values that go int...
Contents get_contents() const
Returns the token representing the semantic meaning of the stored value.
NumericType get_numeric_type() const
Returns the token representing the numeric type of the data storage.
TypeHandle is the identifier used to differentiate C++ class types.
Defines the properties of a named stage of the multitexture pipeline.