FeatureTeamColourFix.diff (8,657 bytes)
2007-03-22 23:58
Index: Rendering/UnitModels/UnitDrawer.cpp
===================================================================
--- Rendering/UnitModels/UnitDrawer.cpp (revision 3483)
+++ Rendering/UnitModels/UnitDrawer.cpp (working copy)
@@ -1065,6 +1126,7 @@
/* S3O */
SetupForS3ODrawing();
texturehandler->SetS3oTexture(unit->model->textureType);
+ SetS3OTeamColour(unit->team);
unit->Draw();
CleanUpS3ODrawing();
}
Index: Sim/Misc/Feature.cpp
===================================================================
--- Sim/Misc/Feature.cpp (revision 3483)
+++ Sim/Misc/Feature.cpp (working copy)
@@ -11,6 +11,7 @@
#include "LogOutput.h"
#include "Sim/Units/Unit.h"
#include "Rendering/Env/BaseTreeDrawer.h"
+#include "Rendering/UnitModels/UnitDrawer.h"
#include "Sim/ModInfo.h"
#include "Sim/Projectiles/FireProjectile.h"
#include "Sim/Projectiles/SmokeProjectile.h"
@@ -29,6 +30,7 @@
CR_MEMBER(reclaimLeft),
CR_MEMBER(id),
CR_MEMBER(allyteam),
+ CR_MEMBER(team),
CR_MEMBER(tempNum),
CR_MEMBER(lastReclaim),
CR_MEMBER(def),
@@ -56,7 +58,8 @@
health(0),
id(0),
finalHeight(0),
- solidOnTop(0)
+ solidOnTop(0),
+ model(NULL)
{
immobile=true;
physicalState = OnGround;
@@ -77,12 +80,18 @@
}
}
-void CFeature::Initialize (const float3& pos,FeatureDef* def,short int heading,int facing, int allyteam,std::string fromUnit)
+void CFeature::Initialize (const float3& pos,FeatureDef* def,short int heading,int facing, int team, std::string fromUnit)
{
this->def=def;
createdFromUnit=fromUnit;
this->pos=pos;
- this->allyteam=allyteam;
+ if (team == -1) {
+ this->allyteam=team;
+ this->team=0;
+ } else {
+ this->allyteam=gs->AllyTeam(team);
+ this->team=team;
+ }
this->pos.CheckInBounds();
this->heading=heading;
health=def->maxHealth;
@@ -94,18 +103,14 @@
buildFacing=facing;
if(def->drawType==DRAWTYPE_3DO){
- if(def->model==0){
- if(!def->useCSOffset) {
- def->model=modelParser->Load3DO(def->modelname.c_str(),def->collisionSphereScale);
- } else {
- def->model=modelParser->Load3DO(def->modelname.c_str(),def->collisionSphereScale,1,
- def->collisionSphereOffset);
- }
- height=def->model->height;
- def->radius=def->model->radius;
- SetRadius(def->radius);
- }
- midPos=pos+def->model->relMidPos;
+ if(!def->useCSOffset)
+ model=modelParser->Load3DO(def->modelname.c_str(),def->collisionSphereScale,team);
+ else
+ model=modelParser->Load3DO(def->modelname.c_str(),def->collisionSphereScale,team, def->collisionSphereOffset);
+ height=model->height;
+ def->radius=model->radius;
+ SetRadius(def->radius);
+ midPos=pos+model->relMidPos;
} else if(def->drawType==DRAWTYPE_TREE){
midPos=pos+UpVector*def->radius;
height = 2*def->radius;
@@ -255,7 +260,7 @@
residualImpulse=impulse;
health-=damages[0];
if(health<=0 && def->destructable){
- featureHandler->CreateWreckage(pos,def->deathFeature,heading,buildFacing, 1,-1,false,"");
+ featureHandler->CreateWreckage(pos,def->deathFeature,heading,buildFacing, 1,team,false,"");
featureHandler->DeleteFeature(this);
blockHeightChanges=false;
@@ -376,7 +381,9 @@
{
glPushMatrix();
glMultMatrixf(transMatrix.m);
- def->model->DrawStatic();
+ if (model->textureType)
+ unitDrawer->SetS3OTeamColour(team);
+ model->DrawStatic();
glPopMatrix();
}
Index: Sim/Misc/Feature.h
===================================================================
--- Sim/Misc/Feature.h (revision 3483)
+++ Sim/Misc/Feature.h (working copy)
@@ -2,6 +2,7 @@
#define __FEATURE_H__
#include "Sim/Objects/SolidObject.h"
+#include "Rendering/UnitModels/3DModelParser.h"
#include "Matrix44f.h"
#include <vector>
#include <list>
@@ -36,6 +37,7 @@
void DependentDied(CObject *o);
CUnit* lastBuilder;
+ S3DOModel* model; //used by 3do obects
std::string createdFromUnit;
// This flag is used to stop a potential exploit involving tripping a unit back and forth
@@ -49,6 +51,7 @@
float reclaimLeft;
int id;
int allyteam;
+ int team;
int tempNum;
int lastReclaim;
Index: Sim/Misc/FeatureDef.h
===================================================================
--- Sim/Misc/FeatureDef.h (revision 3483)
+++ Sim/Misc/FeatureDef.h (working copy)
@@ -14,7 +14,7 @@
FeatureDef():
metal(0), energy(0), maxHealth(0), radius(0), mass(0),
- upright(false), drawType(0), model(NULL), modelType(0),
+ upright(false), drawType(0), modelType(0),
destructable(false), reclaimable(true), blocking(false),
burnable(false), floating(false), geoThermal(false),
xsize(0), ysize(0) {}
@@ -34,7 +34,6 @@
bool upright;
int drawType;
- S3DOModel* model; //used by 3do obects
std::string modelname; //used by 3do obects
int modelType; //used by tree etc
Index: Sim/Misc/FeatureHandler.cpp
===================================================================
--- Sim/Misc/FeatureHandler.cpp (revision 3483)
+++ Sim/Misc/FeatureHandler.cpp (working copy)
@@ -92,7 +92,7 @@
delete[] drawQuads;
}
-CFeature* CFeatureHandler::CreateWreckage(const float3& pos, const std::string& name, float rot, int facing, int iter, int allyteam, bool emitSmoke,std::string fromUnit)
+CFeature* CFeatureHandler::CreateWreckage(const float3& pos, const std::string& name, float rot, int facing, int iter, int team, bool emitSmoke,std::string fromUnit)
{
ASSERT_SYNCED_MODE;
if(name.empty())
@@ -103,11 +103,11 @@
return 0;
if(iter>1){
- return CreateWreckage(pos,fd->deathFeature,rot,facing, iter-1,allyteam,emitSmoke,"");
+ return CreateWreckage(pos,fd->deathFeature,rot,facing, iter-1,team,emitSmoke,"");
} else {
if(!fd->modelname.empty()){
CFeature* f=SAFE_NEW CFeature;
- f->Initialize (pos,fd,(short int)rot,facing,allyteam,fromUnit);
+ f->Initialize (pos,fd,(short int)rot,facing,team,fromUnit);
if(emitSmoke && f->blocking)
f->emitSmokeTime=300;
return f;
@@ -427,10 +427,10 @@
float sqDist=(f->pos-camera->pos).SqLength2D();
float farLength=f->sqRadius*unitDrawDist*unitDrawDist;
if(sqDist<farLength){
- if(!def->model->textureType || shadowHandler->inShadowPass){
+ if(!f->model->textureType || shadowHandler->inShadowPass){
f->DrawS3O ();
} else {
- unitDrawer->QueS3ODraw(f,def->model->textureType);
+ unitDrawer->QueS3ODraw(f,f->model->textureType);
}
} else {
if(farFeatures)
@@ -463,15 +463,15 @@
void CFeatureHandler::DrawFar(CFeature* feature,CVertexArray* va)
{
- float3 interPos=feature->pos+UpVector*feature->def->model->height*0.5f;
+ float3 interPos=feature->pos+UpVector*feature->model->height*0.5f;
int snurr=-feature->heading+GetHeadingFromVector(camera->pos.x-feature->pos.x,camera->pos.z-feature->pos.z)+(0xffff>>4);
if(snurr<0)
snurr+=0xffff;
if(snurr>0xffff)
snurr-=0xffff;
snurr=snurr>>13;
- float tx=(feature->def->model->farTextureNum%8)*(1.0f/8.0f)+snurr*(1.0f/64);
- float ty=(feature->def->model->farTextureNum/8)*(1.0f/64.0f);
+ float tx=(feature->model->farTextureNum%8)*(1.0f/8.0f)+snurr*(1.0f/64);
+ float ty=(feature->model->farTextureNum/8)*(1.0f/64.0f);
float offset=0;
va->AddVertexTN(interPos-(camera->up*feature->radius*1.4f-offset)+camera->right*feature->radius,tx,ty,unitDrawer->camNorm);
va->AddVertexTN(interPos+(camera->up*feature->radius*1.4f+offset)+camera->right*feature->radius,tx,ty+(1.0f/64.0f),unitDrawer->camNorm);
@@ -505,7 +505,6 @@
fd->energy=atof(wreckParser.SGetValueDef("0",name+"\\energy").c_str());
fd->maxHealth=atof(wreckParser.SGetValueDef("0",name+"\\damage").c_str());
fd->metal=atof(wreckParser.SGetValueDef("0",name+"\\metal").c_str());
- fd->model=0;
fd->modelname=wreckParser.SGetValueDef("",name+"\\object");
if(!fd->modelname.empty()){
fd->modelname=string("objects3d/")+fd->modelname;
Index: Sim/Units/Unit.cpp
===================================================================
--- Sim/Units/Unit.cpp (revision 3483)
+++ Sim/Units/Unit.cpp (working copy)
@@ -182,7 +182,7 @@
CUnit::~CUnit()
{
if(delayedWreckLevel>=0){
- featureHandler->CreateWreckage(pos,wreckName, heading, buildFacing, delayedWreckLevel,-1,true,unitDef->name);
+ featureHandler->CreateWreckage(pos,wreckName, heading, buildFacing, delayedWreckLevel,team,true,unitDef->name);
}
if(unitDef->isAirBase){
@@ -1272,7 +1272,7 @@
if(unitDef->isFeature){
UnBlock();
- CFeature* f=featureHandler->CreateWreckage(pos,wreckName, heading, buildFacing, 0,allyteam,false,"");
+ CFeature* f=featureHandler->CreateWreckage(pos,wreckName, heading, buildFacing, 0,team,false,"");
if(f){
f->blockHeightChanges=true;
}