Commit b4c37cb8 authored by chili's avatar chili
Browse files

refactor Cbuf for increased extensibility

parent bf379f2a
......@@ -14,17 +14,25 @@ namespace Bind
void TransformCbuf::Bind( Graphics& gfx ) noexcept
{
const auto modelView = parent.GetTransformXM() * gfx.GetCamera();
const Transforms tf =
UpdateBindImpl( gfx,GetTransforms( gfx ) );
}
void TransformCbuf::UpdateBindImpl( Graphics& gfx,const Transforms& tf ) noexcept
{
pVcbuf->Update( gfx,tf );
pVcbuf->Bind( gfx );
}
TransformCbuf::Transforms TransformCbuf::GetTransforms( Graphics& gfx ) noexcept
{
const auto modelView = parent.GetTransformXM() * gfx.GetCamera();
return {
DirectX::XMMatrixTranspose( modelView ),
DirectX::XMMatrixTranspose(
modelView *
gfx.GetProjection()
)
};
pVcbuf->Update( gfx,tf );
pVcbuf->Bind( gfx );
}
std::unique_ptr<VertexConstantBuffer<TransformCbuf::Transforms>> TransformCbuf::pVcbuf;
......
......@@ -7,15 +7,18 @@ namespace Bind
{
class TransformCbuf : public Bindable
{
private:
protected:
struct Transforms
{
DirectX::XMMATRIX modelView;
DirectX::XMMATRIX modelViewProj;
DirectX::XMMATRIX model;
};
public:
TransformCbuf( Graphics& gfx,const Drawable& parent,UINT slot = 0u );
void Bind( Graphics& gfx ) noexcept override;
protected:
void UpdateBindImpl( Graphics& gfx,const Transforms& tf ) noexcept;
Transforms GetTransforms( Graphics& gfx ) noexcept;
private:
static std::unique_ptr<VertexConstantBuffer<Transforms>> pVcbuf;
const Drawable& parent;
......
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