|
@@ -3207,13 +3207,14 @@ get_texture(TextureStage *stage) const {
|
|
|
* Recursively searches the scene graph for references to the given texture,
|
|
* Recursively searches the scene graph for references to the given texture,
|
|
|
* and replaces them with the new texture.
|
|
* and replaces them with the new texture.
|
|
|
*
|
|
*
|
|
|
|
|
+ * As of Panda3D 1.10.13, new_tex may be null to remove the texture.
|
|
|
|
|
+ *
|
|
|
* @since 1.10.4
|
|
* @since 1.10.4
|
|
|
*/
|
|
*/
|
|
|
void NodePath::
|
|
void NodePath::
|
|
|
replace_texture(Texture *tex, Texture *new_tex) {
|
|
replace_texture(Texture *tex, Texture *new_tex) {
|
|
|
nassertv_always(!is_empty());
|
|
nassertv_always(!is_empty());
|
|
|
nassertv(tex != nullptr);
|
|
nassertv(tex != nullptr);
|
|
|
- nassertv(new_tex != nullptr);
|
|
|
|
|
|
|
|
|
|
r_replace_texture(node(), tex, new_tex);
|
|
r_replace_texture(node(), tex, new_tex);
|
|
|
}
|
|
}
|
|
@@ -4249,15 +4250,19 @@ get_material() const {
|
|
|
* Recursively searches the scene graph for references to the given material,
|
|
* Recursively searches the scene graph for references to the given material,
|
|
|
* and replaces them with the new material.
|
|
* and replaces them with the new material.
|
|
|
*
|
|
*
|
|
|
|
|
+ * As of Panda3D 1.10.13, new_mat may be null to remove the material.
|
|
|
|
|
+ *
|
|
|
* @since 1.10.0
|
|
* @since 1.10.0
|
|
|
*/
|
|
*/
|
|
|
void NodePath::
|
|
void NodePath::
|
|
|
replace_material(Material *mat, Material *new_mat) {
|
|
replace_material(Material *mat, Material *new_mat) {
|
|
|
nassertv_always(!is_empty());
|
|
nassertv_always(!is_empty());
|
|
|
nassertv(mat != nullptr);
|
|
nassertv(mat != nullptr);
|
|
|
- nassertv(new_mat != nullptr);
|
|
|
|
|
|
|
|
|
|
- CPT(RenderAttrib) new_attrib = MaterialAttrib::make(new_mat);
|
|
|
|
|
|
|
+ CPT(RenderAttrib) new_attrib;
|
|
|
|
|
+ if (new_mat != nullptr) {
|
|
|
|
|
+ new_attrib = MaterialAttrib::make(new_mat);
|
|
|
|
|
+ }
|
|
|
r_replace_material(node(), mat, (const MaterialAttrib *)new_attrib.p());
|
|
r_replace_material(node(), mat, (const MaterialAttrib *)new_attrib.p());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -6841,7 +6846,11 @@ r_replace_material(PandaNode *node, Material *mat,
|
|
|
const MaterialAttrib *ma;
|
|
const MaterialAttrib *ma;
|
|
|
if (node_state->get_attrib(ma)) {
|
|
if (node_state->get_attrib(ma)) {
|
|
|
if (mat == ma->get_material()) {
|
|
if (mat == ma->get_material()) {
|
|
|
- node->set_state(node_state->set_attrib(new_attrib));
|
|
|
|
|
|
|
+ if (new_attrib != nullptr) {
|
|
|
|
|
+ node->set_state(node_state->set_attrib(new_attrib));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ node->set_state(node_state->remove_attrib(MaterialAttrib::get_class_slot()));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -6860,7 +6869,11 @@ r_replace_material(PandaNode *node, Material *mat,
|
|
|
if (geom_state->get_attrib(ma)) {
|
|
if (geom_state->get_attrib(ma)) {
|
|
|
if (mat == ma->get_material()) {
|
|
if (mat == ma->get_material()) {
|
|
|
// Replace it
|
|
// Replace it
|
|
|
- gnode->set_geom_state(i, geom_state->set_attrib(new_attrib));
|
|
|
|
|
|
|
+ if (new_attrib != nullptr) {
|
|
|
|
|
+ gnode->set_geom_state(i, geom_state->set_attrib(new_attrib));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ gnode->set_geom_state(i, geom_state->remove_attrib(MaterialAttrib::get_class_slot()));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|