2025-07-03 23:03 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000648Spring engineGeneralpublic2007-10-28 14:03
ReporterKDR_11k 
Assigned Toimbaczek 
PrioritynormalSeveritytrivialReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000648: [patch] missile and starburst texture 2 only applied to the first segment of the trail
DescriptionThis patch fixes the missile and starburst texture2 only applying to the first segment of the smoketrail (the segment that's still part of the projectile, not a CSmokeTrailProjectile). Now the entire trail uses the texture.
Additional InformationI've attempted to make CSmokeTrailProjectile deal with a null texture but I just couldn't get it to work, setting texture to &ph->smoketrailtex in the constructor still has the crash happen, supplying &ph->smoketrailtex as an argument instead works.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • patch file icon smoketrailtex.patch (10,415 bytes) 2007-09-28 21:50 -
    Index: Sim/Projectiles/PieceProjectile.cpp
    ===================================================================
    --- Sim/Projectiles/PieceProjectile.cpp	(revision 4474)
    +++ Sim/Projectiles/PieceProjectile.cpp	(working copy)
    @@ -162,7 +162,7 @@
     		if(flags & PP_Smoke){
     			float3 dir=speed;
     			dir.Normalize();
    -			CSmokeTrailProjectile* tp=SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldSmokeDir,owner,false,true,7,Smoke_Time,0.5f,drawTrail);
    +			CSmokeTrailProjectile* tp=SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldSmokeDir,owner,false,true,7,Smoke_Time,0.5f,drawTrail,0,&ph->smoketrailtex);
     			tp->creationTime+=8-((age)&7);
     		}
     		CProjectile::Collision();
    @@ -180,7 +180,7 @@
     	if(flags & PP_Smoke){
     		float3 dir=speed;
     		dir.Normalize();
    -		CSmokeTrailProjectile* tp=SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldSmokeDir,owner,false,true,7,Smoke_Time,0.5f,drawTrail);
    +		CSmokeTrailProjectile* tp=SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldSmokeDir,owner,false,true,7,Smoke_Time,0.5f,drawTrail,0,&ph->smoketrailtex);
     		tp->creationTime+=8-((age)&7);
     	}
     	CProjectile::Collision(unit);
    @@ -256,7 +256,7 @@
     		dir.Normalize();
     		if(curCallback)
     			curCallback->drawCallbacker=0;
    -		curCallback=SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldSmokeDir,owner,age==8,false,14,Smoke_Time,0.5f,drawTrail,this);
    +		curCallback=SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldSmokeDir,owner,age==8,false,14,Smoke_Time,0.5f,drawTrail,this,&ph->smoketrailtex);
     		useAirLos=curCallback->useAirLos;
     		oldSmoke=pos;
     		oldSmokeDir=dir;
    Index: Sim/Projectiles/Unsynced/SmokeTrailProjectile.cpp
    ===================================================================
    --- Sim/Projectiles/Unsynced/SmokeTrailProjectile.cpp	(revision 4474)
    +++ Sim/Projectiles/Unsynced/SmokeTrailProjectile.cpp	(working copy)
    @@ -13,7 +13,7 @@
     #include "SmokeTrailProjectile.h"
     #include "mmgr.h"
     
    -CR_BIND_DERIVED(CSmokeTrailProjectile, CProjectile, (float3(0,0,0),float3(0,0,0),float3(0,0,0),float3(0,0,0),NULL,0,0,0,0,0,0,NULL));
    +CR_BIND_DERIVED(CSmokeTrailProjectile, CProjectile, (float3(0,0,0),float3(0,0,0),float3(0,0,0),float3(0,0,0),NULL,0,0,0,0,0,0,NULL,NULL));
     
     CR_REG_METADATA(CSmokeTrailProjectile,(
     	CR_MEMBER(pos1),
    @@ -32,14 +32,15 @@
     	CR_MEMBER(drawSegmented),
     	CR_MEMBER(firstSegment),
     	CR_MEMBER(lastSegment),
    -	CR_MEMBER(drawCallbacker)
    +	CR_MEMBER(drawCallbacker),
    +	CR_MEMBER(texture)
     	));
     
     //////////////////////////////////////////////////////////////////////
     // Construction/Destruction
     //////////////////////////////////////////////////////////////////////
     
    -CSmokeTrailProjectile::CSmokeTrailProjectile(const float3& pos1,const float3& pos2,const float3& dir1,const float3& dir2, CUnit* owner,bool firstSegment,bool lastSegment,float size,float time,float color,bool drawTrail,CProjectile* drawCallback)
    +CSmokeTrailProjectile::CSmokeTrailProjectile(const float3& pos1,const float3& pos2,const float3& dir1,const float3& dir2, CUnit* owner,bool firstSegment,bool lastSegment,float size,float time,float color,bool drawTrail,CProjectile* drawCallback,AtlasedTexture* texture)
     : CProjectile((pos1+pos2)*0.5f,ZeroVector,owner, false),
     	pos1(pos1),
     	pos2(pos2),
    @@ -53,11 +54,18 @@
     	drawSegmented(false),
     	drawCallbacker(drawCallback),
     	firstSegment(firstSegment),
    -	lastSegment(lastSegment)
    +	lastSegment(lastSegment),
    +	texture(texture)
     {
     	checkCol=false;
     	castShadow=true;
     
    +	//if no custom texture is defined, use the default texture
    +	//Note that this will crash anyway (no idea why) so never have a null texture!
    +	if (texture==0) {
    +		texture = &ph->smoketrailtex;
    +	}
    +
     	if(!drawTrail){
     		float dist=pos1.distance(pos2);
     		dirpos1=pos1-dir1*dist*0.33f;
    @@ -138,22 +146,22 @@
     			col3[2]=(unsigned char) (color*alpha);
     			col3[3]=(unsigned char)alpha;
     
    -			float midtexx = ph->smoketrailtex.xstart + (ph->smoketrailtex.xend - ph->smoketrailtex.xstart)*0.5f;
    +			float midtexx = texture->xstart + (texture->xend - texture->xstart)*0.5f;
     
    -			va->AddVertexTC(pos1-odir1*size,ph->smoketrailtex.xstart,ph->smoketrailtex.ystart,col);
    -			va->AddVertexTC(pos1+odir1*size,ph->smoketrailtex.xstart,ph->smoketrailtex.yend,col);
    -			va->AddVertexTC(midpos+odir3*size3,midtexx,ph->smoketrailtex.yend,col3);
    -			va->AddVertexTC(midpos-odir3*size3,midtexx,ph->smoketrailtex.ystart,col3);
    +			va->AddVertexTC(pos1-odir1*size,texture->xstart,texture->ystart,col);
    +			va->AddVertexTC(pos1+odir1*size,texture->xstart,texture->yend,col);
    +			va->AddVertexTC(midpos+odir3*size3,midtexx,texture->yend,col3);
    +			va->AddVertexTC(midpos-odir3*size3,midtexx,texture->ystart,col3);
     
    -			va->AddVertexTC(midpos-odir3*size3,midtexx,ph->smoketrailtex.ystart,col3);
    -			va->AddVertexTC(midpos+odir3*size3,midtexx,ph->smoketrailtex.yend,col3);
    -			va->AddVertexTC(pos2+odir2*size2,ph->smoketrailtex.xend,ph->smoketrailtex.yend,col2);
    -			va->AddVertexTC(pos2-odir2*size2,ph->smoketrailtex.xend,ph->smoketrailtex.ystart,col2);
    +			va->AddVertexTC(midpos-odir3*size3,midtexx,texture->ystart,col3);
    +			va->AddVertexTC(midpos+odir3*size3,midtexx,texture->yend,col3);
    +			va->AddVertexTC(pos2+odir2*size2,texture->xend,texture->yend,col2);
    +			va->AddVertexTC(pos2-odir2*size2,texture->xend,texture->ystart,col2);
     		} else {
    -			va->AddVertexTC(pos1-odir1*size,ph->smoketrailtex.xstart,ph->smoketrailtex.ystart,col);
    -			va->AddVertexTC(pos1+odir1*size,ph->smoketrailtex.xstart,ph->smoketrailtex.yend,col);
    -			va->AddVertexTC(pos2+odir2*size2,ph->smoketrailtex.xend,ph->smoketrailtex.yend,col2);
    -			va->AddVertexTC(pos2-odir2*size2,ph->smoketrailtex.xend,ph->smoketrailtex.ystart,col2);
    +			va->AddVertexTC(pos1-odir1*size,texture->xstart,texture->ystart,col);
    +			va->AddVertexTC(pos1+odir1*size,texture->xstart,texture->yend,col);
    +			va->AddVertexTC(pos2+odir2*size2,texture->xend,texture->yend,col2);
    +			va->AddVertexTC(pos2-odir2*size2,texture->xend,texture->ystart,col2);
     		}
     	} else {	//draw as particles
     		unsigned char col[4];
    Index: Sim/Projectiles/Unsynced/SmokeTrailProjectile.h
    ===================================================================
    --- Sim/Projectiles/Unsynced/SmokeTrailProjectile.h	(revision 4474)
    +++ Sim/Projectiles/Unsynced/SmokeTrailProjectile.h	(working copy)
    @@ -12,7 +12,7 @@
     public:
     	void Update();
     	void Draw();
    -	CSmokeTrailProjectile(const float3& pos1,const float3& pos2,const float3& dir1,const float3& dir2, CUnit* owner,bool firstSegment,bool lastSegment,float size=1,float time=80,float color=0.7f,bool drawTrail=true,CProjectile* drawCallback=0);
    +	CSmokeTrailProjectile(const float3& pos1,const float3& pos2,const float3& dir1,const float3& dir2, CUnit* owner,bool firstSegment,bool lastSegment,float size=1,float time=80,float color=0.7f,bool drawTrail=true,CProjectile* drawCallback=0,AtlasedTexture* texture=0);
     	virtual ~CSmokeTrailProjectile();
     
     	float3 pos1;
    @@ -32,6 +32,7 @@
     	bool drawSegmented;
     	bool firstSegment,lastSegment;
     	CProjectile* drawCallbacker;
    +	AtlasedTexture* texture;
     };
     
     #endif /* SMOKETRAILPROJECTILE_H */
    Index: Sim/Projectiles/WeaponProjectiles/MissileProjectile.cpp
    ===================================================================
    --- Sim/Projectiles/WeaponProjectiles/MissileProjectile.cpp	(revision 4474)
    +++ Sim/Projectiles/WeaponProjectiles/MissileProjectile.cpp	(working copy)
    @@ -130,7 +130,7 @@
     	if(h>pos.y && fabs(speed.y)>0.001f)
     		pos-=speed*std::min((float)1,float((h-pos.y)/fabs(speed.y)));
     	if (weaponDef->visuals.smokeTrail)
    -		SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldDir,owner,false,true,7,Smoke_Time,0.6f,drawTrail);
    +		SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldDir,owner,false,true,7,Smoke_Time,0.6f,drawTrail,0,weaponDef->visuals.texture2);
     	//helper->Explosion(pos,damages,areaOfEffect,owner);
     	CWeaponProjectile::Collision();
     	oldSmoke=pos;
    @@ -139,7 +139,7 @@
     void CMissileProjectile::Collision(CUnit *unit)
     {
     	if (weaponDef->visuals.smokeTrail)
    -		SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldDir,owner,false,true,7,Smoke_Time,0.6f,drawTrail);
    +		SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldDir,owner,false,true,7,Smoke_Time,0.6f,drawTrail,0,weaponDef->visuals.texture2);
     //	unit->DoDamage(damages,owner);
     	//helper->Explosion(pos,damages,areaOfEffect,owner);
     
    @@ -228,7 +228,7 @@
     	age++;
     	numParts++;
     	if(weaponDef->visuals.smokeTrail && !(age&7)){
    -		CSmokeTrailProjectile* tp=SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldDir,owner,age==8,false,7,Smoke_Time,0.6f,drawTrail);
    +		CSmokeTrailProjectile* tp=SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldDir,owner,age==8,false,7,Smoke_Time,0.6f,drawTrail,0,weaponDef->visuals.texture2);
     		oldSmoke=pos;
     		oldDir=dir;
     		numParts=0;
    Index: Sim/Projectiles/WeaponProjectiles/StarburstProjectile.cpp
    ===================================================================
    --- Sim/Projectiles/WeaponProjectiles/StarburstProjectile.cpp	(revision 4474)
    +++ Sim/Projectiles/WeaponProjectiles/StarburstProjectile.cpp	(working copy)
    @@ -120,7 +120,7 @@
     	if(h>pos.y)
     		pos+=speed*(h-pos.y)/speed.y;
     	if (weaponDef->visuals.smokeTrail)
    -		SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldSmokeDir,owner,false,true,7,Smoke_Time,0.7f,drawTrail);
    +		SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldSmokeDir,owner,false,true,7,Smoke_Time,0.7f,drawTrail,0,weaponDef->visuals.texture2);
     	oldSmokeDir=dir;
     //	helper->Explosion(pos,damages,areaOfEffect,owner);
     	CWeaponProjectile::Collision();
    @@ -130,7 +130,7 @@
     void CStarburstProjectile::Collision(CUnit *unit)
     {
     	if (weaponDef->visuals.smokeTrail)
    -		SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldSmokeDir,owner,false,true,7,Smoke_Time,0.7f,drawTrail);
    +		SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldSmokeDir,owner,false,true,7,Smoke_Time,0.7f,drawTrail,0,weaponDef->visuals.texture2);
     	oldSmokeDir=dir;
     //	unit->DoDamage(damages,owner);
     //	helper->Explosion(pos,damages,areaOfEffect,owner);
    @@ -219,7 +219,7 @@
     	if(weaponDef->visuals.smokeTrail && !(age&7)){
     		if(curCallback)
     			curCallback->drawCallbacker=0;
    -		curCallback=SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldSmokeDir,owner,age==8,false,7,Smoke_Time,0.7f,drawTrail,this);
    +		curCallback=SAFE_NEW CSmokeTrailProjectile(pos,oldSmoke,dir,oldSmokeDir,owner,age==8,false,7,Smoke_Time,0.7f,drawTrail,this,weaponDef->visuals.texture2);
     		oldSmoke=pos;
     		oldSmokeDir=dir;
     		numParts=0;
    
    patch file icon smoketrailtex.patch (10,415 bytes) 2007-09-28 21:50 +

-Relationships
+Relationships

-Notes

~0001366

KDR_11k (reporter)

Is the &ph->smoketrailtex issue a dealbreaker or was this put on an IDIL list?

~0001367

imbaczek (reporter)

I wanted to apply that, but forgot. Will see about that soonish.

~0001370

imbaczek (reporter)

committed in r4644, thanks.
+Notes

-Issue History
Date Modified Username Field Change
2007-09-28 21:50 KDR_11k New Issue
2007-09-28 21:50 KDR_11k File Added: smoketrailtex.patch
2007-10-27 15:10 KDR_11k Note Added: 0001366
2007-10-28 07:11 imbaczek Note Added: 0001367
2007-10-28 13:23 tvo Status new => assigned
2007-10-28 13:23 tvo Assigned To => imbaczek
2007-10-28 14:03 imbaczek Status assigned => resolved
2007-10-28 14:03 imbaczek Resolution open => fixed
2007-10-28 14:03 imbaczek Note Added: 0001370
+Issue History