#ifndef _RenderSimulator_h__ #define _RenderSimulator_h__ #include "common.h" #include "Statistics.h" class BspTree; class KdTree; class ViewCell; class KdLeaf; class SimulationStatistics: public StatisticsBase { public: /// view cell with the biggest "cost" float maxCost; /// view cell with the minimal "cost" float minCost; /// average render time float avgRenderTime; /// average render time with the overhead when crossing view cells float avgRtWithoutOverhead; void Reset() { maxCost = 0; minCost = 999999; avgRenderTime = 0; avgRtWithoutOverhead = 0; } void Print(ostream &app) const; friend ostream &operator<<(ostream &s, const SimulationStatistics &stat) { stat.Print(s); return s; } }; /** Simulated rendering using a simple render heuristics. Used to evaluate the quality of the view cell partition. */ class RenderSimulator { public: RenderSimulator(); /** Constructor taking the estimated render cost, the view cell overhead, and the average move speed of the player into account. */ RenderSimulator(float objRendercost, float vcOverhead, float moveSpeed); /** Simulates rendering of the view cells. @returns the statistics of the simulation. */ virtual SimulationStatistics SimulateRendering() = 0; /** Sets estimated render time for a single object in the PVS. */ void SetObjectRenderCost(const float objRenderCost); /** Contant overhead for crossing a view cell border. */ void SetVcOverhead(const float vcOverhead); /** Average move speed of the player during rendering. */ void SetMoveSpeed(const float moveSpeed); protected: /// render time for single object of the PVS float mObjRenderCost; /// const overhead for crossing a view cell border float mVcOverhead; /// move speed of player float mMoveSpeed; }; class BspRenderSimulator: public RenderSimulator { public: BspRenderSimulator(BspTree *bspTree); BspRenderSimulator(float objRenderCost, float vcOverhead, float moveSpeed, BspTree *bspTree); SimulationStatistics SimulateRendering(); protected: /** Simulates rendering of the pvs of one view cell, with given rendering time for an object. @param viewCell the view cell holding the Pvs @param objRenderTime estimated render time for one object of the Pvs */ Real RenderPvs(ViewCell &viewCell, const float objRenderTime) const; BspTree *mBspTree; }; class KdRenderSimulator: public RenderSimulator { public: KdRenderSimulator(KdTree *kdTree); KdRenderSimulator(float objRenderCost, float vcOverhead, float moveSpeed, KdTree *kdTree); SimulationStatistics SimulateRendering(); protected: Real RenderPvs(KdLeaf *leaf, float objRenderTime) const; KdTree *mKdTree; }; #endif // RenderSimulator