Added missing std:: prefixes to several C functions. Fixed type conversion issue in ogl.cpp

git-svn-id: https://svn.code.sf.net/p/extremetuxracer/code/trunk@602 0420edf4-82e4-42fc-9478-35b55e6d67a3
master
pkeus 2016-01-19 16:16:09 +00:00
parent ee35f1a467
commit 78729153f1
21 changed files with 92 additions and 93 deletions

View File

@ -205,9 +205,9 @@ void GetTimeComponents(double time, int *min, int *sec, int *hundr) {
}
std::string GetTimeString() {
time_t rawtime;
time(&rawtime);
struct tm* timeinfo = localtime(&rawtime);
std::time_t rawtime;
std::time(&rawtime);
struct std::tm* timeinfo = std::localtime(&rawtime);
std::string line = Int_StrN(timeinfo->tm_mon + 1);
line += '_' + Int_StrN(timeinfo->tm_mday);

View File

@ -77,7 +77,7 @@ CCourse::~CCourse() {
}
double CCourse::GetBaseHeight(double distance) const {
double slope = tan(ANGLES_TO_RADIANS(curr_course->angle));
double slope = std::tan(ANGLES_TO_RADIANS(curr_course->angle));
return -slope * distance -
base_height_value / 255.0 * curr_course->scale;
@ -352,7 +352,7 @@ bool CCourse::LoadElevMap() {
ny = img.getSize().y;
Fields.resize(nx*ny);
double slope = tan(ANGLES_TO_RADIANS(curr_course->angle));
double slope = std::tan(ANGLES_TO_RADIANS(curr_course->angle));
int pad = 0;
int depth = 4;
const uint8_t* data = img.getPixelsPtr();

View File

@ -317,7 +317,7 @@ void CEnvironment::DrawFog() {
// --------------- calculate the planes ---------------------------
double slope = tan(ANGLES_TO_RADIANS(Course.GetCourseAngle()));
double slope = std::tan(ANGLES_TO_RADIANS(Course.GetCourseAngle()));
// TPlane left_edge_plane = MakePlane (1.0, 0.0, 0.0, 0.0);
// TPlane right_edge_plane = MakePlane (-1.0, 0.0, 0.0, Course.width);

View File

@ -274,13 +274,13 @@ void InitConfig() {
#if 0
char buff[256];
if (strcmp(arg0, "./etr") == 0) { // start from work directory
if (std::strcmp(arg0, "./etr") == 0) { // start from work directory
char *s = getcwd(buff, 256);
if (s==nullptr) {};
} else { // start with full path
strcpy(buff, arg0);
if (strlen(buff) > 5) {
buff[strlen(buff)-3] = 0;
std::strcpy(buff, arg0);
if (std::strlen(buff) > 5) {
buff[std::strlen(buff)-3] = 0;
}
}

View File

@ -96,8 +96,8 @@ static void draw_herring_count(int herring_count, sf::Color color) {
TVector2d calc_new_fan_pt(double angle) {
return TVector2d(
ENERGY_GAUGE_CENTER_X + cos(ANGLES_TO_RADIANS(angle)) * SPEEDBAR_OUTER_RADIUS,
ENERGY_GAUGE_CENTER_Y + sin(ANGLES_TO_RADIANS(angle)) * SPEEDBAR_OUTER_RADIUS);
ENERGY_GAUGE_CENTER_X + std::cos(ANGLES_TO_RADIANS(angle)) * SPEEDBAR_OUTER_RADIUS,
ENERGY_GAUGE_CENTER_Y + std::sin(ANGLES_TO_RADIANS(angle)) * SPEEDBAR_OUTER_RADIUS);
}
void draw_partial_tri_fan(double fraction) {
@ -263,7 +263,7 @@ void DrawWind(float dir, float speed, const CControl *ctrl) {
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
// direction indicator
float dir_angle = RADIANS_TO_ANGLES(atan2(ctrl->cvel.x, ctrl->cvel.z));
float dir_angle = RADIANS_TO_ANGLES(std::atan2(ctrl->cvel.x, ctrl->cvel.z));
glColor4f(0, 0.5, 0, 1.0);
glRotatef(dir_angle - dir, 0, 0, 1);

View File

@ -65,7 +65,7 @@ int main(int argc, char **argv) {
std::cout << "\n----------- Extreme Tux Racer " ETR_VERSION_STRING " ----------------";
std::cout << "\n----------- (C) 2010-2016 Extreme Tuxracer Team --------\n\n";
srand(time(nullptr));
std::srand(std::time(nullptr));
InitConfig();
InitGame(argc, argv);
Winsys.Init();

View File

@ -105,7 +105,7 @@ TMatrix<4, 4> RotateAboutVectorMatrix(const TVector3d& u, double angle) {
double b = u.y;
double c = u.z;
double d = sqrt(b*b + c*c);
double d = std::sqrt(b*b + c*c);
if (d < EPS) {
if (a < 0)
@ -194,7 +194,7 @@ TQuaternion MakeQuaternionFromMatrix(const TMatrix<4, 4>& m) {
tr = m[0][0] + m[1][1] + m[2][2];
if (tr > 0.0) {
s = sqrt(tr + 1.0);
s = std::sqrt(tr + 1.0);
res.w = 0.5 * s;
s = 0.5 / s;
res.x = (m[1][2] - m[2][1]) * s;
@ -207,7 +207,7 @@ TQuaternion MakeQuaternionFromMatrix(const TMatrix<4, 4>& m) {
int j = nxt[i];
int k = nxt[j];
s = sqrt(m[i][i] - m[j][j] - m[k][k] + 1.0);
s = std::sqrt(m[i][i] - m[j][j] - m[k][k] + 1.0);
q[i] = s * 0.5;
@ -235,8 +235,8 @@ TQuaternion MakeRotationQuaternion(const TVector3d& s, const TVector3d& t) {
} else {
double cos2phi = DotProduct(s, t);
double sinphi = sqrt((1 - cos2phi) / 2.0);
double cosphi = sqrt((1 + cos2phi) / 2.0);
double sinphi = std::sqrt((1 - cos2phi) / 2.0);
double cosphi = std::sqrt((1 + cos2phi) / 2.0);
return TQuaternion(
sinphi * u.x,
@ -259,10 +259,10 @@ TQuaternion InterpolateQuaternions(const TQuaternion& q, TQuaternion r, double t
double scale0, scale1;
if (1.0 - cosphi > EPS) {
double phi = acos(cosphi);
double sinphi = sin(phi);
scale0 = sin(phi * (1.0 - t)) / sinphi;
scale1 = sin(phi * t) / sinphi;
double phi = std::acos(cosphi);
double sinphi = std::sin(phi);
scale0 = std::sin(phi * (1.0 - t)) / sinphi;
scale1 = std::sin(phi * t) / sinphi;
} else {
scale0 = 1.0 - t;
scale1 = t;
@ -516,15 +516,15 @@ double LinearInterp(const double x[], const double y[], double val, int n) {
}
double XRandom(double min, double max) {
return (double)rand() / RAND_MAX * (max - min) + min;
return (double)std::rand() / RAND_MAX * (max - min) + min;
}
double FRandom() {
return (double)rand() / RAND_MAX;
return (double)std::rand() / RAND_MAX;
}
int IRandom(int min, int max) {
return min + rand()%(max-min+1);
return min + std::rand()%(max-min+1);
}
int ITrunc(int val, int base) {

View File

@ -50,8 +50,8 @@ template void TMatrix<4, 4>::SetIdentity();
template<int ix, int iy>
void TMatrix<ix, iy>::SetRotationMatrix(double angle, char axis) {
double sinv, cosv;
sinv = sin(ANGLES_TO_RADIANS(angle));
cosv = cos(ANGLES_TO_RADIANS(angle));
sinv = std::sin(ANGLES_TO_RADIANS(angle));
cosv = std::cos(ANGLES_TO_RADIANS(angle));
SetIdentity();

View File

@ -31,7 +31,6 @@ GNU General Public License for more details.
#include "regist.h"
#include "winsys.h"
#include "spx.h"
#include <cctype>
CNewPlayer NewPlayer;

View File

@ -137,7 +137,7 @@ void set_material(const sf::Color& diffuse_colour, const sf::Color& specular_col
};
glMaterialiv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, specular_exp);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, specular_exp);
}
void ClearRenderContext() {
@ -429,9 +429,9 @@ void glTexCoord2(const TVector2d& vec) {
}
void glLoadMatrix(const TMatrix<4, 4>& mat) {
glLoadMatrixd((const double*) mat.data());
glLoadMatrixd(mat.data());
}
void glMultMatrix(const TMatrix<4, 4>& mat) {
glMultMatrixd((const double*) mat.data());
glMultMatrixd(mat.data());
}

View File

@ -79,7 +79,7 @@ TGuiParticle::TGuiParticle(float x, float y) {
vel.x = 0;
vel.y = BASE_VELOCITY + p_dist * VELOCITY_RANGE;
int type = rand() % 4;
int type = std::rand() % 4;
switch (type) {
case 0:
sprite.setTextureRect(sf::IntRect(0, 0, texture.getSize().x / 2, texture.getSize().y / 2));
@ -105,8 +105,8 @@ void TGuiParticle::Update(float time_step, float push_timestep, const TVector2d&
float x = sprite.getPosition().x / static_cast<float>(Winsys.resolution.width);
float y = sprite.getPosition().y / static_cast<float>(Winsys.resolution.height);
float dist_from_push = (pow((x - push_position.x), 2) +
pow((y - push_position.y), 2));
float dist_from_push = (std::pow((x - push_position.x), 2) +
std::pow((y - push_position.y), 2));
if (push_timestep > 0) {
f.x = PUSH_FACTOR * push_vector.x / push_timestep;
f.y = PUSH_FACTOR * push_vector.y / push_timestep;
@ -326,7 +326,7 @@ void create_new_particles(const TVector3d& loc, const TVector3d& vel, int num) {
newp->pt.x = loc.x + 2.*(FRandom() - 0.5) * START_RADIUS;
newp->pt.y = loc.y;
newp->pt.z = loc.z + 2.*(FRandom() - 0.5) * START_RADIUS;
newp->type = rand() % 4;
newp->type = std::rand() % 4;
newp->base_size = (FRandom() + 0.5) * OLD_PART_SIZE;
newp->cur_size = NEW_PART_SIZE;
newp->age = FRandom() * MIN_AGE;
@ -379,7 +379,7 @@ void clear_particles() {
static double adjust_particle_count(double count) {
if (count < 1) {
if (((double) rand()) / RAND_MAX < count) return 1.0;
if (((double)std::rand()) / RAND_MAX < count) return 1.0;
else return 0.0;
} else return count;
}
@ -500,7 +500,7 @@ void TFlakeArea::Draw(const CControl *ctrl) const {
const TPlane& lp = get_left_clip_plane();
const TPlane& rp = get_right_clip_plane();
float dir_angle(atan(ctrl->viewdir.x / ctrl->viewdir.z) * 180 / M_PI);
float dir_angle(std::atan(ctrl->viewdir.x / ctrl->viewdir.z) * 180 / M_PI);
ScopedRenderMode rm(PARTICLES);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@ -553,7 +553,7 @@ void CFlakes::MakeSnowFlake(std::size_t ar, std::size_t i) {
areas[ar].flakes[i].vel.z = 0;
areas[ar].flakes[i].vel.y = -areas[ar].flakes[i].size * areas[ar].speed;
int type = rand() % 4;
int type = std::rand() % 4;
static const GLfloat tex_coords[4][8] = {
{
@ -738,7 +738,7 @@ TCurtain::TCurtain(int num_rows, float z_dist, float tex_size,
break;
}
angledist = atan(size / 2 / zdist) * 360 / M_PI;
angledist = std::atan(size / 2 / zdist) * 360 / M_PI;
numCols = (unsigned int)(-2 * startangle / angledist) + 1;
if (numCols > MAX_CURTAIN_COLS) numCols = MAX_CURTAIN_COLS;
lastangle = startangle + (numCols-1) * angledist;
@ -820,9 +820,9 @@ void TCurtain::Update(float timestep, const TVector3d& drift, const CControl* ct
static CCurtain Curtain;
void TCurtain::CurtainVec(float angle, float zdist, float &x, float &z) {
x = zdist * sin(angle * M_PI / 180);
if (angle > 90 || angle < -90) z = sqrt(zdist * zdist - x * x);
else z = -sqrt(zdist * zdist - x * x);
x = zdist * std::sin(angle * M_PI / 180);
if (angle > 90 || angle < -90) z = std::sqrt(zdist * zdist - x * x);
else z = -std::sqrt(zdist * zdist - x * x);
}
void CCurtain::Draw() {
@ -1070,8 +1070,8 @@ void CWind::Update(float timestep) {
if (WAngle > params.maxAngle) WAngle = params.maxAngle;
if (WAngle < params.minAngle) WAngle = params.minAngle;
float xx = sin(WAngle * M_PI / 180.f);
float zz = sqrt(1 - xx * xx);
float xx = std::sin(WAngle * M_PI / 180.f);
float zz = std::sqrt(1 - xx * xx);
if ((WAngle > 90 && WAngle < 270) || (WAngle > 450 && WAngle < 630)) {
zz = -zz;
}

View File

@ -276,7 +276,7 @@ TVector3d CControl::CalcAirForce() {
double re = 34600 * windspeed;
int tablesize = sizeof(airdrag) / sizeof(airdrag[0]);
double interpol = LinearInterp(airlog, airdrag, log10(re), tablesize);
double dragcoeff = pow(10.0, interpol);
double dragcoeff = std::pow(10.0, interpol);
double airfact = 0.104 * dragcoeff * windspeed;
return airfact * windvec;
}
@ -326,8 +326,8 @@ TVector3d CControl::CalcFrictionForce(double speed, const TVector3d& nmlforce) {
double steer_angle = turn_fact * MAX_TURN_ANGLE;
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)) *
if (fabs(fric_f_mag * std::sin(steer_angle * M_PI / 180)) > MAX_TURN_PERP) {
steer_angle = RADIANS_TO_ANGLES(std::asin(MAX_TURN_PERP / fric_f_mag)) *
turn_fact / fabs(turn_fact);
}
TMatrix<4, 4> fric_rot_mat = RotateAboutVectorMatrix(ff.surfnml, steer_angle);
@ -534,8 +534,8 @@ void CControl::SolveOdeSystem(double timestep) {
vel_err[i] *= vel_err[i];
tot_vel_err += vel_err[i];
}
tot_pos_err = sqrt(tot_pos_err);
tot_vel_err = sqrt(tot_vel_err);
tot_pos_err = std::sqrt(tot_pos_err);
tot_vel_err = std::sqrt(tot_vel_err);
if (tot_pos_err / MAX_POS_ERR > tot_vel_err / MAX_VEL_ERR) {
err = tot_pos_err;
tol = MAX_POS_ERR;
@ -548,7 +548,7 @@ void CControl::SolveOdeSystem(double timestep) {
done = false;
if (!failed) {
failed = true;
h *= std::max(0.5, 0.8 * pow(tol/err, solver.TimestepExponent()));
h *= std::max(0.5, 0.8 * std::pow(tol/err, solver.TimestepExponent()));
} else h *= 0.5;
h = AdjustTimeStep(h, saved_vel);
@ -566,7 +566,7 @@ void CControl::SolveOdeSystem(double timestep) {
new_f = CalcNetForce(new_pos, new_vel);
if (!failed && solver.EstimateError != nullptr) {
double temp = 1.25 * pow(err / tol, solver.TimestepExponent());
double temp = 1.25 * std::pow(err / tol, solver.TimestepExponent());
if (temp > 0.2) h = h / temp;
else h = 5.0 * h;
}

View File

@ -328,7 +328,7 @@ float quadsquare::RecomputeError(const quadcornerdata& cd) {
}
std::size_t *terrain_count = new std::size_t[numTerr];
memset(terrain_count, 0, sizeof(*terrain_count)*numTerr);
std::memset(terrain_count, 0, sizeof(*terrain_count)*numTerr);
for (int i=cd.xorg; i<=cd.xorg+whole; i++) {
for (int j=cd.zorg; j<=cd.zorg+whole; j++) {
@ -1081,8 +1081,8 @@ void ResetQuadtree() {
}
static int get_root_level(int nx, int nz) {
int xlev = (int)(log(static_cast<double>(nx)) / log(2.0));
int zlev = (int)(log(static_cast<double>(nz)) / log(2.0));
int xlev = (int)(std::log(static_cast<double>(nx)) / std::log(2.0));
int zlev = (int)(std::log(static_cast<double>(nz)) / std::log(2.0));
return std::max(xlev, zlev);
}

View File

@ -239,11 +239,11 @@ void CRacing::Enter() {
// this function is not used yet.
/*static int SlideVolume(CControl *ctrl, double speed, int typ) {
if (typ == 1) { // only at paddling or braking
return (int)(std::min((((pow(ctrl->turn_fact, 2) * 128)) +
return (int)(std::min((((std::pow(ctrl->turn_fact, 2) * 128)) +
(ctrl->is_braking ? 128:0) +
(ctrl->jumping ? 128:0) + 20) * (speed / 10), 128.0));
} else { // always
return (int)(128 * pow((speed/2),2));
return (int)(128 * std::pow((speed/2),2));
}
}*/
@ -304,7 +304,7 @@ static void CalcSteeringControls(CControl *ctrl, float time_step) {
static void CalcFinishControls(CControl *ctrl, float timestep, bool airborne) {
double speed = ctrl->cvel.Length();
double dir_angle = RADIANS_TO_ANGLES(atan(ctrl->cvel.x / ctrl->cvel.z));
double dir_angle = RADIANS_TO_ANGLES(std::atan(ctrl->cvel.x / ctrl->cvel.z));
if (fabs(dir_angle) > 5 && speed > 5) {
ctrl->turn_fact = dir_angle / 20;

View File

@ -245,7 +245,7 @@ void CTexture::DrawFrame(std::size_t idx, int x, int y, double w, double h, int
void CTexture::DrawNumChr(char c, int x, int y, int w, int h) {
int idx;
if (isdigit(c)) {
if (std::isdigit(c)) {
char chrname[2] = {c, '\0'};
idx = atoi(chrname);
} else if (c == ':')

View File

@ -53,8 +53,8 @@ CCamera::CCamera() {
}
void CCamera::XMove(GLfloat step) {
zview += (float)sin(-vhead * 3.14 / 180) * step;
xview += (float)cos(-vhead * 3.14 / 180) * step;
zview += (float)std::sin(-vhead * 3.14 / 180) * step;
xview += (float)std::cos(-vhead * 3.14 / 180) * step;
}
void CCamera::YMove(GLfloat step) {
@ -62,8 +62,8 @@ void CCamera::YMove(GLfloat step) {
}
void CCamera::ZMove(GLfloat step) {
xview += (float)sin(vhead * 3.14 / 180) * step;
zview += (float)cos(vhead * 3.14 / 180) * step;
xview += (float)std::sin(vhead * 3.14 / 180) * step;
zview += (float)std::cos(vhead * 3.14 / 180) * step;
}
void CCamera::RotateHead(GLfloat step) {
@ -107,8 +107,8 @@ void CGluCamera::Update(float timestep) {
if (turnleft) angle -= timestep * 2000;
if (nearer) distance -= timestep * 100;
if (farther) distance += timestep * 100;
double xx = distance * sin(angle * M_PI / 180);
double zz = distance * sin((90 - angle) * M_PI / 180);
double xx = distance * std::sin(angle * M_PI / 180);
double zz = distance * std::sin((90 - angle) * M_PI / 180);
glLoadIdentity();
gluLookAt(xx, 0, zz, 0, 0, 0, 0, 1, 0);
}

View File

@ -560,13 +560,13 @@ void CCharShape::AdjustJoints(double turnFact, bool isBraking,
if (isBraking) braking_angle = MAX_ARM_ANGLE2;
paddling_angle = MAX_PADDLING_ANGLE2 * sin(paddling_factor * M_PI);
ext_paddling_angle = MAX_EXT_PADDLING_ANGLE2 * sin(paddling_factor * M_PI);
kick_paddling_angle = MAX_KICK_PADDLING_ANGLE2 * sin(paddling_factor * M_PI * 2.0);
paddling_angle = MAX_PADDLING_ANGLE2 * std::sin(paddling_factor * M_PI);
ext_paddling_angle = MAX_EXT_PADDLING_ANGLE2 * std::sin(paddling_factor * M_PI);
kick_paddling_angle = MAX_KICK_PADDLING_ANGLE2 * std::sin(paddling_factor * M_PI * 2.0);
turning_angle[0] = std::max(-turnFact,0.0) * MAX_ARM_ANGLE2;
turning_angle[1] = std::max(turnFact,0.0) * MAX_ARM_ANGLE2;
flap_angle = MAX_ARM_ANGLE2 * (0.5 + 0.5 * sin(M_PI * flap_factor * 6 - M_PI / 2));
flap_angle = MAX_ARM_ANGLE2 * (0.5 + 0.5 * std::sin(M_PI * flap_factor * 6 - M_PI / 2));
force_angle = clamp(-20.0, -net_force.z / 300.0, 20.0);
turn_leg_angle = turnFact * 10;
@ -663,18 +663,18 @@ void CCharShape::DrawShadowSphere(const TMatrix<4, 4>& mat) {
double sin_phi, cos_phi;
double sin_phi_d_phi, cos_phi_d_phi;
sin_phi = sin(phi);
cos_phi = cos(phi);
sin_phi_d_phi = sin(phi + d_phi);
cos_phi_d_phi = cos(phi + d_phi);
sin_phi = std::sin(phi);
cos_phi = std::cos(phi);
sin_phi_d_phi = std::sin(phi + d_phi);
cos_phi_d_phi = std::cos(phi + d_phi);
if (phi <= eps) {
glBegin(GL_TRIANGLE_FAN);
DrawShadowVertex(0., 0., 1., mat);
for (theta = 0.0; theta + eps < twopi; theta += d_theta) {
sin_theta = sin(theta);
cos_theta = cos(theta);
sin_theta = std::sin(theta);
cos_theta = std::cos(theta);
x = cos_theta * sin_phi_d_phi;
y = sin_theta * sin_phi_d_phi;
@ -690,8 +690,8 @@ void CCharShape::DrawShadowSphere(const TMatrix<4, 4>& mat) {
glBegin(GL_TRIANGLE_FAN);
DrawShadowVertex(0., 0., -1., mat);
for (theta = twopi; theta - eps > 0; theta -= d_theta) {
sin_theta = sin(theta);
cos_theta = cos(theta);
sin_theta = std::sin(theta);
cos_theta = std::cos(theta);
x = cos_theta * sin_phi;
y = sin_theta * sin_phi;
z = cos_phi;
@ -705,8 +705,8 @@ void CCharShape::DrawShadowSphere(const TMatrix<4, 4>& mat) {
} else {
glBegin(GL_TRIANGLE_STRIP);
for (theta = 0.0; theta + eps < twopi; theta += d_theta) {
sin_theta = sin(theta);
cos_theta = cos(theta);
sin_theta = std::sin(theta);
cos_theta = std::cos(theta);
x = cos_theta * sin_phi;
y = sin_theta * sin_phi;
z = cos_phi;

View File

@ -35,7 +35,7 @@ template<>
double TVector3<double>::Norm() {
double square = x*x + y*y + z*z;
if (square == 0.0) return 0.0;
double denom = sqrt(square);
double denom = std::sqrt(square);
*this *= 1.0 / denom;
return denom;
}

View File

@ -28,7 +28,7 @@ struct TVector2 {
: x(_x), y(_y)
{}
double Length() const {
return sqrt(static_cast<double>(x*x + y*y));
return std::sqrt(static_cast<double>(x*x + y*y));
}
double Norm();
TVector2<T>& operator*=(T f) {
@ -55,7 +55,7 @@ struct TVector3 {
: x(_x), y(_y), z(_z)
{}
double Length() const {
return sqrt(static_cast<double>(x*x + y*y + z*z));
return std::sqrt(static_cast<double>(x*x + y*y + z*z));
}
double Norm();
TVector3<T>& operator*=(T f) {
@ -85,7 +85,7 @@ struct TVector4 {
: x(_x), y(_y), z(_z), w(_w)
{}
double Length() const {
return sqrt(static_cast<double>(x*x + y*y + z*z + w*w));
return std::sqrt(static_cast<double>(x*x + y*y + z*z + w*w));
}
double Norm();
TVector4<T>& operator*=(T f) {

View File

@ -78,11 +78,11 @@ TVector3d interpolate_view_pos(const TVector3d& ctrl_pos1, const TVector3d& ctrl
TQuaternion q1 = MakeRotationQuaternion(y_vec, vec1);
TQuaternion q2 = MakeRotationQuaternion(y_vec, vec2);
double alpha = std::min(MAX_INTERPOLATION_VALUE, 1.f - exp(-dt / time_constant));
double alpha = std::min(MAX_INTERPOLATION_VALUE, 1.f - std::exp(-dt / time_constant));
q2 = InterpolateQuaternions(q1, q2, alpha);
vec2 = RotateVector(q2, y_vec);
double theta = RADIANS_TO_ANGLES(M_PI/2 - acos(DotProduct(vec2, y_vec)));
double theta = RADIANS_TO_ANGLES(M_PI/2 - std::acos(DotProduct(vec2, y_vec)));
if (theta > max_vec_angle) {
TVector3d axis = CrossProduct(y_vec, vec2);
axis.Norm();
@ -111,7 +111,7 @@ void interpolate_view_frame(const TVector3d& up1, const TVector3d& dir1,
TMatrix<4, 4> cob_mat2(x2, y2, z2);
TQuaternion q2 = MakeQuaternionFromMatrix(cob_mat2);
double alpha = std::min(MAX_INTERPOLATION_VALUE, 1.f - exp(-dt / (float)time_constant));
double alpha = std::min(MAX_INTERPOLATION_VALUE, 1.f - std::exp(-dt / (float)time_constant));
q2 = InterpolateQuaternions(q1, q2, alpha);
cob_mat2 = MakeMatrixFromQuaternion(q2);
@ -162,7 +162,7 @@ TVector3d MakeViewVector() {
course_angle -
CAMERA_ANGLE_ABOVE_SLOPE +
PLAYER_ANGLE_IN_CAMERA);
return TVector3d(0, camera_distance * sin(rad), camera_distance * cos(rad));
return TVector3d(0, camera_distance * std::sin(rad), camera_distance * std::cos(rad));
}
void update_view(CControl *ctrl, float dt) {
@ -324,18 +324,18 @@ void SetupViewFrustum(const CControl *ctrl) {
double near_dist = NEAR_CLIP_DIST;
double far_dist = param.forward_clip_distance;
double half_fov = ANGLES_TO_RADIANS(param.fov * 0.5);
double half_fov_horiz = atan(tan(half_fov) * aspect);
double half_fov_horiz = std::atan(std::tan(half_fov) * aspect);
frustum_planes[0] = TPlane(0, 0, 1, near_dist);
frustum_planes[1] = TPlane(0, 0, -1, -far_dist);
frustum_planes[2]
= TPlane(-cos(half_fov_horiz), 0, sin(half_fov_horiz), 0);
= TPlane(-std::cos(half_fov_horiz), 0, std::sin(half_fov_horiz), 0);
frustum_planes[3]
= TPlane(cos(half_fov_horiz), 0, sin(half_fov_horiz), 0);
= TPlane(std::cos(half_fov_horiz), 0, std::sin(half_fov_horiz), 0);
frustum_planes[4]
= TPlane(0, cos(half_fov), sin(half_fov), 0);
= TPlane(0, std::cos(half_fov), std::sin(half_fov), 0);
frustum_planes[5]
= TPlane(0, -cos(half_fov), sin(half_fov), 0);
= TPlane(0, -std::cos(half_fov), std::sin(half_fov), 0);
for (int i=0; i<6; i++) {
TVector3d pt = TransformPoint(ctrl->view_mat,

View File

@ -105,7 +105,7 @@ void CWinsys::SetupVideoMode(const TScreenRes& resolution_) {
window.setFramerateLimit(param.framerate);
scale = CalcScreenScale();
if (param.use_quad_scale) scale = sqrt(scale);
if (param.use_quad_scale) scale = std::sqrt(scale);
}
void CWinsys::SetupVideoMode(std::size_t idx) {