Commit 7fa7828c authored by chili's avatar chili
Browse files

fix static index buffer issue more than 1 box

parent 45e4a393
...@@ -92,6 +92,10 @@ Box::Box( Graphics& gfx, ...@@ -92,6 +92,10 @@ Box::Box( Graphics& gfx,
AddStaticBind( std::make_unique<Topology>( gfx,D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ) ); AddStaticBind( std::make_unique<Topology>( gfx,D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ) );
} }
else
{
SetIndexFromStatic();
}
AddBind( std::make_unique<TransformCbuf>( gfx,*this ) ); AddBind( std::make_unique<TransformCbuf>( gfx,*this ) );
} }
......
...@@ -17,10 +17,23 @@ public: ...@@ -17,10 +17,23 @@ public:
} }
void AddStaticIndexBuffer( std::unique_ptr<IndexBuffer> ibuf ) noexcept(!IS_DEBUG) void AddStaticIndexBuffer( std::unique_ptr<IndexBuffer> ibuf ) noexcept(!IS_DEBUG)
{ {
assert( pIndexBuffer == nullptr ); assert( "Attempting to add index buffer a second time" && pIndexBuffer == nullptr );
pIndexBuffer = ibuf.get(); pIndexBuffer = ibuf.get();
staticBinds.push_back( std::move( ibuf ) ); staticBinds.push_back( std::move( ibuf ) );
} }
void SetIndexFromStatic() noexcept(!IS_DEBUG)
{
assert( "Attempting to add index buffer a second time" && pIndexBuffer == nullptr );
for( const auto& b : staticBinds )
{
if( const auto p = dynamic_cast<IndexBuffer*>(b.get()) )
{
pIndexBuffer = p;
return;
}
}
assert( "Failed to find index buffer in static binds" && pIndexBuffer != nullptr );
}
private: private:
const std::vector<std::unique_ptr<Bindable>>& GetStaticBinds() const noexcept override const std::vector<std::unique_ptr<Bindable>>& GetStaticBinds() const noexcept override
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment