1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef MODEL_RENDER_CONTAINER_HDR
#define MODEL_RENDER_CONTAINER_HDR
#define MDL_TYPE(o) (o->model->type)
#define TEX_TYPE(o) (o->model->textureType)
#include "System/UnorderedMap.hpp"
#include "Rendering/Models/3DModel.h"
class CUnit;
class CFeature;
class CProjectile;
class IModelRenderContainer {
public:
static IModelRenderContainer* GetInstance(int);
IModelRenderContainer(int mdlType): modelType(mdlType) {
numUnits = 0;
numFeatures = 0;
numProjectiles = 0;
}
virtual ~IModelRenderContainer();
virtual void AddUnit(const CUnit*);
virtual void DelUnit(const CUnit*);
public:
virtual void AddFeature(const CFeature*);
virtual void DelFeature(const CFeature*);
virtual void AddProjectile(const CProjectile*);
virtual void DelProjectile(const CProjectile*);
unsigned int GetNumUnits() const { return numUnits; }
unsigned int GetNumFeatures() const { return numFeatures; }
unsigned int GetNumProjectiles() const { return numProjectiles; }
protected:
typedef std::vector< CUnit*> UnitSet;
typedef std::vector< CFeature*> FeatureSet;
typedef std::vector<CProjectile*> ProjectileSet;
// textureType ==> modelSet
typedef spring::unordered_map<int, UnitSet> UnitRenderBin;
typedef spring::unordered_map<int, FeatureSet> FeatureRenderBin;
typedef spring::unordered_map<int, ProjectileSet> ProjectileRenderBin;
UnitRenderBin units; // all opaque or all cloaked
FeatureRenderBin features; // all (opaque and fade) or all shadow
ProjectileRenderBin projectiles; // opaque only, (synced && (piece || weapon)) only
int modelType;
unsigned int numUnits;
unsigned int numFeatures;
unsigned int numProjectiles;
public:
const UnitSet& GetUnitSet(int texType) { return units[texType]; }
const FeatureSet& GetFeatureSet(int texType) { return features[texType]; }
const ProjectileSet& GetProjectileSet(int texType) { return projectiles[texType]; }
const UnitRenderBin& GetUnitBin() const { return units; }
const FeatureRenderBin& GetFeatureBin() const { return features; }
const ProjectileRenderBin& GetProjectileBin() const { return projectiles; }
UnitRenderBin& GetUnitBinMutable() { return units; }
FeatureRenderBin& GetFeatureBinMutable() { return features; }
ProjectileRenderBin& GetProjectileBinMutable() { return projectiles; }
};
class ModelRenderContainer3DO: public IModelRenderContainer {
public:
ModelRenderContainer3DO(): IModelRenderContainer(MODELTYPE_3DO) {}
};
class ModelRenderContainerS3O: public IModelRenderContainer {
public:
ModelRenderContainerS3O(): IModelRenderContainer(MODELTYPE_S3O) {}
};
class ModelRenderContainerOBJ: public IModelRenderContainer {
public:
ModelRenderContainerOBJ(): IModelRenderContainer(MODELTYPE_OBJ) {}
};
class ModelRenderContainerASS: public IModelRenderContainer {
public:
ModelRenderContainerASS(): IModelRenderContainer(MODELTYPE_ASS) {}
};
#endif
|