Nebula
Loading...
Searching...
No Matches
Models::ModelContext Class Reference

#include <modelcontext.h>

Inherits Graphics::GraphicsContext.

Classes

struct  MaterialInstanceContext
 
struct  ModelInstance
 
struct  NodeInstanceState
 

Public Member Functions

 ModelContext ()
 constructor
 
virtual ~ModelContext ()
 destructor
 
- Public Member Functions inherited from Graphics::GraphicsContext
 GraphicsContext ()
 constructor
 
virtual ~GraphicsContext ()
 destructor
 

Static Public Member Functions

static void Create ()
 create context
 
static void Setup (const Graphics::GraphicsEntityId id, const Resources::ResourceName &name, const Util::StringAtom &tag, std::function< void()> finishedCallback)
 setup
 
static void Setup (const Graphics::GraphicsEntityId id, const Math::mat4 transform, const Math::bbox &boundingBox, const Materials::MaterialId material, const CoreGraphics::MeshId mesh, const IndexT primitiveGroup)
 Setup without a model resource.
 
static void ChangeModel (const Graphics::GraphicsEntityId id, const Resources::ResourceName &name, const Util::StringAtom &tag, std::function< void()> finishedCallback)
 change model for existing entity
 
static const Models::ModelId GetModel (const Graphics::GraphicsEntityId id)
 get model
 
static void SetTransform (const Graphics::GraphicsEntityId id, const Math::mat4 &transform)
 set the transform for a model
 
static Math::mat4 GetTransform (const Graphics::GraphicsEntityId id)
 get the transform for a model
 
static Math::mat4 GetTransform (const Graphics::ContextEntityId id)
 get the transform for a model
 
static Math::bbox ComputeBoundingBox (const Graphics::GraphicsEntityId id)
 Compute the bounding box for a model.
 
static IndexT GetNodeIndex (const Graphics::GraphicsEntityId id, const Util::StringAtom &name)
 Get node index based on name.
 
static MaterialInstanceContextSetupMaterialInstanceContext (const Graphics::GraphicsEntityId id, const IndexT nodeIndex, const CoreGraphics::BatchGroup::Code batch)
 Setup material instance context.
 
static MaterialInstanceContextSetupMaterialInstanceContext (const Graphics::GraphicsEntityId id, const CoreGraphics::BatchGroup::Code batch)
 Setup material instance context.
 
static CoreGraphics::ConstantBufferOffset AllocateInstanceConstants (const Graphics::GraphicsEntityId id, const IndexT nodeIndex, const Materials::BatchIndex batch)
 Allocate constant memory for instance constants in this frame.
 
static CoreGraphics::ConstantBufferOffset AllocateInstanceConstants (const Graphics::GraphicsEntityId id, const Materials::BatchIndex batch)
 Allocate constant memory for instance constants in this frame.
 
static void SetAlwaysVisible (const Graphics::GraphicsEntityId id)
 Set all nodes in the model to always be visible.
 
static void UpdateTransforms (const Graphics::FrameContext &ctx)
 runs before frame is updated
 
static void WaitForWork (const Graphics::FrameContext &ctx)
 Wait for thread work to finish.
 
static void OnRenderDebug (uint32_t flags)
 debug rendering
 
static const Models::ModelId GetModel (const Graphics::ContextEntityId id)
 get model
 
static const NodeInstanceRangeGetModelRenderableRange (const Graphics::GraphicsEntityId id)
 Get model node instance states.
 
static const NodeInstanceRangeGetModelTransformableRange (const Graphics::GraphicsEntityId id)
 Get model node instance transformables.
 
static const Util::Array< NodeInstanceState > & GetModelRenderableStates ()
 Get array to all model node states.
 
static const Util::Array< Math::bbox > & GetModelRenderableBoundingBoxes ()
 Get array to all model node instace bounding boxes.
 
static const Util::Array< NodeInstanceFlags > & GetModelRenderableFlags ()
 Get array to all model node instance flags.
 
static const ModelInstance::RenderableGetModelRenderables ()
 Get node renderable context.
 
static const ModelInstance::TransformableGetModelTransformables ()
 Get node transformable context.
 
static bool IsLoaded (const Graphics::GraphicsEntityId id)
 Get if model is loaded.
 

Static Public Attributes

static Threading::AtomicCounter ConstantsUpdateCounter = 0
 
static Threading::AtomicCounter TransformsUpdateCounter = 0
 

Private Types

enum  {
  Model_Id , Model_NodeInstanceRoots , Model_NodeInstanceTransform , Model_NodeInstanceStates ,
  Model_NodeLookup , Model_Transform , Model_Dirty
}
 
typedef Ids::IdAllocator< Resources::ResourceId, Util::Array< uint32 >, NodeInstanceRange, NodeInstanceRange, Util::Dictionary< Util::StringAtom, IndexT >, Math::mat4, bool > ModelContextAllocator
 

Private Member Functions

 __DeclareContext ()
 

Static Private Member Functions

static Graphics::ContextEntityId Alloc ()
 allocate a new slice for this context
 
static void Dealloc (Graphics::ContextEntityId id)
 deallocate a slice
 

Static Private Attributes

static ModelInstance NodeInstances
 
static Memory::RangeAllocator TransformInstanceAllocator
 
static Memory::RangeAllocator RenderInstanceAllocator
 
static ModelContextAllocator modelContextAllocator
 
static Util::Dictionary< Models::ModelNode *, MaterialInstanceContextmaterialInstanceContexts
 
static Threading::Event completionEvent
 

Friends

class Visibility::VisibilityContext
 
class Raytracing::RaytracingContext
 

Additional Inherited Members

- Static Protected Member Functions inherited from Graphics::GraphicsContext
static void InternalRegisterEntity (const Graphics::GraphicsEntityId id, Graphics::GraphicsContextState &&state)
 
static void InternalDeregisterEntity (const Graphics::GraphicsEntityId id, Graphics::GraphicsContextState &&state)
 
template<class ID_ALLOCATOR >
static void InternalDefragment (ID_ALLOCATOR &allocator, Graphics::GraphicsContextState &&state)
 

Member Typedef Documentation

◆ ModelContextAllocator

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
Model_Id 
Model_NodeInstanceRoots 
Model_NodeInstanceTransform 
Model_NodeInstanceStates 
Model_NodeLookup 
Model_Transform 
Model_Dirty 

Constructor & Destructor Documentation

◆ ModelContext()

Models::ModelContext::ModelContext ( )

constructor

◆ ~ModelContext()

Models::ModelContext::~ModelContext ( )
virtual

destructor

Member Function Documentation

◆ __DeclareContext()

Models::ModelContext::__DeclareContext ( )
private

◆ Alloc()

Graphics::ContextEntityId Models::ModelContext::Alloc ( )
inlinestaticprivate

allocate a new slice for this context

◆ AllocateInstanceConstants() [1/2]

CoreGraphics::ConstantBufferOffset Models::ModelContext::AllocateInstanceConstants ( const Graphics::GraphicsEntityId id,
const IndexT nodeIndex,
const Materials::BatchIndex batch )
static

Allocate constant memory for instance constants in this frame.

◆ AllocateInstanceConstants() [2/2]

CoreGraphics::ConstantBufferOffset Models::ModelContext::AllocateInstanceConstants ( const Graphics::GraphicsEntityId id,
const Materials::BatchIndex batch )
static

Allocate constant memory for instance constants in this frame.

◆ ChangeModel()

void Models::ModelContext::ChangeModel ( const Graphics::GraphicsEntityId id,
const Resources::ResourceName & name,
const Util::StringAtom & tag,
std::function< void()> finishedCallback )
static

change model for existing entity

◆ ComputeBoundingBox()

Math::bbox Models::ModelContext::ComputeBoundingBox ( const Graphics::GraphicsEntityId id)
static

Compute the bounding box for a model.

◆ Create()

void Models::ModelContext::Create ( )
static

create context

◆ Dealloc()

void Models::ModelContext::Dealloc ( Graphics::ContextEntityId id)
inlinestaticprivate

deallocate a slice

◆ GetModel() [1/2]

const Models::ModelId Models::ModelContext::GetModel ( const Graphics::ContextEntityId id)
static

get model

◆ GetModel() [2/2]

const Models::ModelId Models::ModelContext::GetModel ( const Graphics::GraphicsEntityId id)
static

get model

◆ GetModelRenderableBoundingBoxes()

const Util::Array< Math::bbox > & Models::ModelContext::GetModelRenderableBoundingBoxes ( )
static

Get array to all model node instace bounding boxes.

◆ GetModelRenderableFlags()

const Util::Array< NodeInstanceFlags > & Models::ModelContext::GetModelRenderableFlags ( )
static

Get array to all model node instance flags.

◆ GetModelRenderableRange()

const Models::NodeInstanceRange & Models::ModelContext::GetModelRenderableRange ( const Graphics::GraphicsEntityId id)
static

Get model node instance states.

◆ GetModelRenderables()

const ModelContext::ModelInstance::Renderable & Models::ModelContext::GetModelRenderables ( )
static

Get node renderable context.

◆ GetModelRenderableStates()

const Util::Array< ModelContext::NodeInstanceState > & Models::ModelContext::GetModelRenderableStates ( )
static

Get array to all model node states.

◆ GetModelTransformableRange()

const NodeInstanceRange & Models::ModelContext::GetModelTransformableRange ( const Graphics::GraphicsEntityId id)
static

Get model node instance transformables.

◆ GetModelTransformables()

const ModelContext::ModelInstance::Transformable & Models::ModelContext::GetModelTransformables ( )
static

Get node transformable context.

◆ GetNodeIndex()

IndexT Models::ModelContext::GetNodeIndex ( const Graphics::GraphicsEntityId id,
const Util::StringAtom & name )
static

Get node index based on name.

◆ GetTransform() [1/2]

Math::mat4 Models::ModelContext::GetTransform ( const Graphics::ContextEntityId id)
static

get the transform for a model

◆ GetTransform() [2/2]

Math::mat4 Models::ModelContext::GetTransform ( const Graphics::GraphicsEntityId id)
static

get the transform for a model

◆ IsLoaded()

bool Models::ModelContext::IsLoaded ( const Graphics::GraphicsEntityId id)
static

Get if model is loaded.

◆ OnRenderDebug()

void Models::ModelContext::OnRenderDebug ( uint32_t flags)
static

debug rendering

◆ SetAlwaysVisible()

void Models::ModelContext::SetAlwaysVisible ( const Graphics::GraphicsEntityId id)
static

Set all nodes in the model to always be visible.

◆ SetTransform()

void Models::ModelContext::SetTransform ( const Graphics::GraphicsEntityId id,
const Math::mat4 & transform )
static

set the transform for a model

◆ Setup() [1/2]

void Models::ModelContext::Setup ( const Graphics::GraphicsEntityId id,
const Math::mat4 transform,
const Math::bbox & boundingBox,
const Materials::MaterialId material,
const CoreGraphics::MeshId mesh,
const IndexT primitiveGroup )
static

Setup without a model resource.

◆ Setup() [2/2]

void Models::ModelContext::Setup ( const Graphics::GraphicsEntityId id,
const Resources::ResourceName & name,
const Util::StringAtom & tag,
std::function< void()> finishedCallback )
static

setup

◆ SetupMaterialInstanceContext() [1/2]

ModelContext::MaterialInstanceContext & Models::ModelContext::SetupMaterialInstanceContext ( const Graphics::GraphicsEntityId id,
const CoreGraphics::BatchGroup::Code batch )
static

Setup material instance context.

◆ SetupMaterialInstanceContext() [2/2]

ModelContext::MaterialInstanceContext & Models::ModelContext::SetupMaterialInstanceContext ( const Graphics::GraphicsEntityId id,
const IndexT nodeIndex,
const CoreGraphics::BatchGroup::Code batch )
static

Setup material instance context.

◆ UpdateTransforms()

void Models::ModelContext::UpdateTransforms ( const Graphics::FrameContext & ctx)
static

runs before frame is updated

Go through all models and apply their transforms.

◆ WaitForWork()

void Models::ModelContext::WaitForWork ( const Graphics::FrameContext & ctx)
static

Wait for thread work to finish.

Friends And Related Symbol Documentation

◆ Raytracing::RaytracingContext

friend class Raytracing::RaytracingContext
friend

◆ Visibility::VisibilityContext

friend class Visibility::VisibilityContext
friend

Member Data Documentation

◆ completionEvent

Threading::Event Models::ModelContext::completionEvent
staticprivate

◆ ConstantsUpdateCounter

Threading::AtomicCounter Models::ModelContext::ConstantsUpdateCounter = 0
static

◆ materialInstanceContexts

Util::Dictionary< Models::ModelNode *, ModelContext::MaterialInstanceContext > Models::ModelContext::materialInstanceContexts
staticprivate

◆ modelContextAllocator

ModelContext::ModelContextAllocator Models::ModelContext::modelContextAllocator
staticprivate

◆ NodeInstances

ModelContext::ModelInstance Models::ModelContext::NodeInstances
staticprivate

◆ RenderInstanceAllocator

Memory::RangeAllocator Models::ModelContext::RenderInstanceAllocator
staticprivate

◆ TransformInstanceAllocator

Memory::RangeAllocator Models::ModelContext::TransformInstanceAllocator
staticprivate

◆ TransformsUpdateCounter

Threading::AtomicCounter Models::ModelContext::TransformsUpdateCounter = 0
static

The documentation for this class was generated from the following files: