| 166 | } |
| 167 | |
| 168 | void RemoveNamedConstant(HNamedConstantBuffer buffer, dmhash_t name_hash) |
| 169 | { |
| 170 | NamedConstantBuffer::Constant* c = buffer->m_Constants.Get(name_hash); |
| 171 | if (!c) |
| 172 | return; |
| 173 | |
| 174 | uint32_t values_index = c->m_ValueIndex; |
| 175 | uint32_t num_values = c->m_NumValues; |
| 176 | |
| 177 | dmVMath::Vector4* p_current = &buffer->m_Values[values_index]; |
| 178 | // shift the data "left" by num_values |
| 179 | uint32_t remaining = buffer->m_Values.Size() - (values_index + num_values); |
| 180 | |
| 181 | dmVMath::Vector4* p_next = p_current + num_values; |
| 182 | memmove(p_current, p_next, remaining * sizeof(dmVMath::Vector4)); // if it's the last item, then "remaining" will be 0 |
| 183 | |
| 184 | buffer->m_Constants.Erase(name_hash); |
| 185 | buffer->m_Values.SetSize(buffer->m_Values.Size() - num_values); |
| 186 | |
| 187 | ShiftConstantsContext shift_context; |
| 188 | shift_context.m_Index = values_index; |
| 189 | shift_context.m_NumValues = num_values; |
| 190 | shift_context.m_Direction = 0; |
| 191 | buffer->m_Constants.Iterate(ShiftConstantIndices, &shift_context); |
| 192 | } |
| 193 | |
| 194 | Result SetNamedConstantAtIndex(HNamedConstantBuffer buffer, dmhash_t name_hash, dmVMath::Vector4* values, |
| 195 | uint32_t num_values, uint32_t value_index, dmRenderDDF::MaterialDesc::ConstantType constant_type) |