From 0ec8f1d758be8fd9e2c7f190dba72c945675597d Mon Sep 17 00:00:00 2001 From: tobspr Date: Sat, 15 Aug 2015 21:07:06 +0200 Subject: [PATCH] Make instance count override properly --- panda/src/pgraph/shaderAttrib.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/panda/src/pgraph/shaderAttrib.cxx b/panda/src/pgraph/shaderAttrib.cxx index 29e78e9dd1..0587bbbaec 100644 --- a/panda/src/pgraph/shaderAttrib.cxx +++ b/panda/src/pgraph/shaderAttrib.cxx @@ -696,8 +696,18 @@ compose_impl(const RenderAttrib *other) const { } } } - // Just copy the instance count. - attr->_instance_count = over->_instance_count; + + // In case no instance count is set, just copy it. + if (attr->_instance_count == 0) { + attr->_instance_count = over->_instance_count; + } else { + // If an instance count is set, check if the other attrib has an instance count set, + // if so, override it, otherwise just keep the current instance count + if (over->_instance_count > 0) { + attr->_instance_count = over->_instance_count; + } + } + // Update the flags. attr->_flags &= ~(over->_has_flags); attr->_flags |= over->_flags;