TDME2 1.9.121
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
EntityRenderer Class Referencefinal

Rendering class. More...

#include <tdme/engine/subsystems/rendering/EntityRenderer.h>

Collaboration diagram for EntityRenderer:
Collaboration graph

Classes

struct  Object3DRenderContext
 

Public Member Functions

 EntityRenderer (Engine *engine, Renderer *renderer)
 Public constructor. More...
 
 ~EntityRenderer ()
 Destructor. More...
 
void initialize ()
 Init. More...
 
void dispose ()
 Dispose. More...
 
BatchRendererTrianglesacquireTrianglesBatchRenderer ()
 
void reset ()
 Resets the object 3d renderer. More...
 
void render (Entity::RenderPass renderPass, const vector< Object3D * > &objects, bool renderTransparentFaces, int32_t renderTypes)
 Renders all given objects. More...
 
void renderTransparentFaces ()
 Renders collected transparent faces. More...
 
void render (Entity::RenderPass renderPass, const vector< Entity * > &pses)
 Render points particle system entities. More...
 
void render (Entity::RenderPass renderPass, const vector< LinesObject3D * > &objects)
 Renders all given lines objects. More...
 

Static Public Attributes

static constexpr int32_t RENDERTYPE_NORMALS { 1 }
 
static constexpr int32_t RENDERTYPE_TEXTUREARRAYS { 2 }
 
static constexpr int32_t RENDERTYPE_TEXTUREARRAYS_DIFFUSEMASKEDTRANSPARENCY { 4 }
 
static constexpr int32_t RENDERTYPE_EFFECTCOLORS { 8 }
 
static constexpr int32_t RENDERTYPE_MATERIALS { 16 }
 
static constexpr int32_t RENDERTYPE_MATERIALS_DIFFUSEMASKEDTRANSPARENCY { 32 }
 
static constexpr int32_t RENDERTYPE_TEXTURES { 64 }
 
static constexpr int32_t RENDERTYPE_TEXTURES_DIFFUSEMASKEDTRANSPARENCY { 128 }
 
static constexpr int32_t RENDERTYPE_LIGHTS { 256 }
 
static constexpr int32_t RENDERTYPE_SHADOWMAPPING { 512 }
 
static constexpr int32_t RENDERTYPE_RENDERGROUP_OBJECTORIGIN { 1024 }
 
static constexpr int32_t RENDERTYPE_ALL { 2047 }
 

Private Member Functions

void prepareTransparentFaces (const vector< TransparentRenderFace * > &transparentRenderFaces)
 Renders transparent faces TODO: guess this should be optimized regarding GL commands skinned mesh is not supported when using GPU. More...
 
void renderTransparentFacesGroups (int contextIdx)
 Render transparent faces groups. More...
 
void releaseTransparentFacesGroups ()
 Release transparent faces groups. More...
 
void renderObjectsOfSameType (int threadIdx, const vector< Object3D * > &objects, bool collectTransparentFaces, int32_t renderTypes, TransparentRenderFacesPool *transparentRenderFacesPool)
 Renders multiple objects of same type(with same model) More...
 
void renderObjectsOfSameTypeNonInstanced (const vector< Object3D * > &objects, bool collectTransparentFaces, int32_t renderTypes)
 Renders multiple objects of same type(with same model) not using instancing. More...
 
void renderObjectsOfSameTypeInstanced (int threadIdx, const vector< Object3D * > &objects, bool collectTransparentFaces, int32_t renderTypes, TransparentRenderFacesPool *transparentRenderFacesPool)
 Renders multiple objects of same type(with same model) using instancing. More...
 
bool checkMaterialChangable (Object3DNode *object3DNode, int32_t facesEntityIdx, int32_t renderTypes)
 Checks if a material could change when having multiple objects but same model. More...
 
void setupMaterial (int contextIdx, Object3DNode *object3DNode, int32_t facesEntityIdx, int32_t renderTypes, bool updateOnly, string &materialKey, const string &currentMaterialKey=string())
 Set ups a material for rendering. More...
 
void clearMaterial (int contextIdx)
 Clear material for rendering. More...
 
void renderFunction (int threadIdx, Entity::RenderPass renderPass, const vector< Object3D * > &objects, unordered_map< uint8_t, unordered_map< Model *, vector< Object3D * > > > &objectsByShadersAndModels, bool renderTransparentFaces, int renderTypes, TransparentRenderFacesPool *transparentRenderFacesPool)
 Render function. More...
 

Private Attributes

Engineengine { nullptr }
 
Rendererrenderer { nullptr }
 
vector< BatchRendererTriangles * > trianglesBatchRenderers
 
unordered_map< uint8_t, unordered_map< Model *, vector< Object3D * > > > objectsByShadersAndModels
 
vector< TransparentRenderFace * > nodeTransparentRenderFaces
 
EntityRenderer_TransparentRenderFacesGroupPooltransparentRenderFacesGroupPool { nullptr }
 
TransparentRenderFacesPooltransparentRenderFacesPool { nullptr }
 
unordered_map< string, TransparentRenderFacesGroup * > transparentRenderFacesGroups
 
RenderTransparentRenderPointsPoolrenderTransparentRenderPointsPool { nullptr }
 
BatchRendererPointspsePointBatchRenderer { nullptr }
 
int threadCount
 
vector< Object3DRenderContextcontexts
 

Static Private Attributes

static constexpr int32_t BATCHRENDERER_MAX { 256 }
 
static constexpr int32_t INSTANCEDRENDERING_OBJECTS_MAX { 16384 }
 

Friends

class Object3DNodeRenderer
 
class TransparentRenderFacesGroup
 
class tdme::engine::Engine
 

Detailed Description

Rendering class.

Author
Andreas Drewke
Version
$Id$

Definition at line 58 of file EntityRenderer.h.

Constructor & Destructor Documentation

◆ EntityRenderer()

EntityRenderer ( Engine engine,
Renderer renderer 
)

Public constructor.

Parameters
engineengine
rendererrenderer

Definition at line 140 of file EntityRenderer.cpp.

◆ ~EntityRenderer()

Destructor.

Definition at line 158 of file EntityRenderer.cpp.

Member Function Documentation

◆ acquireTrianglesBatchRenderer()

BatchRendererTriangles * acquireTrianglesBatchRenderer ( )
Returns
batch renderer for triangles

Definition at line 199 of file EntityRenderer.cpp.

◆ checkMaterialChangable()

bool checkMaterialChangable ( Object3DNode object3DNode,
int32_t  facesEntityIdx,
int32_t  renderTypes 
)
inlineprivate

Checks if a material could change when having multiple objects but same model.

Parameters
object3DNodeobject 3d node
facesEntityIdxfaces entity idx
renderTypesrender types

Definition at line 151 of file EntityRenderer.h.

◆ clearMaterial()

void clearMaterial ( int  contextIdx)
private

Clear material for rendering.

Parameters
contextIdxcontext index

Definition at line 1270 of file EntityRenderer.cpp.

◆ dispose()

void dispose ( )

Dispose.

Definition at line 185 of file EntityRenderer.cpp.

◆ initialize()

void initialize ( )

Init.

Definition at line 175 of file EntityRenderer.cpp.

◆ prepareTransparentFaces()

void prepareTransparentFaces ( const vector< TransparentRenderFace * > &  transparentRenderFaces)
private

Renders transparent faces TODO: guess this should be optimized regarding GL commands skinned mesh is not supported when using GPU.

Parameters
transparentRenderFacestransparent render faces

Definition at line 344 of file EntityRenderer.cpp.

◆ releaseTransparentFacesGroups()

void releaseTransparentFacesGroups ( )
private

Release transparent faces groups.

Definition at line 411 of file EntityRenderer.cpp.

◆ render() [1/3]

void render ( Entity::RenderPass  renderPass,
const vector< Entity * > &  pses 
)

Render points particle system entities.

Parameters
renderPassrender pass
psespoints particle system entities

Definition at line 1305 of file EntityRenderer.cpp.

◆ render() [2/3]

void render ( Entity::RenderPass  renderPass,
const vector< LinesObject3D * > &  objects 
)

Renders all given lines objects.

Parameters
renderPassrender pass
objectslines objects

Definition at line 1445 of file EntityRenderer.cpp.

◆ render() [3/3]

void render ( Entity::RenderPass  renderPass,
const vector< Object3D * > &  objects,
bool  renderTransparentFaces,
int32_t  renderTypes 
)

Renders all given objects.

Parameters
renderPassrender pass
objectsobjects
renderTransparentFacesrender transparent faces
renderTypesrender types

Definition at line 225 of file EntityRenderer.cpp.

◆ renderFunction()

void renderFunction ( int  threadIdx,
Entity::RenderPass  renderPass,
const vector< Object3D * > &  objects,
unordered_map< uint8_t, unordered_map< Model *, vector< Object3D * > > > &  objectsByShadersAndModels,
bool  renderTransparentFaces,
int  renderTypes,
TransparentRenderFacesPool transparentRenderFacesPool 
)
inlineprivate

Render function.

Parameters
threadIdxthread index
objectsobjects
visibleObjectsByModelsobjects by models storage
renderTransparentFacesrender transparent faces
renderTypesrender types

Definition at line 181 of file EntityRenderer.h.

◆ renderObjectsOfSameType()

void renderObjectsOfSameType ( int  threadIdx,
const vector< Object3D * > &  objects,
bool  collectTransparentFaces,
int32_t  renderTypes,
TransparentRenderFacesPool transparentRenderFacesPool 
)
inlineprivate

Renders multiple objects of same type(with same model)

Parameters
threadIdxthread idx
objectsobjects of same type/ with same models
collectTransparentFacescollect render faces
renderTypesrender types
transparentRenderFacesPooltransparent render faces pool

Definition at line 120 of file EntityRenderer.h.

◆ renderObjectsOfSameTypeInstanced()

void renderObjectsOfSameTypeInstanced ( int  threadIdx,
const vector< Object3D * > &  objects,
bool  collectTransparentFaces,
int32_t  renderTypes,
TransparentRenderFacesPool transparentRenderFacesPool 
)
private

Renders multiple objects of same type(with same model) using instancing.

Parameters
threadIdxthread idx
objectsobjects of same type/ with same models
collectTransparentFacescollect render faces
renderTypesrender types

Definition at line 707 of file EntityRenderer.cpp.

◆ renderObjectsOfSameTypeNonInstanced()

void renderObjectsOfSameTypeNonInstanced ( const vector< Object3D * > &  objects,
bool  collectTransparentFaces,
int32_t  renderTypes 
)
private

Renders multiple objects of same type(with same model) not using instancing.

Parameters
objectsobjects of same type/ with same models
collectTransparentFacescollect render faces
renderTypesrender types

Definition at line 419 of file EntityRenderer.cpp.

◆ renderTransparentFaces()

void renderTransparentFaces ( )

Renders collected transparent faces.

Definition at line 277 of file EntityRenderer.cpp.

◆ renderTransparentFacesGroups()

void renderTransparentFacesGroups ( int  contextIdx)
private

Render transparent faces groups.

Parameters
contextIdxcontext index

Definition at line 405 of file EntityRenderer.cpp.

◆ reset()

void reset ( )

Resets the object 3d renderer.

Definition at line 220 of file EntityRenderer.cpp.

◆ setupMaterial()

void setupMaterial ( int  contextIdx,
Object3DNode object3DNode,
int32_t  facesEntityIdx,
int32_t  renderTypes,
bool  updateOnly,
string &  materialKey,
const string &  currentMaterialKey = string() 
)
private

Set ups a material for rendering.

Parameters
contextIdxcontext index
object3DNodeobject 3d node
facesEntityIdxfaces entity idx
renderTypesrender types
updateOnlyupdate only, means material has been set up already, only do changes
materialKeymaterial key
currentMaterialKeycurrent material key or empty

Definition at line 1143 of file EntityRenderer.cpp.

Friends And Related Function Documentation

◆ Object3DNodeRenderer

friend class Object3DNodeRenderer
friend

Definition at line 59 of file EntityRenderer.h.

◆ tdme::engine::Engine

friend class tdme::engine::Engine
friend

Definition at line 61 of file EntityRenderer.h.

◆ TransparentRenderFacesGroup

friend class TransparentRenderFacesGroup
friend

Definition at line 60 of file EntityRenderer.h.

Member Data Documentation

◆ BATCHRENDERER_MAX

constexpr int32_t BATCHRENDERER_MAX { 256 }
staticconstexprprivate

Definition at line 64 of file EntityRenderer.h.

◆ contexts

vector<Object3DRenderContext> contexts
private

Definition at line 91 of file EntityRenderer.h.

◆ engine

Engine* engine { nullptr }
private

Definition at line 79 of file EntityRenderer.h.

◆ INSTANCEDRENDERING_OBJECTS_MAX

constexpr int32_t INSTANCEDRENDERING_OBJECTS_MAX { 16384 }
staticconstexprprivate

Definition at line 65 of file EntityRenderer.h.

◆ nodeTransparentRenderFaces

vector<TransparentRenderFace*> nodeTransparentRenderFaces
private

Definition at line 84 of file EntityRenderer.h.

◆ objectsByShadersAndModels

unordered_map<uint8_t, unordered_map<Model*, vector<Object3D*> > > objectsByShadersAndModels
private

Definition at line 83 of file EntityRenderer.h.

◆ psePointBatchRenderer

BatchRendererPoints* psePointBatchRenderer { nullptr }
private

Definition at line 89 of file EntityRenderer.h.

◆ renderer

Renderer* renderer { nullptr }
private

Definition at line 80 of file EntityRenderer.h.

◆ renderTransparentRenderPointsPool

RenderTransparentRenderPointsPool* renderTransparentRenderPointsPool { nullptr }
private

Definition at line 88 of file EntityRenderer.h.

◆ RENDERTYPE_ALL

constexpr int32_t RENDERTYPE_ALL { 2047 }
staticconstexpr

Definition at line 253 of file EntityRenderer.h.

◆ RENDERTYPE_EFFECTCOLORS

constexpr int32_t RENDERTYPE_EFFECTCOLORS { 8 }
staticconstexpr

Definition at line 245 of file EntityRenderer.h.

◆ RENDERTYPE_LIGHTS

constexpr int32_t RENDERTYPE_LIGHTS { 256 }
staticconstexpr

Definition at line 250 of file EntityRenderer.h.

◆ RENDERTYPE_MATERIALS

constexpr int32_t RENDERTYPE_MATERIALS { 16 }
staticconstexpr

Definition at line 246 of file EntityRenderer.h.

◆ RENDERTYPE_MATERIALS_DIFFUSEMASKEDTRANSPARENCY

constexpr int32_t RENDERTYPE_MATERIALS_DIFFUSEMASKEDTRANSPARENCY { 32 }
staticconstexpr

Definition at line 247 of file EntityRenderer.h.

◆ RENDERTYPE_NORMALS

constexpr int32_t RENDERTYPE_NORMALS { 1 }
staticconstexpr

Definition at line 242 of file EntityRenderer.h.

◆ RENDERTYPE_RENDERGROUP_OBJECTORIGIN

constexpr int32_t RENDERTYPE_RENDERGROUP_OBJECTORIGIN { 1024 }
staticconstexpr

Definition at line 252 of file EntityRenderer.h.

◆ RENDERTYPE_SHADOWMAPPING

constexpr int32_t RENDERTYPE_SHADOWMAPPING { 512 }
staticconstexpr

Definition at line 251 of file EntityRenderer.h.

◆ RENDERTYPE_TEXTUREARRAYS

constexpr int32_t RENDERTYPE_TEXTUREARRAYS { 2 }
staticconstexpr

Definition at line 243 of file EntityRenderer.h.

◆ RENDERTYPE_TEXTUREARRAYS_DIFFUSEMASKEDTRANSPARENCY

constexpr int32_t RENDERTYPE_TEXTUREARRAYS_DIFFUSEMASKEDTRANSPARENCY { 4 }
staticconstexpr

Definition at line 244 of file EntityRenderer.h.

◆ RENDERTYPE_TEXTURES

constexpr int32_t RENDERTYPE_TEXTURES { 64 }
staticconstexpr

Definition at line 248 of file EntityRenderer.h.

◆ RENDERTYPE_TEXTURES_DIFFUSEMASKEDTRANSPARENCY

constexpr int32_t RENDERTYPE_TEXTURES_DIFFUSEMASKEDTRANSPARENCY { 128 }
staticconstexpr

Definition at line 249 of file EntityRenderer.h.

◆ threadCount

int threadCount
private

Definition at line 90 of file EntityRenderer.h.

◆ transparentRenderFacesGroupPool

EntityRenderer_TransparentRenderFacesGroupPool* transparentRenderFacesGroupPool { nullptr }
private

Definition at line 85 of file EntityRenderer.h.

◆ transparentRenderFacesGroups

unordered_map<string, TransparentRenderFacesGroup*> transparentRenderFacesGroups
private

Definition at line 87 of file EntityRenderer.h.

◆ transparentRenderFacesPool

TransparentRenderFacesPool* transparentRenderFacesPool { nullptr }
private

Definition at line 86 of file EntityRenderer.h.

◆ trianglesBatchRenderers

vector<BatchRendererTriangles*> trianglesBatchRenderers
private

Definition at line 82 of file EntityRenderer.h.


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