hopefully working implementation of mpfNoSelect from this discussion: http://glest.org/glest_board/index.php?topic=8165.msg82932#msg82932

This commit is contained in:
Titus Tscharntke 2012-07-14 21:29:15 +00:00
parent 62bc601cc6
commit d10d5fc770
8 changed files with 33 additions and 9 deletions

View File

@ -215,6 +215,7 @@ public:
void removeUnitFromSelection(const Unit *unit); void removeUnitFromSelection(const Unit *unit);
Uint64 getTickCount() {return tickCount;}
bool getPaused(); bool getPaused();
void setPaused(bool value, bool forceAllowPauseStateChange=false); void setPaused(bool value, bool forceAllowPauseStateChange=false);
void tryPauseToggle(bool pause); void tryPauseToggle(bool pause);

View File

@ -1756,7 +1756,6 @@ void Renderer::renderMouse3d() {
const UnitType *building= gui->getBuilding(); const UnitType *building= gui->getBuilding();
const Gui *gui= game->getGui(); const Gui *gui= game->getGui();
renderGhostModel(building, pos, gui->getSelectedFacing()); renderGhostModel(building, pos, gui->getSelectedFacing());
modelRenderer->end(); modelRenderer->end();
@ -4625,7 +4624,9 @@ void Renderer::renderGhostModel(const UnitType *building, const Vec2i pos,Cardin
color= Vec4f(1.f, 1.f, 1.f, 0.5f); color= Vec4f(1.f, 1.f, 1.f, 0.5f);
} }
else { else {
color= Vec4f(1.f, 0.f, 0.f, 0.5f); // Uint64 tc=game->getTickCount();
// float red=0.49f+((tc%4*1.0f)/2);
color= Vec4f(1.0f, 0.f, 0.f, 0.5f);
} }
} }
@ -7005,7 +7006,7 @@ vector<Unit *> Renderer::renderUnitsFast(bool renderingShadows, bool colorPickin
//assertGl(); //assertGl();
modelRenderer->render(model); modelRenderer->render(model,rmSelection);
glPopMatrix(); glPopMatrix();

View File

@ -34,7 +34,7 @@ public:
ModelRendererGl(); ModelRendererGl();
virtual void begin(bool renderNormals, bool renderTextures, bool renderColors, MeshCallback *meshCallback); virtual void begin(bool renderNormals, bool renderTextures, bool renderColors, MeshCallback *meshCallback);
virtual void end(); virtual void end();
virtual void render(Model *model); virtual void render(Model *model,int renderMode=rmNormal);
virtual void renderNormalsOnly(Model *model); virtual void renderNormalsOnly(Model *model);
void setDuplicateTexCoords(bool duplicateTexCoords) {this->duplicateTexCoords= duplicateTexCoords;} void setDuplicateTexCoords(bool duplicateTexCoords) {this->duplicateTexCoords= duplicateTexCoords;}
@ -42,7 +42,7 @@ public:
private: private:
void renderMesh(Mesh *mesh); void renderMesh(Mesh *mesh,int renderMode=rmNormal);
void renderMeshNormals(Mesh *mesh); void renderMeshNormals(Mesh *mesh);
}; };

View File

@ -70,6 +70,7 @@ private:
//properties //properties
bool twoSided; bool twoSided;
bool customColor; bool customColor;
bool noSelect;
uint32 textureFlags; uint32 textureFlags;
@ -123,6 +124,7 @@ public:
//properties //properties
bool getTwoSided() const {return twoSided;} bool getTwoSided() const {return twoSided;}
bool getCustomTexture() const {return customColor;} bool getCustomTexture() const {return customColor;}
bool getNoSelect() const {return noSelect;}
//external data //external data
const InterpolationData *getInterpolationData() const {return interpolationData;} const InterpolationData *getInterpolationData() const {return interpolationData;}

View File

@ -42,7 +42,8 @@ enum ModelType{
enum MeshPropertyFlag{ enum MeshPropertyFlag{
mpfCustomColor= 1, mpfCustomColor= 1,
mpfTwoSided= 2 mpfTwoSided= 2,
mpfNoSelect= 4
}; };
enum MeshTexture{ enum MeshTexture{

View File

@ -18,6 +18,14 @@
namespace Shared{ namespace Graphics{ namespace Shared{ namespace Graphics{
enum RenderMode{
rmNormal,
rmSelection,
renderModeCount
};
class Texture; class Texture;
// ===================================================== // =====================================================
@ -50,7 +58,7 @@ public:
virtual void begin(bool renderNormals, bool renderTextures, bool renderColors, MeshCallback *meshCallback= NULL)=0; virtual void begin(bool renderNormals, bool renderTextures, bool renderColors, MeshCallback *meshCallback= NULL)=0;
virtual void end()=0; virtual void end()=0;
virtual void render(Model *model)=0; virtual void render(Model *model,int renderMode=rmNormal)=0;
virtual void renderNormalsOnly(Model *model)=0; virtual void renderNormalsOnly(Model *model)=0;
}; };

View File

@ -103,7 +103,7 @@ void ModelRendererGl::end() {
assertGl(); assertGl();
} }
void ModelRendererGl::render(Model *model) { void ModelRendererGl::render(Model *model,int renderMode) {
//assertions //assertions
assert(rendering); assert(rendering);
assertGl(); assertGl();
@ -138,8 +138,12 @@ void ModelRendererGl::renderNormalsOnly(Model *model) {
// ===================== PRIVATE ======================= // ===================== PRIVATE =======================
void ModelRendererGl::renderMesh(Mesh *mesh) { void ModelRendererGl::renderMesh(Mesh *mesh,int renderMode) {
if(renderMode==rmSelection && mesh->getNoSelect()==true)
{// don't render this and do nothing
return;
}
//assertions //assertions
assertGl(); assertGl();

View File

@ -62,6 +62,7 @@ Mesh::Mesh() {
twoSided= false; twoSided= false;
customColor= false; customColor= false;
noSelect= false;
textureFlags=0; textureFlags=0;
@ -242,6 +243,7 @@ void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *tex
//misc //misc
twoSided= false; twoSided= false;
customColor= false; customColor= false;
noSelect= false;
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Load v2, this = %p Found meshHeader.hasTexture = %d, texName [%s] mtDiffuse = %d meshIndex = %d\n",this,meshHeader.hasTexture,toLower(reinterpret_cast<char*>(meshHeader.texName)).c_str(),mtDiffuse,meshIndex); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Load v2, this = %p Found meshHeader.hasTexture = %d, texName [%s] mtDiffuse = %d meshIndex = %d\n",this,meshHeader.hasTexture,toLower(reinterpret_cast<char*>(meshHeader.texName)).c_str(),mtDiffuse,meshIndex);
@ -327,6 +329,7 @@ void Mesh::loadV3(int meshIndex, const string &dir, FILE *f,
//misc //misc
twoSided= (meshHeader.properties & mp3TwoSided) != 0; twoSided= (meshHeader.properties & mp3TwoSided) != 0;
customColor= (meshHeader.properties & mp3CustomColor) != 0; customColor= (meshHeader.properties & mp3CustomColor) != 0;
noSelect = false;
textureFlags= 0; textureFlags= 0;
if((meshHeader.properties & mp3NoTexture) != mp3NoTexture) { if((meshHeader.properties & mp3NoTexture) != mp3NoTexture) {
@ -464,6 +467,7 @@ void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textu
//properties //properties
customColor= (meshHeader.properties & mpfCustomColor) != 0; customColor= (meshHeader.properties & mpfCustomColor) != 0;
twoSided= (meshHeader.properties & mpfTwoSided) != 0; twoSided= (meshHeader.properties & mpfTwoSided) != 0;
noSelect= (meshHeader.properties & mpfNoSelect) != 0;
//material //material
diffuseColor= Vec3f(meshHeader.diffuseColor); diffuseColor= Vec3f(meshHeader.diffuseColor);
@ -537,6 +541,9 @@ void Mesh::save(int meshIndex, const string &dir, FILE *f, TextureManager *textu
if(twoSided) { if(twoSided) {
meshHeader.properties |= mpfTwoSided; meshHeader.properties |= mpfTwoSided;
} }
if(noSelect) {
meshHeader.properties |= mpfNoSelect;
}
meshHeader.textures = textureFlags; meshHeader.textures = textureFlags;
fwrite(&meshHeader, sizeof(MeshHeader), 1, f); fwrite(&meshHeader, sizeof(MeshHeader), 1, f);