| 269 | } |
| 270 | |
| 271 | void SetNamedConstant(HNamedConstantBuffer buffer, dmhash_t name_hash, dmVMath::Vector4* values, uint32_t num_values, dmRenderDDF::MaterialDesc::ConstantType type) |
| 272 | { |
| 273 | dmHashTable64<NamedConstantBuffer::Constant>& constants = buffer->m_Constants; |
| 274 | |
| 275 | NamedConstantBuffer::Constant* c = constants.Get(name_hash); |
| 276 | if (c && c->m_NumValues != num_values) |
| 277 | { |
| 278 | RemoveNamedConstant(buffer, name_hash); |
| 279 | c = 0; |
| 280 | } |
| 281 | |
| 282 | if (c == 0) |
| 283 | { |
| 284 | if (constants.Full()) |
| 285 | { |
| 286 | uint32_t capacity = constants.Capacity() + 8; |
| 287 | constants.SetCapacity(capacity, capacity * 2); |
| 288 | } |
| 289 | |
| 290 | if (buffer->m_Values.Remaining() < num_values) |
| 291 | buffer->m_Values.OffsetCapacity(num_values - buffer->m_Values.Remaining()); |
| 292 | |
| 293 | uint32_t values_index = buffer->m_Values.Size(); |
| 294 | |
| 295 | buffer->m_Values.SetSize(buffer->m_Values.Size() + num_values); |
| 296 | |
| 297 | NamedConstantBuffer::Constant constant; |
| 298 | constant.m_NameHash = name_hash; |
| 299 | constant.m_NumValues = num_values; |
| 300 | constant.m_ValueIndex = values_index; |
| 301 | constant.m_Type = type; |
| 302 | constants.Put(name_hash, constant); |
| 303 | |
| 304 | // Get the pointer |
| 305 | c = constants.Get(name_hash); |
| 306 | } |
| 307 | |
| 308 | dmVMath::Vector4* p = &buffer->m_Values[c->m_ValueIndex]; |
| 309 | memcpy(p, values, sizeof(values[0]) * num_values); |
| 310 | } |
| 311 | |
| 312 | void SetNamedConstant(HNamedConstantBuffer buffer, dmhash_t name_hash, dmVMath::Vector4* values, uint32_t num_values) |
| 313 | { |