19GeomMunger *DXGeomMunger9::_deleted_chain =
nullptr;
33 state->get_attrib(texture);
34 state->get_attrib(tex_gen);
42 const ColorAttrib *color_attrib;
43 const ShaderAttrib *shader_attrib;
44 state->get_attrib_def(shader_attrib);
46 if (!shader_attrib->auto_shader() &&
47 shader_attrib->get_shader() == nullptr &&
48 state->get_attrib(color_attrib) &&
49 color_attrib->get_color_type() != ColorAttrib::T_vertex) {
51 if (color_attrib->get_color_type() == ColorAttrib::T_off) {
52 _color.set(1, 1, 1, 1);
54 _color = color_attrib->get_color();
57 const ColorScaleAttrib *color_scale_attrib;
58 if (state->get_attrib(color_scale_attrib) &&
59 color_scale_attrib->has_scale()) {
60 _color.componentwise_mult(color_scale_attrib->get_scale());
63 _should_munge_state = true;
67 _filtered_texture =
nullptr;
68 _reffed_filtered_texture =
false;
69 if (texture !=
nullptr) {
71 if (_filtered_texture != texture) {
72 _filtered_texture->ref();
73 _reffed_filtered_texture =
true;
78 _texture.add_callback(
this);
79 _tex_gen.add_callback(
this);
87 if (_reffed_filtered_texture) {
89 _reffed_filtered_texture =
false;
92 _texture.remove_callback(
this);
93 _tex_gen.remove_callback(
this);
105 if (_reffed_filtered_texture) {
107 _reffed_filtered_texture =
false;
118 if (dxgsg9_cat.is_debug()) {
121 <<
"preparing animation type " << animation <<
" for " << *orig
127 PT(GeomVertexFormat) new_format =
new GeomVertexFormat(*orig);
128 new_format->set_animation(animation);
129 PT(GeomVertexArrayFormat) new_array_format =
new GeomVertexArrayFormat;
135 if (vertex_type !=
nullptr) {
136 new_array_format->add_column
137 (InternalName::get_vertex(), 3, NT_float32,
139 new_format->remove_column(vertex_type->
get_name());
146 if (animation.get_animation_type() == AT_hardware &&
147 animation.get_num_transforms() > 0) {
148 if (animation.get_num_transforms() > 1) {
151 new_array_format->add_column
152 (InternalName::get_transform_weight(), animation.get_num_transforms() - 1,
153 NT_float32, C_other);
156 if (animation.get_indexed_transforms()) {
159 new_array_format->add_column
160 (InternalName::get_transform_index(), 1,
161 NT_packed_dcba, C_index);
165 new_format->remove_column(InternalName::get_transform_weight());
166 new_format->remove_column(InternalName::get_transform_index());
169 new_format->remove_column(InternalName::get_transform_blend());
172 if (normal_type !=
nullptr) {
173 new_array_format->add_column
174 (InternalName::get_normal(), 3, NT_float32, C_normal);
175 new_format->remove_column(normal_type->
get_name());
178 if (color_type !=
nullptr) {
179 new_array_format->add_column
180 (InternalName::get_color(), 1, NT_packed_dabc, C_color);
181 new_format->remove_column(color_type->
get_name());
190 if (_filtered_texture !=
nullptr) {
191 int num_stages = _filtered_texture->get_num_on_ff_stages();
192 vector_int ff_tc_index(num_stages, 0);
198 int max_tc_index = -1;
199 for (si = 0; si < num_stages; ++si) {
200 int tc_index = _filtered_texture->get_ff_tc_index(si);
201 nassertr(tc_index < num_stages, orig);
202 ff_tc_index[tc_index] = si;
203 max_tc_index = std::max(tc_index, max_tc_index);
209 for (tc_index = 0; tc_index <= max_tc_index; ++tc_index) {
210 si = ff_tc_index[tc_index];
211 TextureStage *stage = _filtered_texture->get_on_ff_stage(si);
214 const GeomVertexColumn *texcoord_type = orig->
get_column(name);
216 if (texcoord_type !=
nullptr) {
217 new_array_format->add_column
222 new_array_format->add_column(name, 2, NT_float32, C_texcoord);
224 new_format->remove_column(name);
230 for (
size_t i = 0; i < new_format->get_num_arrays(); ++i) {
231 CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i);
232 if (orig_a->count_unused_space() != 0) {
233 PT(GeomVertexArrayFormat) new_a =
new GeomVertexArrayFormat;
234 for (
int j = 0; j < orig_a->get_num_columns(); ++j) {
235 const GeomVertexColumn *column = orig_a->get_column(j);
239 new_format->set_array(i, new_a);
244 new_format->insert_array(0, new_array_format);
246 return GeomVertexFormat::register_format(new_format);
257 PT(GeomVertexFormat) new_format =
new GeomVertexFormat(*orig);
258 PT(GeomVertexArrayFormat) new_array_format =
new GeomVertexArrayFormat;
264 if (vertex_type !=
nullptr) {
265 new_array_format->add_column
266 (InternalName::get_vertex(), 3, NT_float32,
268 new_format->remove_column(vertex_type->
get_name());
275 if (normal_type !=
nullptr) {
276 new_array_format->add_column
277 (InternalName::get_normal(), 3, NT_float32, C_normal);
278 new_format->remove_column(normal_type->
get_name());
281 if (color_type !=
nullptr) {
282 new_array_format->add_column
283 (InternalName::get_color(), 1, NT_packed_dabc, C_color);
284 new_format->remove_column(color_type->
get_name());
293 if (_filtered_texture !=
nullptr) {
294 int num_stages = _filtered_texture->get_num_on_ff_stages();
295 vector_int ff_tc_index(num_stages, 0);
301 int max_tc_index = -1;
302 for (si = 0; si < num_stages; ++si) {
303 int tc_index = _filtered_texture->get_ff_tc_index(si);
304 nassertr(tc_index < num_stages, orig);
305 ff_tc_index[tc_index] = si;
306 max_tc_index = std::max(tc_index, max_tc_index);
312 for (tc_index = 0; tc_index <= max_tc_index; ++tc_index) {
313 si = ff_tc_index[tc_index];
314 TextureStage *stage = _filtered_texture->get_on_ff_stage(si);
317 const GeomVertexColumn *texcoord_type = orig->
get_column(name);
319 if (texcoord_type !=
nullptr) {
320 new_array_format->add_column
325 new_array_format->add_column(name, 2, NT_float32, C_texcoord);
327 new_format->remove_column(name);
333 for (
size_t i = 0; i < new_format->get_num_arrays(); ++i) {
334 CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i);
335 if (orig_a->count_unused_space() != 0) {
336 PT(GeomVertexArrayFormat) new_a =
new GeomVertexArrayFormat;
337 for (
int j = 0; j < orig_a->get_num_columns(); ++j) {
338 const GeomVertexColumn *column = orig_a->get_column(j);
342 new_format->set_array(i, new_a);
347 new_format->insert_array(0, new_array_format);
349 return GeomVertexFormat::register_format(new_format);
358compare_to_impl(
const GeomMunger *other)
const {
359 const DXGeomMunger9 *om = DCAST(DXGeomMunger9, other);
360 if (_filtered_texture != om->_filtered_texture) {
361 return _filtered_texture < om->_filtered_texture ? -1 : 1;
363 if (_tex_gen.owner_before(om->_tex_gen)) {
366 if (om->_tex_gen.owner_before(_tex_gen)) {
370 return StandardMunger::compare_to_impl(other);
379geom_compare_to_impl(
const GeomMunger *other)
const {
383 const DXGeomMunger9 *om = DCAST(DXGeomMunger9, other);
384 if (_filtered_texture != om->_filtered_texture) {
385 return _filtered_texture < om->_filtered_texture ? -1 : 1;
387 if (_tex_gen.owner_before(om->_tex_gen)) {
390 if (om->_tex_gen.owner_before(_tex_gen)) {
394 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...
Objects of this class are used to convert vertex data from a Geom into a format suitable for passing ...
This object describes how the vertex animation, if any, represented in a GeomVertexData is encoded.
get_animation_type
Returns the type of animation represented by this spec.
int get_num_values() const
Returns the number of numeric values of the column: the number of distinct numeric values that go int...
NumericType get_numeric_type() const
Returns the token representing the numeric type of the data storage.
const InternalName * get_name() const
Returns the name of this particular data field, e.g.
Contents get_contents() const
Returns the token representing the semantic meaning of the stored value.
int get_num_components() const
Returns the number of components of the column: the number of instances of the NumericType in each el...
Encapsulates all the communication with a particular instance of a given rendering backend.
bool get_color_scale_via_lighting() const
Returns true if this particular GSG can implement (or would prefer to implement) set color and/or col...
get_max_texture_stages
Returns the maximum number of simultaneous textures that may be applied to geometry with multitexturi...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Performs some generic munging that is appropriate for all GSG types; for instance,...
Computes texture coordinates for geometry automatically based on vertex position and/or normal.
Indicates the set of TextureStages and their associated Textures that should be applied to (or remove...
ConstPointerTo< TextureAttrib > filter_to_max(int max_texture_stages) const
Returns a new TextureAttrib, very much like this one, but with the number of on_stages reduced to be ...
get_texcoord_name
See set_texcoord_name.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void unref_delete(RefCountType *ptr)
This global helper function will unref the given ReferenceCount object, and if the reference count re...