Refactorizations:
- Reduced time spend in set_material(), reduced calls in track_marks.cpp - Uniformized some more double/float usage - Prefer copy_n over memcpy, fill_n over memset git-svn-id: https://svn.code.sf.net/p/extremetuxracer/code/branches/SFML2@515 0420edf4-82e4-42fc-9478-35b55e6d67a3master
parent
7aeae80081
commit
ad659cf18b
|
@ -161,7 +161,7 @@ void CGameConfig::Enter() {
|
|||
detail_level = AddUpDown(rightpos, area.top+dd*5, 1, 4, param.perf_level);
|
||||
|
||||
textbuttons[0] = AddTextButton(Trans.Text(28), area.left+50, AutoYPosN(80), siz);
|
||||
double len = FT.GetTextWidth(Trans.Text(8));
|
||||
float len = FT.GetTextWidth(Trans.Text(8));
|
||||
textbuttons[1] = AddTextButton(Trans.Text(15), area.right-len-50, AutoYPosN(80), siz);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
|
|
|
@ -40,7 +40,7 @@ GNU General Public License for more details.
|
|||
|
||||
void TCourse::SetDescription(const std::string& description) {
|
||||
FT.AutoSizeN(2);
|
||||
vector<string> desclist = FT.MakeLineList(description.c_str(), 335 * Winsys.scale - 16.0);
|
||||
vector<string> desclist = FT.MakeLineList(description.c_str(), 335.f * Winsys.scale - 16.f);
|
||||
size_t cnt = min<size_t>(desclist.size(), MAX_DESCRIPTION_LINES);
|
||||
num_lines = cnt;
|
||||
for (size_t ll = 0; ll < cnt; ll++) {
|
||||
|
@ -619,8 +619,8 @@ bool CCourse::LoadTerrainTypes() {
|
|||
TerrList[i].tracktex = SPIntN(*line, "tracktex", -1);
|
||||
TerrList[i].stoptex = SPIntN(*line, "stoptex", -1);
|
||||
TerrList[i].col = SPColor3N(*line, "col", TColor3(255, 255, 255));
|
||||
TerrList[i].friction = SPFloatN(*line, "friction", 0.5);
|
||||
TerrList[i].depth = SPFloatN(*line, "depth", 0.01);
|
||||
TerrList[i].friction = SPFloatN(*line, "friction", 0.5f);
|
||||
TerrList[i].depth = SPFloatN(*line, "depth", 0.01f);
|
||||
TerrList[i].particles = SPBoolN(*line, "part", false);
|
||||
TerrList[i].trackmarks = SPBoolN(*line, "trackmarks", false);
|
||||
TerrList[i].texture = NULL;
|
||||
|
|
|
@ -31,12 +31,12 @@ GNU General Public License for more details.
|
|||
#define TOP_Y 165
|
||||
#define BOTT_Y 64
|
||||
#define FADE 50
|
||||
#define OFFS_SCALE_FACTOR 1.2
|
||||
#define OFFS_SCALE_FACTOR 1.2f
|
||||
|
||||
CCredits Credits;
|
||||
|
||||
|
||||
static double y_offset = 0;
|
||||
static float y_offset = 0;
|
||||
static bool moving = true;
|
||||
sf::RenderTexture* RT = 0;
|
||||
sf::VertexArray arr(sf::Quads, 12);
|
||||
|
@ -55,18 +55,18 @@ void CCredits::LoadCreditList() {
|
|||
TCredits& credit = CreditList.back();
|
||||
credit.text = SPStrN(*line, "text");
|
||||
|
||||
double offset = SPFloatN(*line, "offs", 0) * OFFS_SCALE_FACTOR * Winsys.scale;
|
||||
float offset = SPFloatN(*line, "offs", 0) * OFFS_SCALE_FACTOR * Winsys.scale;
|
||||
if (line != list.cbegin()) credit.offs = CreditList.back().offs + (int)offset;
|
||||
else credit.offs = offset;
|
||||
|
||||
credit.col = SPIntN(*line, "col", 0);
|
||||
credit.size = SPFloatN(*line, "size", 1.0);
|
||||
credit.size = SPFloatN(*line, "size", 1.f);
|
||||
}
|
||||
}
|
||||
|
||||
void CCredits::DrawCreditsText(float time_step) {
|
||||
int h = Winsys.resolution.height;
|
||||
double offs = 0.0;
|
||||
float offs = 0.f;
|
||||
if (moving) y_offset += time_step * 30;
|
||||
|
||||
sf::Text text;
|
||||
|
@ -74,7 +74,7 @@ void CCredits::DrawCreditsText(float time_step) {
|
|||
RT->clear(colTBackr);
|
||||
for (list<TCredits>::const_iterator i = CreditList.begin(); i != CreditList.end(); ++i) {
|
||||
offs = h - TOP_Y - y_offset + i->offs;
|
||||
if (offs > h || offs < -100.0) // Draw only visible lines
|
||||
if (offs > h || offs < -100.f) // Draw only visible lines
|
||||
continue;
|
||||
|
||||
if (i->col == 0)
|
||||
|
|
|
@ -27,7 +27,7 @@ struct TCredits {
|
|||
string text;
|
||||
int offs;
|
||||
int font;
|
||||
double size;
|
||||
float size;
|
||||
int col;
|
||||
};
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ void CEvent::Enter() {
|
|||
ResetGUI();
|
||||
int siz = FT.AutoSizeN(5);
|
||||
textbuttons[1] = AddTextButton(Trans.Text(8), area.left + 100, AutoYPosN(80), siz);
|
||||
double len = FT.GetTextWidth(Trans.Text(13));
|
||||
float len = FT.GetTextWidth(Trans.Text(13));
|
||||
textbuttons[0] = AddTextButton(Trans.Text(13), area.right -len - 100, AutoYPosN(80), siz);
|
||||
textbuttons[2] = AddTextButton(Trans.Text(15), CENTER, AutoYPosN(80), siz);
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ void CEventSelect::Enter() {
|
|||
|
||||
int siz = FT.AutoSizeN(5);
|
||||
|
||||
double len = FT.GetTextWidth(Trans.Text(9));
|
||||
float len = FT.GetTextWidth(Trans.Text(9));
|
||||
textbuttons[0] = AddTextButton(Trans.Text(9), area.right-len-50, AutoYPosN(70), siz);
|
||||
textbuttons[1] = AddTextButton(Trans.Text(8), area.left+50, AutoYPosN(70), siz);
|
||||
SetFocus(textbuttons[1]);
|
||||
|
|
|
@ -247,7 +247,7 @@ float CFont::GetTextWidth(const sf::String& text, const string &fontname, float
|
|||
}
|
||||
|
||||
float CFont::CenterX(const char *text) const {
|
||||
return (Winsys.resolution.width - GetTextWidth(text)) / 2.0;
|
||||
return (Winsys.resolution.width - GetTextWidth(text)) / 2.f;
|
||||
}
|
||||
|
||||
vector<string> CFont::MakeLineList(const char *source, float width) {
|
||||
|
|
|
@ -149,8 +149,8 @@ void SaveConfigFile() {
|
|||
AddItem(liste, "res_type", param.res_type);
|
||||
liste.Add();
|
||||
|
||||
AddComment(liste, "Level of details [1...3]");
|
||||
AddComment(liste, "1 = best performance, 3 = best appearance");
|
||||
AddComment(liste, "Level of details [1...4]");
|
||||
AddComment(liste, "1 = best performance, 4 = best appearance");
|
||||
AddItem(liste, "detail_level", param.perf_level);
|
||||
liste.Add();
|
||||
|
||||
|
|
|
@ -190,13 +190,13 @@ TTextField::TTextField(int x, int y, int width, int height, const sf::String& te
|
|||
: TWidget(x, y, width, height)
|
||||
, text(text_, FT.getCurrentFont(), FT.AutoSizeN(5))
|
||||
, frame(sf::Vector2f(width-6.f, height-6.f))
|
||||
, cursorShape(sf::Vector2f(2, 26 * Winsys.scale))
|
||||
, cursorShape(sf::Vector2f(2.f, 26.f * Winsys.scale))
|
||||
, maxLng(32)
|
||||
, time(0.0)
|
||||
, cursor(false) {
|
||||
text.setPosition(mouseRect.left + 20, mouseRect.top);
|
||||
cursorShape.setFillColor(colYellow);
|
||||
frame.setPosition(x + 3.f, y + 3.f);
|
||||
frame.setPosition(x + 3, y + 3);
|
||||
frame.setOutlineThickness(3);
|
||||
frame.setFillColor(colMBackgr);
|
||||
frame.setOutlineColor(colWhite);
|
||||
|
|
|
@ -25,7 +25,7 @@ GNU General Public License for more details.
|
|||
#include "tux.h"
|
||||
#include "game_ctrl.h"
|
||||
#include "physics.h"
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
static const int numJoints = 19;
|
||||
|
@ -325,7 +325,7 @@ void CKeyframe::UpdateTest(float timestep, CCharShape *shape) {
|
|||
}
|
||||
|
||||
void CKeyframe::ResetFrame2(TKeyframe *frame) {
|
||||
for (int i = 1; i<32; i++) frame->val[i] = 0.0;
|
||||
std::fill_n(frame->val + 1, MAX_FRAME_VALUES - 1, 0.0);
|
||||
frame->val[0] = 0.5; // time
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ void CKeyframe::SaveTest(const string& dir, const string& filename) {
|
|||
void CKeyframe::CopyFrame(size_t prim_idx, size_t sec_idx) {
|
||||
TKeyframe *ppp = &frames[prim_idx];
|
||||
TKeyframe *sss = &frames[sec_idx];
|
||||
memcpy(sss->val, ppp->val, MAX_FRAME_VALUES*sizeof(*sss->val));
|
||||
std::copy_n(ppp->val, MAX_FRAME_VALUES, sss->val);
|
||||
}
|
||||
|
||||
void CKeyframe::AddFrame() {
|
||||
|
@ -423,12 +423,12 @@ void CKeyframe::InsertFrame(size_t idx) {
|
|||
|
||||
void CKeyframe::CopyToClipboard(size_t idx) {
|
||||
if (idx >= frames.size()) return;
|
||||
memcpy(clipboard.val, frames[idx].val, MAX_FRAME_VALUES*sizeof(*frames[idx].val));
|
||||
std::copy_n(frames[idx].val, MAX_FRAME_VALUES, clipboard.val);
|
||||
}
|
||||
|
||||
void CKeyframe::PasteFromClipboard(size_t idx) {
|
||||
if (idx >= frames.size()) return;
|
||||
memcpy(frames[idx].val, clipboard.val, MAX_FRAME_VALUES*sizeof(*frames[idx].val));
|
||||
std::copy_n(clipboard.val, MAX_FRAME_VALUES, frames[idx].val);
|
||||
}
|
||||
|
||||
void CKeyframe::ClearFrame(size_t idx) {
|
||||
|
|
|
@ -362,7 +362,7 @@ bool IntersectPolygon(const TPolygon& p, vector<TVector3d>& v) {
|
|||
double distsq;
|
||||
|
||||
TVector3d nml = MakeNormal(p, &v[0]);
|
||||
ray.pt = TVector3d(0., 0., 0.);
|
||||
ray.pt = TVector3d();
|
||||
ray.vec = nml;
|
||||
|
||||
nuDotProd = DotProduct(nml, ray.vec);
|
||||
|
@ -516,7 +516,7 @@ double LinearInterp(const double x[], const double y[], double val, int n) {
|
|||
return m * val + b;
|
||||
}
|
||||
|
||||
double XRandom(float min, float max) {
|
||||
double XRandom(double min, double max) {
|
||||
return (double)rand() / RAND_MAX * (max - min) + min;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ struct TOdeSolver {
|
|||
int Gauss(double *matrix, int n, double *soln);
|
||||
double LinearInterp(const double x[], const double y[], double val, int n);
|
||||
|
||||
double XRandom(float min, float max);
|
||||
double XRandom(double min, double max);
|
||||
double FRandom();
|
||||
int IRandom(int min, int max);
|
||||
int ITrunc(int val, int base);
|
||||
|
|
|
@ -103,7 +103,7 @@ void CNewPlayer::Enter() {
|
|||
avatar = AddUpDown(area.left + prevwidth + prevoffs + 8, prevtop, 0, (int)Players.numAvatars() - 1, 0, prevwidth - 34);
|
||||
int siz = FT.AutoSizeN(5);
|
||||
textbuttons[0] = AddTextButton(Trans.Text(8), area.left+50, AutoYPosN(70), siz);
|
||||
double len = FT.GetTextWidth(Trans.Text(15));
|
||||
float len = FT.GetTextWidth(Trans.Text(15));
|
||||
textbuttons[1] = AddTextButton(Trans.Text(15), area.right-len-50, AutoYPosN(70), siz);
|
||||
|
||||
textfield = AddTextField(emptyString, area.left, frametop, framewidth, frameheight);
|
||||
|
|
39
src/ogl.cpp
39
src/ogl.cpp
|
@ -130,27 +130,32 @@ void PrintGLInfo() {
|
|||
}
|
||||
}
|
||||
|
||||
void set_material(const sf::Color& diffuse_colour, const sf::Color& specular_colour, float specular_exp) {
|
||||
GLfloat mat_amb_diff[4] = {
|
||||
static_cast<GLfloat>(diffuse_colour.r) / 255.f,
|
||||
static_cast<GLfloat>(diffuse_colour.g) / 255.f,
|
||||
static_cast<GLfloat>(diffuse_colour.b) / 255.f,
|
||||
static_cast<GLfloat>(diffuse_colour.a) / 255.f
|
||||
void set_material_diffuse(const sf::Color& diffuse_colour) {
|
||||
GLint mat_amb_diff[4] = {
|
||||
static_cast<GLint>(diffuse_colour.r) * (INT_MAX / 255),
|
||||
static_cast<GLint>(diffuse_colour.g) * (INT_MAX / 255),
|
||||
static_cast<GLint>(diffuse_colour.b) * (INT_MAX / 255),
|
||||
static_cast<GLint>(diffuse_colour.a) * (INT_MAX / 255)
|
||||
};
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_amb_diff);
|
||||
|
||||
GLfloat mat_specular[4] = {
|
||||
static_cast<GLfloat>(specular_colour.r) / 255.f,
|
||||
static_cast<GLfloat>(specular_colour.g) / 255.f,
|
||||
static_cast<GLfloat>(specular_colour.b) / 255.f,
|
||||
static_cast<GLfloat>(specular_colour.a) / 255.f
|
||||
};
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
|
||||
|
||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, specular_exp);
|
||||
glMaterialiv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_amb_diff);
|
||||
|
||||
glColor(diffuse_colour);
|
||||
}
|
||||
|
||||
void set_material(const sf::Color& diffuse_colour, const sf::Color& specular_colour, float specular_exp) {
|
||||
set_material_diffuse(diffuse_colour);
|
||||
|
||||
GLint mat_specular[4] = {
|
||||
static_cast<GLint>(specular_colour.r) * (INT_MAX / 255),
|
||||
static_cast<GLint>(specular_colour.g) * (INT_MAX / 255),
|
||||
static_cast<GLint>(specular_colour.b) * (INT_MAX / 255),
|
||||
static_cast<GLint>(specular_colour.a) * (INT_MAX / 255)
|
||||
};
|
||||
glMaterialiv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
|
||||
|
||||
glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, specular_exp);
|
||||
}
|
||||
|
||||
void ClearRenderContext() {
|
||||
glDepthMask(GL_TRUE);
|
||||
glClearColor(colBackgr.r / 255.f, colBackgr.g / 255.f, colBackgr.b / 255.f, colBackgr.a / 255.f);
|
||||
|
|
|
@ -48,6 +48,7 @@ void check_gl_error();
|
|||
void InitOpenglExtensions();
|
||||
void PrintGLInfo();
|
||||
|
||||
void set_material_diffuse(const sf::Color& specular_colour);
|
||||
void set_material(const sf::Color& diffuse_colour,
|
||||
const sf::Color& specular_colour,
|
||||
float specular_exp);
|
||||
|
|
|
@ -154,7 +154,7 @@ void update_ui_snow(float time_step) {
|
|||
p->Update(time_step, push_timestep, push_vector);
|
||||
}
|
||||
|
||||
if (FRandom() < time_step*20.0*(MAX_num_snowparticles - particles_2d.size()) / 1000.0) {
|
||||
if (FRandom() < time_step*20.f*(MAX_num_snowparticles - particles_2d.size()) / 1000.f) {
|
||||
particles_2d.emplace_back(FRandom(), -0.05);
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ void update_ui_snow(float time_step) {
|
|||
} else {
|
||||
p->sprite.setPosition(static_cast<float>(Winsys.resolution.width)*FRandom(), static_cast<float>(Winsys.resolution.height) * (-FRandom()*BASE_VELOCITY));
|
||||
double p_dist = FRandom();
|
||||
p->size = PARTICLE_MIN_SIZE + (1.0 - p_dist) * PARTICLE_SIZE_RANGE;
|
||||
p->size = PARTICLE_MIN_SIZE + (1.f - p_dist) * PARTICLE_SIZE_RANGE;
|
||||
p->sprite.setScale(p->size / (p->sprite.getTexture()->getSize().x / 2), p->size / (p->sprite.getTexture()->getSize().x / 2));
|
||||
p->vel.x = 0;
|
||||
p->vel.y = BASE_VELOCITY + p_dist*VELOCITY_RANGE;
|
||||
|
@ -470,7 +470,7 @@ void TFlake::Draw(const TPlane& lp, const TPlane& rp, bool rotate_flake, float d
|
|||
|
||||
|
||||
TFlakeArea::TFlakeArea(
|
||||
int num_flakes,
|
||||
size_t num_flakes,
|
||||
float _xrange,
|
||||
float _ytop,
|
||||
float _yrange,
|
||||
|
@ -498,7 +498,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 / 3.14159);
|
||||
float dir_angle(atan(ctrl->viewdir.x / ctrl->viewdir.z) * 180 / M_PI);
|
||||
|
||||
ScopedRenderMode rm(PARTICLES);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
@ -599,8 +599,8 @@ void CFlakes::UpdateAreas(const CControl *ctrl) {
|
|||
}
|
||||
}
|
||||
|
||||
#define YDRIFT 0.8
|
||||
#define ZDRIFT 0.6
|
||||
#define YDRIFT 0.8f
|
||||
#define ZDRIFT 0.6f
|
||||
|
||||
void CFlakes::Init(int grade, const CControl *ctrl) {
|
||||
Reset();
|
||||
|
@ -680,8 +680,8 @@ void CFlakes::Draw(const CControl *ctrl) const {
|
|||
|
||||
#define NUM_CHANGES 6
|
||||
#define CHANGE_DRIFT 15
|
||||
#define CHANGE_SPEED 0.05
|
||||
#define CURTAIN_WINDDRIFT 0.35
|
||||
#define CHANGE_SPEED 0.05f
|
||||
#define CURTAIN_WINDDRIFT 0.35f
|
||||
|
||||
struct TChange {
|
||||
float min;
|
||||
|
@ -736,7 +736,7 @@ TCurtain::TCurtain(int num_rows, float z_dist, float tex_size,
|
|||
break;
|
||||
}
|
||||
|
||||
angledist = atan(size / 2 / zdist) * 360 / 3.14159;
|
||||
angledist = 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;
|
||||
|
@ -818,7 +818,7 @@ 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 * 3.14159 / 180);
|
||||
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);
|
||||
}
|
||||
|
@ -905,7 +905,7 @@ void CCurtain::Init(const CControl *ctrl) {
|
|||
// wind
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#define UPDATE_TIME 0.04
|
||||
#define UPDATE_TIME 0.04f
|
||||
|
||||
CWind Wind;
|
||||
|
||||
|
@ -1041,7 +1041,7 @@ void CWind::Update(float timestep) {
|
|||
// the wind needn't be updated in each frame
|
||||
CurrTime = CurrTime + timestep;
|
||||
if (CurrTime > UPDATE_TIME) {
|
||||
CurrTime = 0.0;
|
||||
CurrTime = 0.f;
|
||||
|
||||
if (SpeedMode == 1) { // current speed lesser than destination speed
|
||||
if (WSpeed < DestSpeed) {
|
||||
|
@ -1068,7 +1068,7 @@ void CWind::Update(float timestep) {
|
|||
if (WAngle > params.maxAngle) WAngle = params.maxAngle;
|
||||
if (WAngle < params.minAngle) WAngle = params.minAngle;
|
||||
|
||||
float xx = sin(WAngle * 3.14159 / 180);
|
||||
float xx = sin(WAngle * M_PI / 180.f);
|
||||
float zz = sqrt(1 - xx * xx);
|
||||
if ((WAngle > 90 && WAngle < 270) || (WAngle > 450 && WAngle < 630)) {
|
||||
zz = -zz;
|
||||
|
|
|
@ -75,7 +75,7 @@ struct TFlakeArea {
|
|||
vector<TFlake> flakes;
|
||||
|
||||
TFlakeArea(
|
||||
int num_flakes,
|
||||
size_t num_flakes,
|
||||
float xrange,
|
||||
float ytop,
|
||||
float yrange,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <climits>
|
||||
#include <cstring>
|
||||
|
||||
#define TERRAIN_ERROR_SCALE 0.1
|
||||
#define TERRAIN_ERROR_SCALE 0.1f
|
||||
#define VERTEX_FORCE_THRESHOLD 100
|
||||
#define ERROR_MAGNIFICATION_THRESHOLD 20
|
||||
#define ERROR_MAGNIFICATION_AMOUNT 3
|
||||
|
@ -77,17 +77,17 @@ quadsquare::quadsquare(quadcornerdata* pcd) {
|
|||
|
||||
for (int i = 0; i < 2; i++) SubEnabledCount[i] = 0;
|
||||
|
||||
Vertex[0].Y = 0.25 * (pcd->Verts[0].Y
|
||||
+ pcd->Verts[1].Y + pcd->Verts[2].Y + pcd->Verts[3].Y);
|
||||
Vertex[1].Y = 0.5 * (pcd->Verts[3].Y + pcd->Verts[0].Y);
|
||||
Vertex[2].Y = 0.5 * (pcd->Verts[0].Y + pcd->Verts[1].Y);
|
||||
Vertex[3].Y = 0.5 * (pcd->Verts[1].Y + pcd->Verts[2].Y);
|
||||
Vertex[4].Y = 0.5 * (pcd->Verts[2].Y + pcd->Verts[3].Y);
|
||||
Vertex[0].Y = 0.25f * (pcd->Verts[0].Y
|
||||
+ pcd->Verts[1].Y + pcd->Verts[2].Y + pcd->Verts[3].Y);
|
||||
Vertex[1].Y = 0.5f * (pcd->Verts[3].Y + pcd->Verts[0].Y);
|
||||
Vertex[2].Y = 0.5f * (pcd->Verts[0].Y + pcd->Verts[1].Y);
|
||||
Vertex[3].Y = 0.5f * (pcd->Verts[1].Y + pcd->Verts[2].Y);
|
||||
Vertex[4].Y = 0.5f * (pcd->Verts[2].Y + pcd->Verts[3].Y);
|
||||
|
||||
for (int i = 0; i < 2; i++) Error[i] = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Error[i+2] = fabs((Vertex[0].Y + pcd->Verts[i].Y)
|
||||
- (Vertex[i+1].Y + Vertex[((i+1)&3) + 1].Y)) * 0.25;
|
||||
- (Vertex[i+1].Y + Vertex[((i+1)&3) + 1].Y)) * 0.25f;
|
||||
}
|
||||
|
||||
MinY = MaxY = pcd->Verts[0].Y;
|
||||
|
@ -313,8 +313,8 @@ float quadsquare::RecomputeError(const quadcornerdata& cd) {
|
|||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
quadcornerdata q;
|
||||
if (Child[i]) {
|
||||
quadcornerdata q;
|
||||
SetupCornerData(&q, cd, i);
|
||||
Error[i+2] = Child[i]->RecomputeError(q);
|
||||
|
||||
|
@ -327,7 +327,7 @@ float quadsquare::RecomputeError(const quadcornerdata& cd) {
|
|||
if (Error[i+2] > maxerror) maxerror = Error[i+2];
|
||||
}
|
||||
|
||||
int *terrain_count = new int[numTerr];
|
||||
size_t *terrain_count = new size_t[numTerr];
|
||||
memset(terrain_count, 0, sizeof(*terrain_count)*numTerr);
|
||||
|
||||
for (int i=cd.xorg; i<=cd.xorg+whole; i++) {
|
||||
|
@ -343,8 +343,8 @@ float quadsquare::RecomputeError(const quadcornerdata& cd) {
|
|||
}
|
||||
}
|
||||
|
||||
int max_count = 0;
|
||||
int total = 0;
|
||||
size_t max_count = 0;
|
||||
size_t total = 0;
|
||||
for (size_t t=0; t<numTerr; t++) {
|
||||
if (terrain_count[t] > max_count) {
|
||||
max_count = terrain_count[t];
|
||||
|
@ -355,13 +355,13 @@ float quadsquare::RecomputeError(const quadcornerdata& cd) {
|
|||
delete [] terrain_count;
|
||||
|
||||
if (total > 0) {
|
||||
terrain_error = (1.0 - max_count / total);
|
||||
terrain_error = (1.f - ((float)max_count / (float)total));
|
||||
if (numTerr > 1) {
|
||||
terrain_error *= numTerr / (numTerr - 1.0);
|
||||
terrain_error *= numTerr / (numTerr - 1.f);
|
||||
}
|
||||
terrain_error *= whole * whole;
|
||||
terrain_error *= TERRAIN_ERROR_SCALE;
|
||||
} else terrain_error = 0;
|
||||
terrain_error *= whole * whole;
|
||||
terrain_error *= TERRAIN_ERROR_SCALE;
|
||||
|
||||
if (terrain_error > maxerror) maxerror = terrain_error;
|
||||
if (terrain_error > Error[0]) Error[0] = terrain_error;
|
||||
|
@ -419,7 +419,7 @@ void quadsquare::StaticCullAux(const quadcornerdata& cd, float ThresholdDetail,
|
|||
quadsquare* s = GetNeighbor(0, cd);
|
||||
if (s == NULL || (s->Child[1] == NULL && s->Child[2] == NULL)) {
|
||||
|
||||
float y = (cd.Verts[0].Y + cd.Verts[3].Y) * 0.5;
|
||||
float y = (cd.Verts[0].Y + cd.Verts[3].Y) * 0.5f;
|
||||
Vertex[1].Y = y;
|
||||
Error[0] = 0;
|
||||
if (s) s->Vertex[3].Y = y;
|
||||
|
@ -431,7 +431,7 @@ void quadsquare::StaticCullAux(const quadcornerdata& cd, float ThresholdDetail,
|
|||
if (Child[2] == NULL && Child[3] == NULL && Error[1] * ThresholdDetail < size) {
|
||||
quadsquare* s = GetNeighbor(3, cd);
|
||||
if (s == NULL || (s->Child[0] == NULL && s->Child[1] == NULL)) {
|
||||
float y = (cd.Verts[2].Y + cd.Verts[3].Y) * 0.5;
|
||||
float y = (cd.Verts[2].Y + cd.Verts[3].Y) * 0.5f;
|
||||
Vertex[4].Y = y;
|
||||
Error[1] = 0;
|
||||
|
||||
|
@ -452,14 +452,14 @@ void quadsquare::StaticCullAux(const quadcornerdata& cd, float ThresholdDetail,
|
|||
bool NecessaryEdges = false;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
float diff = fabs(Vertex[i+1].Y - (cd.Verts[i].Y
|
||||
+ cd.Verts[(i+3)&3].Y) * 0.5);
|
||||
if (diff > 0.00001) {
|
||||
+ cd.Verts[(i+3)&3].Y) * 0.5f);
|
||||
if (diff > 0.00001f) {
|
||||
NecessaryEdges = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NecessaryEdges) {
|
||||
size *= 1.414213562;
|
||||
size *= 1.414213562f;
|
||||
if (cd.Parent->Square->Error[2 + cd.ChildIndex] * ThresholdDetail < size) {
|
||||
delete cd.Parent->Square->Child[cd.ChildIndex];
|
||||
cd.Parent->Square->Child[cd.ChildIndex] = 0;
|
||||
|
@ -812,26 +812,22 @@ clip_result_t quadsquare::ClipSquare(const quadcornerdata& cd) {
|
|||
}
|
||||
|
||||
int whole = 2 << cd.Level;
|
||||
TVector3d min, max;
|
||||
min.x = cd.xorg * ScaleX;
|
||||
min.y = MinY;
|
||||
min.z = cd.zorg * ScaleZ;
|
||||
max.x = (cd.xorg + whole) * ScaleX;
|
||||
max.y = MaxY;
|
||||
max.z = (cd.zorg + whole) * ScaleZ;
|
||||
if (min.x > max.x) {
|
||||
double tmp = min.x;
|
||||
min.x = max.x;
|
||||
max.x = tmp;
|
||||
}
|
||||
TVector3d minimum(
|
||||
cd.xorg * ScaleX,
|
||||
MinY,
|
||||
cd.zorg * ScaleZ);
|
||||
TVector3d maximum(
|
||||
(cd.xorg + whole) * ScaleX,
|
||||
MaxY,
|
||||
(cd.zorg + whole) * ScaleZ);
|
||||
|
||||
if (min.z > max.z) {
|
||||
double tmp = min.z;
|
||||
min.z = max.z;
|
||||
max.z = tmp;
|
||||
}
|
||||
if (minimum.x > maximum.x)
|
||||
std::swap(minimum.x, maximum.x);
|
||||
|
||||
clip_result_t clip_result = clip_aabb_to_view_frustum(min, max);
|
||||
if (minimum.z > maximum.z)
|
||||
std::swap(minimum.z, maximum.z);
|
||||
|
||||
clip_result_t clip_result = clip_aabb_to_view_frustum(minimum, maximum);
|
||||
|
||||
if (clip_result == NotVisible || clip_result == SomeClip) {
|
||||
return clip_result;
|
||||
|
|
|
@ -27,7 +27,7 @@ struct TScore {
|
|||
string player;
|
||||
int points;
|
||||
int herrings;
|
||||
double time;
|
||||
float time;
|
||||
};
|
||||
|
||||
struct TScoreList {
|
||||
|
|
|
@ -48,7 +48,7 @@ void CSplashScreen::Loop(float timestep) {
|
|||
Trans.LoadTranslations(param.language); // Before first texts are being displayed
|
||||
|
||||
sf::Sprite logo(Tex.GetSFTexture(TEXLOGO));
|
||||
logo.setScale(Winsys.scale/2, Winsys.scale/2);
|
||||
logo.setScale(Winsys.scale/2.f, Winsys.scale/2.f);
|
||||
logo.setPosition((Winsys.resolution.width - logo.getTextureRect().width*(Winsys.scale / 2)) / 2, 60);
|
||||
|
||||
FT.AutoSizeN(6);
|
||||
|
|
|
@ -103,6 +103,7 @@ void DrawTrackmarks() {
|
|||
TTexture* textures[NUM_TRACK_TYPES];
|
||||
|
||||
sf::Color track_colour = colWhite;
|
||||
set_material(track_colour, colBlack, 1.0);
|
||||
ScopedRenderMode rm(TRACK_MARKS);
|
||||
|
||||
textures[TRACK_HEAD] = Tex.GetTexture(trackid1);
|
||||
|
@ -112,8 +113,10 @@ void DrawTrackmarks() {
|
|||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
for (list<track_quad_t>::const_iterator q = track_marks.quads.begin(); q != track_marks.quads.end(); ++q) {
|
||||
track_colour.a = q->alpha;
|
||||
set_material(track_colour, colBlack, 1.0);
|
||||
if (q->alpha != track_colour.a) {
|
||||
track_colour.a = q->alpha;
|
||||
set_material_diffuse(track_colour);
|
||||
}
|
||||
textures[q->track_type]->Bind();
|
||||
|
||||
if ((q->track_type == TRACK_HEAD) || (q->track_type == TRACK_TAIL)) {
|
||||
|
@ -159,8 +162,10 @@ void DrawTrackmarks() {
|
|||
++qnext;
|
||||
while (qnext != track_marks.quads.end() && qnext->track_type != TRACK_TAIL) {
|
||||
q = qnext;
|
||||
track_colour.a = q->alpha;
|
||||
set_material(track_colour, colBlack, 1.0);
|
||||
if (q->alpha != track_colour.a) {
|
||||
track_colour.a = q->alpha;
|
||||
set_material_diffuse(track_colour);
|
||||
}
|
||||
|
||||
glNormal3(q->n4);
|
||||
glTexCoord2(q->t4);
|
||||
|
|
|
@ -441,7 +441,7 @@ bool CCharShape::Load(const string& dir, const string& filename, bool with_actio
|
|||
if (SPIntN(*line, "material", 0) > 0) {
|
||||
CreateMaterial(*line);
|
||||
} else {
|
||||
float visible = SPFloatN(*line, "vis", -1.0);
|
||||
float visible = SPFloatN(*line, "vis", -1.f);
|
||||
bool shadow = SPBoolN(*line, "shad", false);
|
||||
string order = SPStrN(*line, "order");
|
||||
CreateCharNode(parent_name, node_name, name, fullname, order, shadow);
|
||||
|
|
|
@ -323,7 +323,6 @@ void SetupViewFrustum(const CControl *ctrl) {
|
|||
|
||||
double near_dist = NEAR_CLIP_DIST;
|
||||
double far_dist = param.forward_clip_distance;
|
||||
TVector3d origin(0., 0., 0.);
|
||||
double half_fov = ANGLES_TO_RADIANS(param.fov * 0.5);
|
||||
double half_fov_horiz = atan(tan(half_fov) * aspect);
|
||||
|
||||
|
@ -340,14 +339,14 @@ void SetupViewFrustum(const CControl *ctrl) {
|
|||
|
||||
for (int i=0; i<6; i++) {
|
||||
TVector3d pt = TransformPoint(ctrl->view_mat,
|
||||
origin + -frustum_planes[i].d * frustum_planes[i].nml);
|
||||
-frustum_planes[i].d * frustum_planes[i].nml);
|
||||
|
||||
frustum_planes[i].nml = TransformVector(
|
||||
ctrl->view_mat, frustum_planes[i].nml);
|
||||
|
||||
frustum_planes[i].d = -DotProduct(
|
||||
frustum_planes[i].nml,
|
||||
pt - origin);
|
||||
pt);
|
||||
}
|
||||
|
||||
for (int i=0; i<6; i++) {
|
||||
|
|
|
@ -67,10 +67,10 @@ string CWinsys::GetResName(size_t idx) const {
|
|||
return line;
|
||||
}
|
||||
|
||||
double CWinsys::CalcScreenScale() const {
|
||||
if (resolution.height < 768) return 0.78;
|
||||
else if (resolution.height == 768) return 1.0;
|
||||
else return (resolution.height / 768);
|
||||
float CWinsys::CalcScreenScale() const {
|
||||
if (resolution.height < 768) return 0.78f;
|
||||
else if (resolution.height == 768) return 1.0f;
|
||||
else return (resolution.height / 768.f);
|
||||
}
|
||||
|
||||
void CWinsys::SetupVideoMode(const TScreenRes& resolution_) {
|
||||
|
|
|
@ -39,10 +39,10 @@ private:
|
|||
bool sfmlRenders;
|
||||
TScreenRes resolutions[NUM_RESOLUTIONS];
|
||||
TScreenRes auto_resolution;
|
||||
double CalcScreenScale() const;
|
||||
float CalcScreenScale() const;
|
||||
public:
|
||||
TScreenRes resolution;
|
||||
double scale; // scale factor for screen, see 'use_quad_scale'
|
||||
float scale; // scale factor for screen, see 'use_quad_scale'
|
||||
|
||||
CWinsys();
|
||||
|
||||
|
|
Loading…
Reference in New Issue