Torque3D Documentation / _generateds / renderImposterMgr.h

renderImposterMgr.h

Engine/source/renderInstance/renderImposterMgr.h

More...

Classes:

class

This is a shared base render instance type TSLastDetail imposters.

class

This is a render instance for a cached multiple imposter batch.

class

This is a render instance for a single imposter.

class

This is a special render manager for processing single billboard imposters typically generated by the tsLastDetail class.

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _IMPOSTERRENDERMGR_H_
 25#define _IMPOSTERRENDERMGR_H_
 26
 27#ifndef _RENDERBINMANAGER_H_
 28#include "renderInstance/renderBinManager.h"
 29#endif
 30#ifndef _GFXPRIMITIVEBUFFER_H_
 31#include "gfx/gfxPrimitiveBuffer.h"
 32#endif
 33#ifndef _MATTEXTURETARGET_H_
 34#include "materials/matTextureTarget.h"
 35#endif
 36#ifndef _TSLASTDETAIL_H_
 37#include "ts/tsLastDetail.h"
 38#endif
 39
 40class TSLastDetail;
 41class GFXTextureObject;
 42class RenderDeferredMgr;
 43struct ImposterRenderInst;
 44
 45
 46/*
 47GFXDeclareVertexFormat( ImposterCorner )
 48{
 49   /// billboard corner index
 50   float corner;
 51};
 52*/
 53
 54/// This is a special render manager for processing single 
 55/// billboard imposters typically generated by the tsLastDetail
 56/// class.  It tries to render them in large batches with as 
 57/// few state changes as possible.  For an example of use see 
 58/// TSLastDetail::render().
 59class RenderImposterMgr : public RenderBinManager
 60{
 61protected:
 62    
 63   typedef RenderBinManager Parent;
 64
 65   static const U32 smImposterBatchSize = 1000;
 66
 67   static U32 smRendered;
 68   static U32 smBatches;
 69   static U32 smDrawCalls;
 70   static U32 smPolyCount;
 71   static U32 smRTChanges;
 72
 73   ImposterState mBuffer[smImposterBatchSize*4];
 74   
 75   GFXPrimitiveBufferHandle mIB;
 76   //GFXVertexBufferHandle<ImposterCorner> mCornerVB;   
 77
 78   void _innerRender( const SceneRenderState *state, RenderDeferredMgr *deferredBin );
 79
 80   void _renderDeferred( const SceneRenderState *state, RenderDeferredMgr *deferredBin, bool startDeferred );
 81
 82   static bool _clearStats( GFXDevice::GFXDeviceEventType type );
 83
 84public:
 85
 86   static const RenderInstType RIT_Imposter;
 87   static const RenderInstType RIT_ImposterBatch;
 88
 89   RenderImposterMgr( F32 renderOrder = 1.0f, F32 processAddOrder  = 1.0f );
 90   virtual ~RenderImposterMgr();
 91
 92   // ConsoleObject
 93   DECLARE_CONOBJECT(RenderImposterMgr);
 94   static void initPersistFields();
 95
 96   // RenderBinManager
 97   virtual void render( SceneRenderState *state );
 98};
 99
100
101/// This is a shared base render instance type TSLastDetail imposters.
102/// @see TSLastDetail
103/// @see RenderImposterMgr
104struct ImposterBaseRenderInst : public RenderInst
105{
106   /// The material for this imposter.
107   BaseMatInstance *mat;
108};
109
110
111/// This is a render instance for a single imposter.
112struct ImposterRenderInst : public ImposterBaseRenderInst
113{
114   /// The imposter state.
115   ImposterState state;
116
117   /// Helper for setting this instance to a default state.
118   void clear()
119   {
120      dMemset( this, 0, sizeof( ImposterRenderInst ) );
121      type = RenderImposterMgr::RIT_Imposter;
122   }
123};
124
125
126/// This is a render instance for a cached multiple imposter batch.
127struct ImposterBatchRenderInst : public ImposterBaseRenderInst
128{
129   /// The pre-built vertex buffer batch of imposters.
130   GFXVertexBufferHandleBase *vertBuff;
131
132   /// Helper for setting this instance to a default state.
133   void clear()
134   {
135      dMemset( this, 0, sizeof( ImposterBatchRenderInst ) );
136      type = RenderImposterMgr::RIT_ImposterBatch;
137   }
138};
139
140#endif // _TSIMPOSTERRENDERMGR_H_
141