2025-07-19 13:54 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000282Spring engineGeneralpublic2007-06-13 12:48
ReporterNemo 
Assigned Totvo 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000282: [patch] cloaked s3o units lose their texture
DescriptionWhen a s3o unit cloaks, the texture dissappears and the unit instead has the patchwork of 3do textures on it that is generally seen when a texture is missing.

Additional InformationGnome said that this used to be an issue in the 'ghost' mode (when placing buildings/when a building has been spotted with ghost buildings on), and in the positional view (lower left hand corner showing the actions of the unit model) in FPS mode.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • diff file icon FixedS3OCloaking.diff (9,027 bytes) 2007-03-21 15:44 -
    Index: Rendering/UnitModels/UnitDrawer.cpp
    ===================================================================
    --- Rendering/UnitModels/UnitDrawer.cpp	(revision 3466)
    +++ Rendering/UnitModels/UnitDrawer.cpp	(working copy)
    @@ -134,6 +134,12 @@
     		delete *gbi;
     		gbi=ghostBuildings.erase(gbi);
     	}
    +	for(std::list<GhostBuilding*>::iterator gbi=ghostBuildingsS3O.begin();gbi!=ghostBuildingsS3O.end();){
    +		if((*gbi)->decal)
    +			(*gbi)->decal->gbOwner=0;
    +		delete *gbi;
    +		gbi=ghostBuildingsS3O.erase(gbi);
    +	}
     }
     
     void CUnitDrawer::Update(void)
    @@ -155,6 +161,7 @@
     	vector<CUnit*> drawFar;
     	vector<CUnit*> drawStat;
     	drawCloaked.clear();
    +	drawCloakedS3O.clear();
     	glFogfv(GL_FOG_COLOR,FogLand);
     
     	vector<CUnit*> drawIcon;
    @@ -201,11 +208,15 @@
     					if(sqDist>farLength){
     						drawFar.push_back(*usi);
     					} else {
    -						if((*usi)->isCloaked){
    -							drawCloaked.push_back(*usi);
    -						} else {
    -							if((*usi)->model->textureType){
    +						if((*usi)->model->textureType){ // s3o
    +							if((*usi)->isCloaked){
    +								drawCloakedS3O.push_back(*usi);
    +							} else {
     								QueS3ODraw(*usi,(*usi)->model->textureType);
    +							}
    +						} else { // 3do
    +							if((*usi)->isCloaked){
    +								drawCloaked.push_back(*usi);
     							} else {
     								(*usi)->Draw();
     							}
    @@ -224,7 +235,10 @@
     					float iconDistMult=iconHandler->GetDistance((*usi)->unitDef->iconType);
     					float realIconLength=iconLength*iconDistMult*iconDistMult;
     					if(sqDist<realIconLength){
    -						drawCloaked.push_back(*usi);
    +						if ((*usi)->model->textureType)
    +							drawCloakedS3O.push_back(*usi);
    +						else
    +							drawCloaked.push_back(*usi);
     						(*usi)->isIcon = false;
     					}
     				}
    @@ -399,27 +413,47 @@
     
     void CUnitDrawer::SetupForGhostDrawing ()
     {
    -	texturehandler->SetTATexture();
     	glPushAttrib (GL_TEXTURE_BIT | GL_ENABLE_BIT);
     	glEnable(GL_TEXTURE_2D);
    -	glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB_ARB,GL_MODULATE);
    -	glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_ARB,GL_TEXTURE);
    -	glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_ARB,GL_PREVIOUS);
    -	glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_ALPHA_ARB,GL_PREVIOUS_ARB);
    -	glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_ALPHA_ARB,GL_REPLACE);
    -	glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_ARB);
    -	glDepthMask(0);
    -	glDisable(GL_CULL_FACE);
    -	glEnable(GL_BLEND);
    -	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    +	
    +	texturehandler->SetTATexture();
    +	glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
    +	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
    +	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS);
    +	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB);
    +	glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
    +	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
     }
     
    +void CUnitDrawer::SetupForGhostDrawingS3O ()
    +{
    +	SetupBasicS3OTexture0();
    +	SetupBasicS3OTexture1();
    +	// use the alpha given by glColor for the outgoing alpha.
    +	// (might need to change this if we ever have transparent bits on units?)
    +	glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
    +	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PRIMARY_COLOR_ARB);
    +
    +	glActiveTextureARB(GL_TEXTURE0_ARB);
    +}
    +
     void CUnitDrawer::CleanUpGhostDrawing ()
     {
     	glPopAttrib ();
     	glDisable(GL_TEXTURE_2D);
     	glDepthMask(1);
     	glDisable(GL_ALPHA_TEST);
    +
    +	// clean up s3o drawing stuff
    +	// reset texture1 state
    +	CleanupBasicS3OTexture1();
    +
    +	// also reset the alpha generation
    +	glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_ALPHA_ARB, GL_MODULATE);
    +	glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
    +
    +	// reset texture0 state
    +	CleanupBasicS3OTexture0();
     }
     
     void CUnitDrawer::DrawCloakedUnits(void)
    @@ -433,7 +467,6 @@
     	glAlphaFunc(GL_GREATER,0.1f);
     	glEnable(GL_ALPHA_TEST);
     	glColor4f(1,1,1,0.3f);
    -	texturehandler->SetTATexture();
     	glDepthMask(0);
     
     	//ok these isnt really cloaked but the effect is the same
    @@ -442,7 +475,8 @@
     			glPushMatrix();
     			glTranslatef3(ti->second.pos);
     			glRotatef(ti->second.rotation*180/PI,0,1,0);
    -			modelParser->Load3DO(ti->second.unitdef->model.modelpath,1,ti->second.team)->DrawStatic();
    +			S3DOModel* model = modelParser->Load3DO(ti->second.unitdef->model.modelpath,1,ti->second.team);
    +			model->DrawStatic();
     			glPopMatrix();
     		}
     		if(ti->second.drawBorder){
    @@ -468,41 +502,68 @@
     		}
     	}
     
    -	for(vector<CUnit*>::iterator ui=drawCloaked.begin();ui!=drawCloaked.end();++ui){
    -		if((*ui)->losStatus[gu->myAllyTeam] & LOS_INLOS){
    -			glColor4f(1,1,1,0.4f);
    -			(*ui)->Draw();
    -		} else {
    -			if((*ui)->losStatus[gu->myAllyTeam] & LOS_CONTRADAR)
    -				glColor4f(0.9f,0.9f,0.9f,0.5f);
    -			else
    -				glColor4f(0.6f,0.6f,0.6f,0.4f);
    -			glPushMatrix();
    -			glTranslatef3((*ui)->pos);
    -			(*ui)->model->DrawStatic();
    -			glPopMatrix();
    +	std::vector<CUnit*> dC;
    +	std::list<GhostBuilding*> gB;
    +	
    +	for(int i=0;i<2;++i) {
    +		if(!i) { // 3dos
    +			dC=drawCloaked;
    +			gB=ghostBuildings;
    +		} else { // s3os
    +			dC=drawCloakedS3O;
    +			gB=ghostBuildingsS3O;
    +			SetupForGhostDrawingS3O();
    +			glColor4f(1,1,1,0.3f);
     		}
    -	}
    -	//go through the dead but still ghosted buildings
    -	glColor4f(0.6f,0.6f,0.6f,0.4f);
    -	for(std::list<GhostBuilding*>::iterator gbi=ghostBuildings.begin();gbi!=ghostBuildings.end();){
    -		if(loshandler->InLos((*gbi)->pos,gu->myAllyTeam)){
    -			if((*gbi)->decal)
    -				(*gbi)->decal->gbOwner=0;
    -			delete *gbi;
    -			gbi=ghostBuildings.erase(gbi);
    -		} else {
    -			if(camera->InView((*gbi)->pos,(*gbi)->model->radius*2)){
    +		// cloaked units and living ghosted buildings
    +		for(vector<CUnit*>::iterator ui=dC.begin();ui!=dC.end();++ui){
    +			if((*ui)->losStatus[gu->myAllyTeam] & LOS_INLOS){
    +				if(i) {
    +					SetBasicS3OTeamColour((*ui)->team);
    +					texturehandler->SetS3oTexture((*ui)->model->textureType);
    +				}
    +				(*ui)->Draw();
    +			} else {
    +				if((*ui)->losStatus[gu->myAllyTeam] & LOS_CONTRADAR)
    +					glColor4f(0.9f,0.9f,0.9f,0.5f);
    +				else
    +					glColor4f(0.6f,0.6f,0.6f,0.4f);
     				glPushMatrix();
    -				glTranslatef3((*gbi)->pos);
    -				glRotatef((*gbi)->facing*90,0,1,0);
    -				(*gbi)->model->DrawStatic();
    +				glTranslatef3((*ui)->pos);
    +				if(i) {
    +					SetBasicS3OTeamColour((*ui)->team);
    +					texturehandler->SetS3oTexture((*ui)->model->textureType);
    +				}
    +				(*ui)->model->DrawStatic();
     				glPopMatrix();
     			}
    -			++gbi;
     		}
    +
    +		//go through the dead but still ghosted buildings
    +		glColor4f(0.6f,0.6f,0.6f,0.4f);
    +		for(std::list<GhostBuilding*>::iterator gbi=gB.begin();gbi!=gB.end();){
    +			if(loshandler->InLos((*gbi)->pos,gu->myAllyTeam)){
    +				if((*gbi)->decal)
    +					(*gbi)->decal->gbOwner=0;
    +				delete *gbi;
    +				gbi=ghostBuildings.erase(gbi);
    +			} else {
    +				if(camera->InView((*gbi)->pos,(*gbi)->model->radius*2)){
    +					glPushMatrix();
    +					glTranslatef3((*gbi)->pos);
    +					glRotatef((*gbi)->facing*90,0,1,0);
    +					if(i) {
    +						SetBasicS3OTeamColour((*gbi)->team);
    +						texturehandler->SetS3oTexture((*gbi)->model->textureType);
    +					}
    +					(*gbi)->model->DrawStatic();
    +					glPopMatrix();
    +				}
    +				++gbi;
    +			}
    +		}
     	}
    -
    +	
     	// reset gl states
     	CleanUpGhostDrawing ();
     }
    @@ -1087,7 +1148,7 @@
     
     	if (model->textureType == 0){
     		/* 3DO */
    -		SetupForGhostDrawing();
    +		SetupForGhostDrawing();//(model, side);
     		glPushMatrix();
     		glTranslatef3(pos);
     		glRotatef(facing*90.0f,0,1,0);
    Index: Rendering/UnitModels/UnitDrawer.h
    ===================================================================
    --- Rendering/UnitModels/UnitDrawer.h	(revision 3430)
    +++ Rendering/UnitModels/UnitDrawer.h	(working copy)
    @@ -32,10 +32,12 @@
     	void CleanUpS3ODrawing(void);
     	void CleanUpGhostDrawing();
     	void SetupForGhostDrawing();
    +	void SetupForGhostDrawingS3O();//S3DOModel *model, int team);
     
     	inline void DrawFar(CUnit* unit);
     
     	std::vector<CUnit*> drawCloaked;
    +	std::vector<CUnit*> drawCloakedS3O;
     	CVertexArray* va;
     	bool advShading;
     
    @@ -77,8 +79,10 @@
     		float3 pos;
     		S3DOModel* model;
     		int facing;
    +		int team;
     	};
     	std::list<GhostBuilding*> ghostBuildings;	//these are buildings that where in LOS_PREVLOS when they died and havent been in los since then
    +	std::list<GhostBuilding*> ghostBuildingsS3O;
     
     	bool showHealthBars;
     
    Index: Sim/Units/UnitTypes/Building.cpp
    ===================================================================
    --- Sim/Units/UnitTypes/Building.cpp	(revision 3430)
    +++ Sim/Units/UnitTypes/Building.cpp	(working copy)
    @@ -9,6 +9,7 @@
     #include "Rendering/GroundDecalHandler.h"
     #include "Game/GameSetup.h"
     #include "Rendering/UnitModels/UnitDrawer.h"
    +#include "Rendering/UnitModels/3DModelParser.h"
     #include "Sim/Units/UnitDef.h"
     #include "Rendering/GroundDecalHandler.h"
     #include "Game/GameSetup.h"
    @@ -38,7 +39,11 @@
     			gb->model=model;
     			gb->decal=buildingDecal;
     			gb->facing=buildFacing;
    -			unitDrawer->ghostBuildings.push_back(gb);
    +			gb->team=team;
    +			if(model->textureType) //S3O
    +				unitDrawer->ghostBuildingsS3O.push_back(gb);
    +			else // 3DO
    +				unitDrawer->ghostBuildings.push_back(gb);
     			mygb=gb;
     		}
     	}
    
    diff file icon FixedS3OCloaking.diff (9,027 bytes) 2007-03-21 15:44 +

-Relationships
+Relationships

-Notes

~0000802

FLOZi (reporter)

I uploaded a patch which should finally fix this. :)

~0000835

Argh (reporter)

Cool!

~0000862

tvo (reporter)

Committed, r3543.

Thanks for your contribution!

~0000958

tvo (reporter)

This is bugged again in latest SVN, I'm taking a look.

~0000959

tvo (reporter)

r3798 is the last one that compiles fine and works fine wrt this
r3801 is the first next one that compiles fine, and it doesn't work anymore in it

~0000960

tvo (reporter)

fixed, r3820 (stupid typo of me)
+Notes

-Issue History
Date Modified Username Field Change
2006-08-29 22:31 Nemo New Issue
2007-03-21 15:44 FLOZi File Added: FixedS3OCloaking.diff
2007-03-21 15:46 FLOZi Note Added: 0000802
2007-03-21 15:46 tvo Summary cloaked s3o units lose their texture => [patch] cloaked s3o units lose their texture
2007-03-27 05:56 Argh Note Added: 0000835
2007-04-04 22:12 tvo Status new => assigned
2007-04-04 22:12 tvo Assigned To => tvo
2007-04-04 22:13 tvo Status assigned => resolved
2007-04-04 22:13 tvo Resolution open => fixed
2007-04-04 22:13 tvo Note Added: 0000862
2007-06-13 10:40 tvo Status resolved => feedback
2007-06-13 10:40 tvo Resolution fixed => reopened
2007-06-13 10:40 tvo Note Added: 0000958
2007-06-13 10:40 tvo Status feedback => confirmed
2007-06-13 12:34 tvo Note Added: 0000959
2007-06-13 12:48 tvo Status confirmed => resolved
2007-06-13 12:48 tvo Resolution reopened => fixed
2007-06-13 12:48 tvo Note Added: 0000960
+Issue History