Fixed several cppcheck messages
git-svn-id: https://svn.code.sf.net/p/extremetuxracer/code/trunk@437 0420edf4-82e4-42fc-9478-35b55e6d67a3master
parent
bbadb5adb2
commit
4c37a66b4e
|
@ -140,7 +140,6 @@ wstring CFont::UnicodeStr (const char *s) {
|
||||||
|
|
||||||
int CFont::LoadFont (const string& name, const char *path) {
|
int CFont::LoadFont (const string& name, const char *path) {
|
||||||
fonts.push_back(new FTGLPixmapFont (path));
|
fonts.push_back(new FTGLPixmapFont (path));
|
||||||
// fonts.push_back(new FTGLTextureFont (path));
|
|
||||||
if (fonts.back()->Error()) {
|
if (fonts.back()->Error()) {
|
||||||
Message ("Failed to open font");
|
Message ("Failed to open font");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -188,7 +188,7 @@ void TCheckbox::Draw () const {
|
||||||
Tex.Draw (CHECKBOX, position.x + width - 32, position.y, 1.0);
|
Tex.Draw (CHECKBOX, position.x + width - 32, position.y, 1.0);
|
||||||
if (checked)
|
if (checked)
|
||||||
Tex.Draw (CHECKMARK_SMALL, position.x + width - 32, position.y, 1.0);
|
Tex.Draw (CHECKMARK_SMALL, position.x + width - 32, position.y, 1.0);
|
||||||
if (focus == focus)
|
if (focus)
|
||||||
FT.SetColor (colDYell);
|
FT.SetColor (colDYell);
|
||||||
else
|
else
|
||||||
FT.SetColor (colWhite);
|
FT.SetColor (colWhite);
|
||||||
|
|
|
@ -146,7 +146,6 @@ void draw_partial_tri_fan (double fraction) {
|
||||||
|
|
||||||
if (trifan) {
|
if (trifan) {
|
||||||
glEnd();
|
glEnd();
|
||||||
trifan = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -442,13 +442,7 @@ TQuaternion MakeRotationQuaternion (const TVector3& s, const TVector3& t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TQuaternion InterpolateQuaternions (const TQuaternion& q, TQuaternion r, double t) {
|
TQuaternion InterpolateQuaternions (const TQuaternion& q, TQuaternion r, double t) {
|
||||||
TQuaternion res;
|
double cosphi = q.x * r.x + q.y * r.y + q.z * r.z + q.w * r.w;
|
||||||
double cosphi;
|
|
||||||
double sinphi;
|
|
||||||
double phi;
|
|
||||||
double scale0, scale1;
|
|
||||||
|
|
||||||
cosphi = q.x * r.x + q.y * r.y + q.z * r.z + q.w * r.w;
|
|
||||||
|
|
||||||
if (cosphi < 0.0) {
|
if (cosphi < 0.0) {
|
||||||
cosphi = -cosphi;
|
cosphi = -cosphi;
|
||||||
|
@ -458,9 +452,10 @@ TQuaternion InterpolateQuaternions (const TQuaternion& q, TQuaternion r, double
|
||||||
r.w = -r.w;
|
r.w = -r.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double scale0, scale1;
|
||||||
if (1.0 - cosphi > EPS) {
|
if (1.0 - cosphi > EPS) {
|
||||||
phi = acos (cosphi);
|
double phi = acos (cosphi);
|
||||||
sinphi = sin (phi);
|
double sinphi = sin (phi);
|
||||||
scale0 = sin (phi * (1.0 - t)) / sinphi;
|
scale0 = sin (phi * (1.0 - t)) / sinphi;
|
||||||
scale1 = sin (phi * t) / sinphi;
|
scale1 = sin (phi * t) / sinphi;
|
||||||
} else {
|
} else {
|
||||||
|
@ -468,6 +463,7 @@ TQuaternion InterpolateQuaternions (const TQuaternion& q, TQuaternion r, double
|
||||||
scale1 = t;
|
scale1 = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TQuaternion res;
|
||||||
res.x = scale0 * q.x + scale1 * r.x;
|
res.x = scale0 * q.x + scale1 * r.x;
|
||||||
res.y = scale0 * q.y + scale1 * r.y;
|
res.y = scale0 * q.y + scale1 * r.y;
|
||||||
res.z = scale0 * q.z + scale1 * r.z;
|
res.z = scale0 * q.z + scale1 * r.z;
|
||||||
|
@ -561,7 +557,7 @@ void backsb (double *matrix, int n, double *soln) {
|
||||||
|
|
||||||
bool IntersectPolygon (const TPolygon& p, TVector3 *v) {
|
bool IntersectPolygon (const TPolygon& p, TVector3 *v) {
|
||||||
TRay ray;
|
TRay ray;
|
||||||
double d, s, nuDotProd, wec;
|
double d, s, nuDotProd;
|
||||||
double distsq;
|
double distsq;
|
||||||
|
|
||||||
TVector3 nml = MakeNormal (p, v);
|
TVector3 nml = MakeNormal (p, v);
|
||||||
|
@ -608,7 +604,7 @@ bool IntersectPolygon (const TPolygon& p, TVector3 *v) {
|
||||||
TVector3 edge_nml = CrossProduct (nml,
|
TVector3 edge_nml = CrossProduct (nml,
|
||||||
SubtractVectors (v[p.vertices[ (i+1) % p.num_vertices ]], v[p.vertices[i]]));
|
SubtractVectors (v[p.vertices[ (i+1) % p.num_vertices ]], v[p.vertices[i]]));
|
||||||
|
|
||||||
wec = DotProduct (SubtractVectors (pt, v[p.vertices[i]]), edge_nml);
|
double wec = DotProduct (SubtractVectors (pt, v[p.vertices[i]]), edge_nml);
|
||||||
if (wec < 0) return false;
|
if (wec < 0) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -396,15 +396,9 @@ double adjust_particle_count (double particles) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void generate_particles (const CControl *ctrl, double dtime, const TVector3& pos, double speed) {
|
void generate_particles (const CControl *ctrl, double dtime, const TVector3& pos, double speed) {
|
||||||
double brake_particles;
|
|
||||||
double turn_particles;
|
|
||||||
double roll_particles;
|
|
||||||
double surf_y;
|
|
||||||
double left_particles, right_particles;
|
|
||||||
TMatrix rot_mat;
|
|
||||||
TTerrType *TerrList = &Course.TerrList[0];
|
TTerrType *TerrList = &Course.TerrList[0];
|
||||||
|
|
||||||
surf_y = Course.FindYCoord (pos.x, pos.z);
|
double surf_y = Course.FindYCoord (pos.x, pos.z);
|
||||||
|
|
||||||
int id = Course.GetTerrainIdx (pos.x, pos.z, 0.5);
|
int id = Course.GetTerrainIdx (pos.x, pos.z, 0.5);
|
||||||
if (id >= 0 && TerrList[id].particles && pos.y < surf_y) {
|
if (id >= 0 && TerrList[id].particles && pos.y < surf_y) {
|
||||||
|
@ -420,27 +414,28 @@ void generate_particles (const CControl *ctrl, double dtime, const TVector3& pos
|
||||||
|
|
||||||
right_part_pt.y = left_part_pt.y = surf_y;
|
right_part_pt.y = left_part_pt.y = surf_y;
|
||||||
|
|
||||||
brake_particles = dtime *
|
double brake_particles = dtime *
|
||||||
BRAKE_PARTICLES * (ctrl->is_braking ? 1.0 : 0.0)
|
BRAKE_PARTICLES * (ctrl->is_braking ? 1.0 : 0.0)
|
||||||
* min (speed / PARTICLE_SPEED_FACTOR, 1.0);
|
* min (speed / PARTICLE_SPEED_FACTOR, 1.0);
|
||||||
turn_particles = dtime * MAX_TURN_PARTICLES
|
double turn_particles = dtime * MAX_TURN_PARTICLES
|
||||||
* min (speed / PARTICLE_SPEED_FACTOR, 1.0);
|
* min (speed / PARTICLE_SPEED_FACTOR, 1.0);
|
||||||
roll_particles = dtime * MAX_ROLL_PARTICLES
|
double roll_particles = dtime * MAX_ROLL_PARTICLES
|
||||||
* min (speed / PARTICLE_SPEED_FACTOR, 1.0);
|
* min (speed / PARTICLE_SPEED_FACTOR, 1.0);
|
||||||
|
|
||||||
left_particles = turn_particles *
|
double left_particles = turn_particles *
|
||||||
fabs (min(ctrl->turn_fact, 0.)) +
|
fabs (min(ctrl->turn_fact, 0.)) +
|
||||||
brake_particles +
|
brake_particles +
|
||||||
roll_particles * fabs (min(ctrl->turn_animation, 0.));
|
roll_particles * fabs (min(ctrl->turn_animation, 0.));
|
||||||
|
|
||||||
right_particles = turn_particles *
|
double right_particles = turn_particles *
|
||||||
fabs (max(ctrl->turn_fact, 0.)) +
|
fabs (max(ctrl->turn_fact, 0.)) +
|
||||||
brake_particles +
|
brake_particles +
|
||||||
roll_particles * fabs (max(ctrl->turn_animation, 0.));
|
roll_particles * fabs (max(ctrl->turn_animation, 0.));
|
||||||
|
|
||||||
left_particles = adjust_particle_count (left_particles);
|
left_particles = adjust_particle_count (left_particles);
|
||||||
right_particles = adjust_particle_count (right_particles);
|
right_particles = adjust_particle_count (right_particles);
|
||||||
|
|
||||||
|
TMatrix rot_mat;
|
||||||
RotateAboutVectorMatrix(
|
RotateAboutVectorMatrix(
|
||||||
rot_mat, ctrl->cdirection,
|
rot_mat, ctrl->cdirection,
|
||||||
MAX (-MAX_PARTICLE_ANGLE,
|
MAX (-MAX_PARTICLE_ANGLE,
|
||||||
|
@ -567,7 +562,6 @@ void CFlakes::MakeSnowFlake (size_t ar, size_t i) {
|
||||||
areas[ar].flakes[i].pt.y = -XRandom (areas[ar].top, areas[ar].bottom);
|
areas[ar].flakes[i].pt.y = -XRandom (areas[ar].top, areas[ar].bottom);
|
||||||
areas[ar].flakes[i].pt.z = areas[ar].back - FRandom () * (areas[ar].back - areas[ar].front);
|
areas[ar].flakes[i].pt.z = areas[ar].back - FRandom () * (areas[ar].back - areas[ar].front);
|
||||||
|
|
||||||
float p_dist = FRandom ();
|
|
||||||
areas[ar].flakes[i].size = XRandom (areas[ar].minSize, areas[ar].maxSize);
|
areas[ar].flakes[i].size = XRandom (areas[ar].minSize, areas[ar].maxSize);
|
||||||
areas[ar].flakes[i].vel.x = 0;
|
areas[ar].flakes[i].vel.x = 0;
|
||||||
areas[ar].flakes[i].vel.z = 0;
|
areas[ar].flakes[i].vel.z = 0;
|
||||||
|
@ -1037,9 +1031,8 @@ void CWind::CalcDestAngle () {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWind::Update (float timestep) {
|
void CWind::Update (float timestep) {
|
||||||
float xx, zz;
|
|
||||||
|
|
||||||
if (!windy) return;
|
if (!windy) return;
|
||||||
|
|
||||||
// the wind needn't be updated in each frame
|
// the wind needn't be updated in each frame
|
||||||
CurrTime = CurrTime + timestep;
|
CurrTime = CurrTime + timestep;
|
||||||
if (CurrTime > UPDATE_TIME) {
|
if (CurrTime > UPDATE_TIME) {
|
||||||
|
@ -1070,8 +1063,8 @@ void CWind::Update (float timestep) {
|
||||||
if (WAngle > params.maxAngle) WAngle = params.maxAngle;
|
if (WAngle > params.maxAngle) WAngle = params.maxAngle;
|
||||||
if (WAngle < params.minAngle) WAngle = params.minAngle;
|
if (WAngle < params.minAngle) WAngle = params.minAngle;
|
||||||
|
|
||||||
xx = sin (WAngle * 3.14159 / 180);
|
float xx = sin (WAngle * 3.14159 / 180);
|
||||||
zz = sqrt (1 - xx * xx);
|
float zz = sqrt (1 - xx * xx);
|
||||||
if ((WAngle > 90 && WAngle < 270) || (WAngle > 450 && WAngle < 630)) {
|
if ((WAngle > 90 && WAngle < 270) || (WAngle > 450 && WAngle < 630)) {
|
||||||
zz = -zz;
|
zz = -zz;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,6 @@ bool CControl::CheckTreeCollisions (const TVector3& pos, TVector3 *tree_loc, dou
|
||||||
|
|
||||||
CCharShape *shape = Char.GetShape (g_game.char_id);
|
CCharShape *shape = Char.GetShape (g_game.char_id);
|
||||||
double diam = 0.0;
|
double diam = 0.0;
|
||||||
double height;
|
|
||||||
TVector3 loc(0, 0, 0);
|
TVector3 loc(0, 0, 0);
|
||||||
bool hit = false;
|
bool hit = false;
|
||||||
TMatrix mat;
|
TMatrix mat;
|
||||||
|
@ -129,7 +128,7 @@ bool CControl::CheckTreeCollisions (const TVector3& pos, TVector3 *tree_loc, dou
|
||||||
|
|
||||||
for (size_t i=0; i<num_trees; i++) {
|
for (size_t i=0; i<num_trees; i++) {
|
||||||
diam = trees[i].diam;
|
diam = trees[i].diam;
|
||||||
height = trees[i].height;
|
double height = trees[i].height;
|
||||||
loc = trees[i].pt;
|
loc = trees[i].pt;
|
||||||
TVector3 distvec(loc.x - pos.x, 0.0, loc.z - pos.z);
|
TVector3 distvec(loc.x - pos.x, 0.0, loc.z - pos.z);
|
||||||
|
|
||||||
|
@ -173,7 +172,6 @@ bool CControl::CheckTreeCollisions (const TVector3& pos, TVector3 *tree_loc, dou
|
||||||
void CControl::AdjustTreeCollision (const TVector3& pos, TVector3 *vel) {
|
void CControl::AdjustTreeCollision (const TVector3& pos, TVector3 *vel) {
|
||||||
TVector3 treeLoc;
|
TVector3 treeLoc;
|
||||||
double tree_diam;
|
double tree_diam;
|
||||||
double factor;
|
|
||||||
|
|
||||||
if (CheckTreeCollisions (pos, &treeLoc, &tree_diam)) {
|
if (CheckTreeCollisions (pos, &treeLoc, &tree_diam)) {
|
||||||
TVector3 treeNml(
|
TVector3 treeNml(
|
||||||
|
@ -187,6 +185,7 @@ void CControl::AdjustTreeCollision (const TVector3& pos, TVector3 *vel) {
|
||||||
|
|
||||||
double costheta = DotProduct (*vel, treeNml);
|
double costheta = DotProduct (*vel, treeNml);
|
||||||
if (costheta < 0) {
|
if (costheta < 0) {
|
||||||
|
double factor;
|
||||||
if (cairborne) factor = 0.5;
|
if (cairborne) factor = 0.5;
|
||||||
else factor = 1.5;
|
else factor = 1.5;
|
||||||
*vel = AddVectors (
|
*vel = AddVectors (
|
||||||
|
@ -357,22 +356,19 @@ TVector3 CControl::CalcJumpForce () {
|
||||||
}
|
}
|
||||||
|
|
||||||
TVector3 CControl::CalcFrictionForce (double speed, const TVector3& nmlforce) {
|
TVector3 CControl::CalcFrictionForce (double speed, const TVector3& nmlforce) {
|
||||||
double fric_f_mag;
|
|
||||||
TMatrix fric_rot_mat;
|
|
||||||
double steer_angle;
|
|
||||||
|
|
||||||
if ((cairborne == false && speed > minFrictspeed) || g_game.finish) {
|
if ((cairborne == false && speed > minFrictspeed) || g_game.finish) {
|
||||||
TVector3 tmp_nml_f = nmlforce;
|
TVector3 tmp_nml_f = nmlforce;
|
||||||
fric_f_mag = NormVector (tmp_nml_f) * ff.frict_coeff;
|
double fric_f_mag = NormVector (tmp_nml_f) * ff.frict_coeff;
|
||||||
fric_f_mag = MIN (MAX_FRICT_FORCE, fric_f_mag);
|
fric_f_mag = MIN (MAX_FRICT_FORCE, fric_f_mag);
|
||||||
TVector3 frictforce = ScaleVector (fric_f_mag, ff.frictdir);
|
TVector3 frictforce = ScaleVector (fric_f_mag, ff.frictdir);
|
||||||
|
|
||||||
steer_angle = turn_fact * MAX_TURN_ANGLE;
|
double steer_angle = turn_fact * MAX_TURN_ANGLE;
|
||||||
|
|
||||||
if (fabs (fric_f_mag * sin (steer_angle * M_PI / 180)) > MAX_TURN_PERP) {
|
if (fabs (fric_f_mag * sin (steer_angle * M_PI / 180)) > MAX_TURN_PERP) {
|
||||||
steer_angle = RADIANS_TO_ANGLES (asin (MAX_TURN_PERP / fric_f_mag)) *
|
steer_angle = RADIANS_TO_ANGLES (asin (MAX_TURN_PERP / fric_f_mag)) *
|
||||||
turn_fact / fabs (turn_fact);
|
turn_fact / fabs (turn_fact);
|
||||||
}
|
}
|
||||||
|
TMatrix fric_rot_mat;
|
||||||
RotateAboutVectorMatrix (fric_rot_mat, ff.surfnml, steer_angle);
|
RotateAboutVectorMatrix (fric_rot_mat, ff.surfnml, steer_angle);
|
||||||
frictforce = TransformVector (fric_rot_mat, frictforce);
|
frictforce = TransformVector (fric_rot_mat, frictforce);
|
||||||
return ScaleVector (1.0 + MAX_TURN_PEN, frictforce);
|
return ScaleVector (1.0 + MAX_TURN_PEN, frictforce);
|
||||||
|
@ -488,8 +484,6 @@ double CControl::AdjustTimeStep (double h, TVector3 vel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CControl::SolveOdeSystem (double timestep) {
|
void CControl::SolveOdeSystem (double timestep) {
|
||||||
bool failed = false;
|
|
||||||
double speed;
|
|
||||||
double pos_err[3], vel_err[3], tot_pos_err, tot_vel_err;
|
double pos_err[3], vel_err[3], tot_pos_err, tot_vel_err;
|
||||||
double err=0, tol=0;
|
double err=0, tol=0;
|
||||||
|
|
||||||
|
@ -525,7 +519,7 @@ void CControl::SolveOdeSystem (double timestep) {
|
||||||
TVector3 saved_vel = new_vel;
|
TVector3 saved_vel = new_vel;
|
||||||
TVector3 saved_f = new_f;
|
TVector3 saved_f = new_f;
|
||||||
|
|
||||||
failed = false;
|
bool failed = false;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
solver.InitOdeData (x, new_pos.x, h);
|
solver.InitOdeData (x, new_pos.x, h);
|
||||||
solver.InitOdeData (y, new_pos.y, h);
|
solver.InitOdeData (y, new_pos.y, h);
|
||||||
|
@ -613,7 +607,7 @@ void CControl::SolveOdeSystem (double timestep) {
|
||||||
|
|
||||||
t = t + h;
|
t = t + h;
|
||||||
TVector3 tmp_vel = new_vel;
|
TVector3 tmp_vel = new_vel;
|
||||||
speed = NormVector (tmp_vel);
|
double speed = NormVector (tmp_vel);
|
||||||
if (param.perf_level > 2) generate_particles (this, h, new_pos, speed);
|
if (param.perf_level > 2) generate_particles (this, h, new_pos, speed);
|
||||||
|
|
||||||
new_f = CalcNetForce (new_pos, new_vel);
|
new_f = CalcNetForce (new_pos, new_vel);
|
||||||
|
|
|
@ -1147,15 +1147,8 @@ void ResetQuadtree() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_root_level (int nx, int nz) {
|
static int get_root_level (int nx, int nz) {
|
||||||
int xlev, zlev;
|
int xlev = (int) (log(static_cast<double>(nx)) / log (2.0));
|
||||||
|
int zlev = (int) (log(static_cast<double>(nz)) / log (2.0));
|
||||||
xlev = (int) (log(static_cast<double>(nx)) / log (2.0));
|
|
||||||
zlev = (int) (log(static_cast<double>(nz)) / log (2.0));
|
|
||||||
if ((nx >> xlev) << xlev == nx) {
|
|
||||||
} else nx += 1;
|
|
||||||
|
|
||||||
if ((nz >> zlev) << zlev == nz) {
|
|
||||||
} else nz += 1;
|
|
||||||
|
|
||||||
return max (xlev, zlev);
|
return max (xlev, zlev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,13 +235,10 @@ int SlideVolume (CControl *ctrl, double speed, int typ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayTerrainSound (CControl *ctrl, bool airborne) {
|
void PlayTerrainSound (CControl *ctrl, bool airborne) {
|
||||||
int terridx = -1;
|
|
||||||
TTerrType *TerrList = &Course.TerrList[0];
|
|
||||||
|
|
||||||
if (airborne == false) {
|
if (airborne == false) {
|
||||||
terridx = Course.GetTerrainIdx (ctrl->cpos.x, ctrl->cpos.z, 0.5);
|
int terridx = Course.GetTerrainIdx (ctrl->cpos.x, ctrl->cpos.z, 0.5);
|
||||||
if (terridx >= 0) {
|
if (terridx >= 0) {
|
||||||
newsound = (int)Sound.GetSoundIdx (TerrList[terridx].sound);
|
newsound = (int)Sound.GetSoundIdx (Course.TerrList[terridx].sound);
|
||||||
} else newsound = -1;
|
} else newsound = -1;
|
||||||
} else newsound = -1;
|
} else newsound = -1;
|
||||||
if ((newsound != lastsound) && (lastsound >= 0)) Sound.Halt (lastsound);
|
if ((newsound != lastsound) && (lastsound >= 0)) Sound.Halt (lastsound);
|
||||||
|
|
|
@ -155,6 +155,7 @@ int CScore::CalcRaceResult () {
|
||||||
g_game.score = (int)(herringpt + timept);
|
g_game.score = (int)(herringpt + timept);
|
||||||
if (g_game.score < 0) g_game.score = 0;
|
if (g_game.score < 0) g_game.score = 0;
|
||||||
|
|
||||||
|
TScore TempScore;
|
||||||
TempScore.points = g_game.score;
|
TempScore.points = g_game.score;
|
||||||
TempScore.herrings = g_game.herring;
|
TempScore.herrings = g_game.herring;
|
||||||
TempScore.time = g_game.time;
|
TempScore.time = g_game.time;
|
||||||
|
|
|
@ -39,7 +39,6 @@ struct TScoreList {
|
||||||
class CScore : public State {
|
class CScore : public State {
|
||||||
private:
|
private:
|
||||||
vector<TScoreList> Scorelist;
|
vector<TScoreList> Scorelist;
|
||||||
TScore TempScore;
|
|
||||||
|
|
||||||
void Enter();
|
void Enter();
|
||||||
void Loop(double time_step);
|
void Loop(double time_step);
|
||||||
|
|
|
@ -440,16 +440,16 @@ bool CSPList::Load (const string &filepath) {
|
||||||
std::ifstream tempfile(filepath.c_str());
|
std::ifstream tempfile(filepath.c_str());
|
||||||
string line;
|
string line;
|
||||||
|
|
||||||
bool backflag = false;
|
|
||||||
if (!tempfile) {
|
if (!tempfile) {
|
||||||
Message ("CSPList::Load - unable to open " + filepath, "");
|
Message ("CSPList::Load - unable to open " + filepath, "");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
bool backflag = false;
|
||||||
while (getline(tempfile, line)) {
|
while (getline(tempfile, line)) {
|
||||||
|
|
||||||
// delete new line char if in string
|
// delete new line char if in string
|
||||||
size_t npos = line.rfind ('\n');
|
size_t npos = line.rfind ('\n');
|
||||||
if (npos >= 0) SDeleteN (line, npos, 1);
|
if (npos != string::npos) SDeleteN (line, npos, 1);
|
||||||
|
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
if (line.empty()) valid = false; // empty line
|
if (line.empty()) valid = false; // empty line
|
||||||
|
|
|
@ -543,7 +543,7 @@ void CTexture::FreeTextureList () {
|
||||||
}
|
}
|
||||||
|
|
||||||
TTexture* CTexture::GetTexture (size_t idx) const {
|
TTexture* CTexture::GetTexture (size_t idx) const {
|
||||||
if (idx >= CommonTex.size() || idx < 0) return NULL;
|
if (idx >= CommonTex.size()) return NULL;
|
||||||
return CommonTex[idx];
|
return CommonTex[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +552,7 @@ TTexture* CTexture::GetTexture (const string& name) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTexture::BindTex (size_t idx) {
|
bool CTexture::BindTex (size_t idx) {
|
||||||
if (idx < 0 || idx >= CommonTex.size()) return false;
|
if (idx >= CommonTex.size()) return false;
|
||||||
CommonTex[idx]->Bind();
|
CommonTex[idx]->Bind();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,6 @@ void SetRotation (double x, double y, double z) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharKeys (unsigned int key, bool special, bool release, int x, int y) {
|
void CharKeys (unsigned int key, bool special, bool release, int x, int y) {
|
||||||
int keyfact;
|
|
||||||
must_render = true;
|
must_render = true;
|
||||||
|
|
||||||
if (ToolsFinalStage ()) {
|
if (ToolsFinalStage ()) {
|
||||||
|
@ -136,8 +135,6 @@ void CharKeys (unsigned int key, bool special, bool release, int x, int y) {
|
||||||
if (key == 304) shift = !release;
|
if (key == 304) shift = !release;
|
||||||
if (key == 306) control = !release;
|
if (key == 306) control = !release;
|
||||||
if (key == 308) alt = !release;
|
if (key == 308) alt = !release;
|
||||||
if (shift) keyfact = -1;
|
|
||||||
else keyfact = 1;
|
|
||||||
|
|
||||||
if (release) return;
|
if (release) return;
|
||||||
|
|
||||||
|
@ -276,19 +273,16 @@ void CharMouse (int button, int state, int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharMotion (int x, int y) {
|
void CharMotion (int x, int y) {
|
||||||
int diffx, diffy;
|
|
||||||
float diffposx, diffposy;
|
|
||||||
|
|
||||||
must_render = true;
|
must_render = true;
|
||||||
if (rotactive) {
|
if (rotactive) {
|
||||||
diffx = cursor_pos.x - startx;
|
int diffx = cursor_pos.x - startx;
|
||||||
diffy = cursor_pos.y - starty;
|
int diffy = cursor_pos.y - starty;
|
||||||
yrotation = startroty + diffx;
|
yrotation = startroty + diffx;
|
||||||
xrotation = startrotx + diffy;
|
xrotation = startrotx + diffy;
|
||||||
}
|
}
|
||||||
if (moveactive) {
|
if (moveactive) {
|
||||||
diffposx = (double)(cursor_pos.x - startx) / 200;
|
float diffposx = (double)(cursor_pos.x - startx) / 200;
|
||||||
diffposy = (double)(cursor_pos.y - starty) / 200;
|
float diffposy = (double)(cursor_pos.y - starty) / 200;
|
||||||
yposition = startposy - diffposy;
|
yposition = startposy - diffposy;
|
||||||
xposition = startposx + diffposx;
|
xposition = startposx + diffposx;
|
||||||
}
|
}
|
||||||
|
@ -367,7 +361,6 @@ void RenderChar (double timestep) {
|
||||||
|
|
||||||
FT.SetFont ("normal");
|
FT.SetFont ("normal");
|
||||||
FT.SetSize (16);
|
FT.SetSize (16);
|
||||||
int xl, yt;
|
|
||||||
for (size_t i=0; i<=lastnode; i++) {
|
for (size_t i=0; i<=lastnode; i++) {
|
||||||
if (i != curr_node) {
|
if (i != curr_node) {
|
||||||
FT.SetColor (colLGrey);
|
FT.SetColor (colLGrey);
|
||||||
|
@ -376,8 +369,8 @@ void RenderChar (double timestep) {
|
||||||
FT.SetColor (colYellow);
|
FT.SetColor (colYellow);
|
||||||
FT.SetFont ("bold");
|
FT.SetFont ("bold");
|
||||||
}
|
}
|
||||||
xl = ITrunc ((int)i, charbase) * 100 + 20;
|
int xl = ITrunc ((int)i, charbase) * 100 + 20;
|
||||||
yt = IFrac ((int)i, charbase) * 18 + 60;
|
int yt = IFrac ((int)i, charbase) * 18 + 60;
|
||||||
FT.DrawString (xl, yt, TestChar.GetNodeJoint (i));
|
FT.DrawString (xl, yt, TestChar.GetNodeJoint (i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +380,7 @@ void RenderChar (double timestep) {
|
||||||
for (size_t i=0; i<num; i++) {
|
for (size_t i=0; i<num; i++) {
|
||||||
is_visible = false;
|
is_visible = false;
|
||||||
type = action->type[i];
|
type = action->type[i];
|
||||||
yt = Winsys.resolution.height - 120 + (int)i * 18;
|
int yt = Winsys.resolution.height - 120 + (int)i * 18;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0:
|
case 0:
|
||||||
DrawActionVec (i, "trans", yt, action->vec[i]);
|
DrawActionVec (i, "trans", yt, action->vec[i]);
|
||||||
|
|
|
@ -210,15 +210,14 @@ void SingleFrameMotion (int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintFrameParams (int ytop, TKeyframe *frame) {
|
void PrintFrameParams (int ytop, TKeyframe *frame) {
|
||||||
int y, x;
|
|
||||||
int offs = 18;
|
int offs = 18;
|
||||||
|
|
||||||
for (int i=0; i<=last_joint; i++) {
|
for (int i=0; i<=last_joint; i++) {
|
||||||
if (i == curr_joint) FT.SetColor (colYellow);
|
if (i == curr_joint) FT.SetColor (colYellow);
|
||||||
else FT.SetColor (colLGrey);
|
else FT.SetColor (colLGrey);
|
||||||
|
|
||||||
x = ITrunc (i, jointbase) * 140 + 20;
|
int x = ITrunc (i, jointbase) * 140 + 20;
|
||||||
y = IFrac (i, jointbase) * offs + ytop;
|
int y = IFrac (i, jointbase) * offs + ytop;
|
||||||
|
|
||||||
FT.DrawString (x, y, TestFrame.GetJointName(i));
|
FT.DrawString (x, y, TestFrame.GetJointName(i));
|
||||||
if (i < 4) FT.DrawString (x+80, y, Float_StrN (frame->val[i], 2));
|
if (i < 4) FT.DrawString (x+80, y, Float_StrN (frame->val[i], 2));
|
||||||
|
@ -258,7 +257,6 @@ void RenderSingleFrame (double timestep) {
|
||||||
|
|
||||||
FT.SetFont ("normal");
|
FT.SetFont ("normal");
|
||||||
FT.SetSize (16);
|
FT.SetSize (16);
|
||||||
int xl, yt;
|
|
||||||
for (size_t i=0; i<TestFrame.numFrames(); i++) {
|
for (size_t i=0; i<TestFrame.numFrames(); i++) {
|
||||||
if (i != curr_frame) {
|
if (i != curr_frame) {
|
||||||
FT.SetColor (colLGrey);
|
FT.SetColor (colLGrey);
|
||||||
|
@ -267,8 +265,8 @@ void RenderSingleFrame (double timestep) {
|
||||||
FT.SetColor (colYellow);
|
FT.SetColor (colYellow);
|
||||||
FT.SetFont ("bold");
|
FT.SetFont ("bold");
|
||||||
}
|
}
|
||||||
xl = ITrunc ((int)i, framebase) * 100 + 20;
|
int xl = ITrunc ((int)i, framebase) * 100 + 20;
|
||||||
yt = IFrac ((int)i, framebase) * 18 + 20;
|
int yt = IFrac ((int)i, framebase) * 18 + 20;
|
||||||
FT.DrawString (xl, yt, Int_StrN ((int)i));
|
FT.DrawString (xl, yt, Int_StrN ((int)i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -945,9 +945,9 @@ void CCharShape::SaveCharNodes (const string& dir, const string& filename) {
|
||||||
if (node->parent_name >= node->node_name) Message ("wrong parent index");
|
if (node->parent_name >= node->node_name) Message ("wrong parent index");
|
||||||
string line = "*[node] " + Int_StrN ((int)node->node_name);
|
string line = "*[node] " + Int_StrN ((int)node->node_name);
|
||||||
line += " [par] " + Int_StrN ((int)node->parent_name);
|
line += " [par] " + Int_StrN ((int)node->parent_name);
|
||||||
bool rotflag = false;
|
|
||||||
|
|
||||||
if (!act->order.empty()) {
|
if (!act->order.empty()) {
|
||||||
|
bool rotflag = false;
|
||||||
TVector3 rotation;
|
TVector3 rotation;
|
||||||
line += " [order] " + act->order;
|
line += " [order] " + act->order;
|
||||||
for (size_t ii=0; ii<act->order.size(); ii++) {
|
for (size_t ii=0; ii<act->order.size(); ii++) {
|
||||||
|
|
|
@ -208,7 +208,6 @@ void update_view (CControl *ctrl, double dt) {
|
||||||
|
|
||||||
TVector3 vel_dir = ctrl->cvel;
|
TVector3 vel_dir = ctrl->cvel;
|
||||||
NormVector (vel_dir);
|
NormVector (vel_dir);
|
||||||
double course_angle = Course.GetCourseAngle();
|
|
||||||
|
|
||||||
switch (ctrl->viewmode) {
|
switch (ctrl->viewmode) {
|
||||||
case BEHIND: {
|
case BEHIND: {
|
||||||
|
|
|
@ -47,4 +47,4 @@ BEGIN
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
IDI_ICON1 ICON DISCARDABLE "resources\etracericon.ico"
|
IDI_ICON1 ICON DISCARDABLE "resources\etracericon.ico"
|
||||||
|
|
Loading…
Reference in New Issue