@@ -336,7 +336,7 @@ bool DrawAABB::renderSingle(IGPUCommandBuffer* commandBuffer, const hlsl::shapes
336
336
return true ;
337
337
}
338
338
339
- bool DrawAABB::render (IGPUCommandBuffer* commandBuffer, ISemaphore::SWaitInfo waitInfo, const hlsl::float32_t4x4& cameraMat)
339
+ bool DrawAABB::render (IGPUCommandBuffer* commandBuffer, ISemaphore::SWaitInfo waitInfo, std::span< const InstanceData> aabbInstances, const hlsl::float32_t4x4& cameraMat)
340
340
{
341
341
using offset_t = SCachedCreationParameters::streaming_buffer_t ::size_type;
342
342
constexpr auto MdiSizes = std::to_array<offset_t >({ sizeof (float32_t3), sizeof (InstanceData) });
@@ -355,9 +355,11 @@ bool DrawAABB::render(IGPUCommandBuffer* commandBuffer, ISemaphore::SWaitInfo wa
355
355
asset::SBufferBinding<video::IGPUBuffer> indexBinding = { .offset = 0 , .buffer = m_indicesBuffer };
356
356
commandBuffer->bindIndexBuffer (indexBinding, asset::EIT_32BIT);
357
357
358
- auto instances = m_instances ;
359
- for (auto & inst : instances )
358
+ std::vector<InstanceData> instances (aabbInstances. size ()) ;
359
+ for (uint32_t i = 0 ; i < aabbInstances. size (); i++ )
360
360
{
361
+ auto & inst = instances[i];
362
+ inst = aabbInstances[i];
361
363
inst.transform = hlsl::mul (cameraMat, inst.transform );
362
364
}
363
365
@@ -409,25 +411,4 @@ hlsl::float32_t4x4 DrawAABB::getTransformFromAABB(const hlsl::shapes::AABB<3, fl
409
411
return transform;
410
412
}
411
413
412
- void DrawAABB::addAABB (const hlsl::shapes::AABB<3 ,float >& aabb, const hlsl::float32_t4& color)
413
- {
414
- const auto transform = hlsl::float32_t4x4 (1 );
415
- addOBB (aabb, transform, color);
416
- }
417
-
418
- void DrawAABB::addOBB (const hlsl::shapes::AABB<3 , float >& aabb, const hlsl::float32_t4x4& transform, const hlsl::float32_t4& color)
419
- {
420
- InstanceData instance;
421
- instance.color = color;
422
-
423
- hlsl::float32_t4x4 instanceTransform = getTransformFromAABB (aabb);
424
- instance.transform = math::linalg::promoted_mul (transform, instanceTransform);
425
- m_instances.push_back (instance);
426
- }
427
-
428
- void DrawAABB::clearAABBs ()
429
- {
430
- m_instances.clear ();
431
- }
432
-
433
414
}
0 commit comments