mirror of
https://github.com/ZDoom/gzdoom-last-svn.git
synced 2025-06-04 19:20:53 +00:00
- got rid of several redundant conversion macros in the GL code. It uses the defaults from the main engine now.
- Update to ZDoom r1991: - Replaced toint/quickertoint with the portable routines from xs_Float.h. The former used fistp, which is not portable across platforms, so cannot be used in the play simulation. They were only suitable for the renderer. xs_Float.h also has a very fast float->fixed conversion, so FLOAT2FIXED uses that now. (And I also learned that the FPU's round to nearest is not the rounding I learned in grade school but actually Banker's Rounding. I had no idea.) (Also, also, the only thing that could have made quickertoint faster than toint was that it stored a 32-bit int. I never timed them, and I doubt in practice there was any real difference between the two.) git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@632 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
parent
fe0cde0692
commit
38b5ba87cd
36 changed files with 460 additions and 301 deletions
|
@ -201,13 +201,3 @@ static __forceinline SDWORD ksgn (SDWORD a)
|
||||||
else if (a > 0) return 1;
|
else if (a > 0) return 1;
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __forceinline int toint (float v)
|
|
||||||
{
|
|
||||||
return int(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static __forceinline int quickertoint (float v)
|
|
||||||
{
|
|
||||||
return int(v);
|
|
||||||
}
|
|
||||||
|
|
|
@ -23,6 +23,10 @@ typedef int64_t SQWORD;
|
||||||
typedef uint64_t QWORD;
|
typedef uint64_t QWORD;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef SDWORD int32;
|
||||||
|
typedef float real32;
|
||||||
|
typedef double real64;
|
||||||
|
|
||||||
// windef.h, included by windows.h, has its own incompatible definition
|
// windef.h, included by windows.h, has its own incompatible definition
|
||||||
// of DWORD as a long. In files that mix Doom and Windows code, you
|
// of DWORD as a long. In files that mix Doom and Windows code, you
|
||||||
// must define USE_WINDOWS_DWORD before including doomtype.h so that
|
// must define USE_WINDOWS_DWORD before including doomtype.h so that
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "gi.h"
|
#include "gi.h"
|
||||||
#include "templates.h"
|
#include "templates.h"
|
||||||
#include "v_font.h"
|
#include "v_font.h"
|
||||||
|
#include "m_fixed.h"
|
||||||
|
|
||||||
TArray<FSkillInfo> AllSkills;
|
TArray<FSkillInfo> AllSkills;
|
||||||
int DefaultSkill = -1;
|
int DefaultSkill = -1;
|
||||||
|
|
|
@ -331,27 +331,3 @@ static inline SDWORD ksgn (SDWORD a)
|
||||||
:"%cc");
|
:"%cc");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int toint (float v)
|
|
||||||
{
|
|
||||||
volatile QWORD result;
|
|
||||||
|
|
||||||
asm volatile
|
|
||||||
("fistpq %0"
|
|
||||||
:"=m" (result)
|
|
||||||
:"t" (v)
|
|
||||||
:"%st");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int quickertoint (float v)
|
|
||||||
{
|
|
||||||
volatile int result;
|
|
||||||
|
|
||||||
asm volatile
|
|
||||||
("fistpl %0"
|
|
||||||
:"=m" (result)
|
|
||||||
:"t" (v)
|
|
||||||
:"%st");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
|
@ -60,7 +60,6 @@
|
||||||
#include "gl/dynlights/gl_glow.h"
|
#include "gl/dynlights/gl_glow.h"
|
||||||
#include "gl/models/gl_models.h"
|
#include "gl/models/gl_models.h"
|
||||||
#include "gl/utility/gl_clock.h"
|
#include "gl/utility/gl_clock.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
#include "gl/gl_functions.h"
|
#include "gl/gl_functions.h"
|
||||||
|
|
||||||
|
@ -371,8 +370,8 @@ void gl_RecalcVertexHeights(vertex_t * v)
|
||||||
{
|
{
|
||||||
for(j=0;j<2;j++)
|
for(j=0;j<2;j++)
|
||||||
{
|
{
|
||||||
if (j==0) height=TO_GL(v->sectors[i]->ceilingplane.ZatPoint(v));
|
if (j==0) height=FIXED2FLOAT(v->sectors[i]->ceilingplane.ZatPoint(v));
|
||||||
else height=TO_GL(v->sectors[i]->floorplane.ZatPoint(v));
|
else height=FIXED2FLOAT(v->sectors[i]->floorplane.ZatPoint(v));
|
||||||
|
|
||||||
for(k=0;k<v->numheights;k++)
|
for(k=0;k<v->numheights;k++)
|
||||||
{
|
{
|
||||||
|
@ -472,13 +471,13 @@ CCMD(dumpgeometry)
|
||||||
if (seg->linedef)
|
if (seg->linedef)
|
||||||
{
|
{
|
||||||
Printf(" (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, linedef %d, side %d",
|
Printf(" (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, linedef %d, side %d",
|
||||||
TO_GL(seg->v1->x), TO_GL(seg->v1->y), TO_GL(seg->v2->x), TO_GL(seg->v2->y),
|
FIXED2FLOAT(seg->v1->x), FIXED2FLOAT(seg->v1->y), FIXED2FLOAT(seg->v2->x), FIXED2FLOAT(seg->v2->y),
|
||||||
seg-segs, seg->linedef-lines, seg->sidedef != seg->linedef->sidedef[0]);
|
seg-segs, seg->linedef-lines, seg->sidedef != seg->linedef->sidedef[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Printf(" (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, miniseg",
|
Printf(" (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, miniseg",
|
||||||
TO_GL(seg->v1->x), TO_GL(seg->v1->y), TO_GL(seg->v2->x), TO_GL(seg->v2->y),
|
FIXED2FLOAT(seg->v1->x), FIXED2FLOAT(seg->v1->y), FIXED2FLOAT(seg->v2->x), FIXED2FLOAT(seg->v2->y),
|
||||||
seg-segs);
|
seg-segs);
|
||||||
}
|
}
|
||||||
if (seg->PartnerSeg)
|
if (seg->PartnerSeg)
|
||||||
|
|
|
@ -59,7 +59,6 @@
|
||||||
#include "gl/dynlights/gl_dynlight.h"
|
#include "gl/dynlights/gl_dynlight.h"
|
||||||
#include "gl/dynlights/gl_glow.h"
|
#include "gl/dynlights/gl_glow.h"
|
||||||
#include "gl/utility/gl_clock.h"
|
#include "gl/utility/gl_clock.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
#include "gl/gl_functions.h"
|
#include "gl/gl_functions.h"
|
||||||
|
|
||||||
void InitGLRMapinfoData();
|
void InitGLRMapinfoData();
|
||||||
|
@ -630,7 +629,7 @@ static int STACK_ARGS segcmp(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
seg_t *A = *(seg_t**)a;
|
seg_t *A = *(seg_t**)a;
|
||||||
seg_t *B = *(seg_t**)b;
|
seg_t *B = *(seg_t**)b;
|
||||||
return quickertoint(FRACUNIT*(A->sidefrac - B->sidefrac));
|
return xs_RoundToInt(FRACUNIT*(A->sidefrac - B->sidefrac));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrepareSegs()
|
static void PrepareSegs()
|
||||||
|
@ -641,8 +640,8 @@ static void PrepareSegs()
|
||||||
// Get floatng point coordinates of vertices
|
// Get floatng point coordinates of vertices
|
||||||
for(int i = 0; i < numvertexes; i++)
|
for(int i = 0; i < numvertexes; i++)
|
||||||
{
|
{
|
||||||
vertexes[i].fx = TO_GL(vertexes[i].x);
|
vertexes[i].fx = FIXED2FLOAT(vertexes[i].x);
|
||||||
vertexes[i].fy = TO_GL(vertexes[i].y);
|
vertexes[i].fy = FIXED2FLOAT(vertexes[i].y);
|
||||||
vertexes[i].dirty = true;
|
vertexes[i].dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,7 @@ void ADynamicLight::UpdateLocation()
|
||||||
{
|
{
|
||||||
intensity = m_currentIntensity;
|
intensity = m_currentIntensity;
|
||||||
}
|
}
|
||||||
radius = TO_MAP(intensity * 2.0f * gl_lights_size);
|
radius = FLOAT2FIXED(intensity * 2.0f * gl_lights_size);
|
||||||
|
|
||||||
if (x!=oldx || y!=oldy || radius!=oldradius)
|
if (x!=oldx || y!=oldy || radius!=oldradius)
|
||||||
{
|
{
|
||||||
|
@ -492,19 +492,19 @@ float ADynamicLight::DistToSeg(seg_t *seg)
|
||||||
{
|
{
|
||||||
float u, px, py;
|
float u, px, py;
|
||||||
|
|
||||||
float seg_dx = TO_GL(seg->v2->x - seg->v1->x);
|
float seg_dx = FIXED2FLOAT(seg->v2->x - seg->v1->x);
|
||||||
float seg_dy = TO_GL(seg->v2->y - seg->v1->y);
|
float seg_dy = FIXED2FLOAT(seg->v2->y - seg->v1->y);
|
||||||
float seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy;
|
float seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy;
|
||||||
|
|
||||||
u = ( TO_GL(x - seg->v1->x) * seg_dx + TO_GL(y - seg->v1->y) * seg_dy) / seg_length_sq;
|
u = ( FIXED2FLOAT(x - seg->v1->x) * seg_dx + FIXED2FLOAT(y - seg->v1->y) * seg_dy) / seg_length_sq;
|
||||||
if (u < 0.f) u = 0.f; // clamp the test point to the line segment
|
if (u < 0.f) u = 0.f; // clamp the test point to the line segment
|
||||||
if (u > 1.f) u = 1.f;
|
if (u > 1.f) u = 1.f;
|
||||||
|
|
||||||
px = TO_GL(seg->v1->x) + (u * seg_dx);
|
px = FIXED2FLOAT(seg->v1->x) + (u * seg_dx);
|
||||||
py = TO_GL(seg->v1->y) + (u * seg_dy);
|
py = FIXED2FLOAT(seg->v1->y) + (u * seg_dy);
|
||||||
|
|
||||||
px -= TO_GL(x);
|
px -= FIXED2FLOAT(x);
|
||||||
py -= TO_GL(y);
|
py -= FIXED2FLOAT(y);
|
||||||
|
|
||||||
return (px*px) + (py*py);
|
return (px*px) + (py*py);
|
||||||
}
|
}
|
||||||
|
@ -584,7 +584,7 @@ void ADynamicLight::LinkLight()
|
||||||
subsector_t * subSec = R_PointInSubsector(x, y);
|
subsector_t * subSec = R_PointInSubsector(x, y);
|
||||||
if (subSec)
|
if (subSec)
|
||||||
{
|
{
|
||||||
float fradius = TO_GL(radius);
|
float fradius = FIXED2FLOAT(radius);
|
||||||
CollectWithinRadius(subSec, fradius*fradius);
|
CollectWithinRadius(subSec, fradius*fradius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -677,8 +677,8 @@ CCMD(listlights)
|
||||||
sectors=0;
|
sectors=0;
|
||||||
Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f ",
|
Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f ",
|
||||||
dl->target? dl->target->GetClass()->TypeName.GetChars() : dl->GetClass()->TypeName.GetChars(),
|
dl->target? dl->target->GetClass()->TypeName.GetChars() : dl->GetClass()->TypeName.GetChars(),
|
||||||
TO_GL(dl->x), TO_GL(dl->y), TO_GL(dl->z), dl->args[LIGHT_RED],
|
FIXED2FLOAT(dl->x), FIXED2FLOAT(dl->y), FIXED2FLOAT(dl->z), dl->args[LIGHT_RED],
|
||||||
dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], TO_GL(dl->radius));
|
dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], FIXED2FLOAT(dl->radius));
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (dl->target)
|
if (dl->target)
|
||||||
|
|
|
@ -53,7 +53,6 @@
|
||||||
#include "gl/scene/gl_portal.h"
|
#include "gl/scene/gl_portal.h"
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -106,9 +105,9 @@ bool gl_GetLight(Plane & p, ADynamicLight * light,
|
||||||
Vector fn, pos;
|
Vector fn, pos;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
float x = TO_GL(light->x);
|
float x = FIXED2FLOAT(light->x);
|
||||||
float y = TO_GL(light->y);
|
float y = FIXED2FLOAT(light->y);
|
||||||
float z = TO_GL(light->z);
|
float z = FIXED2FLOAT(light->z);
|
||||||
|
|
||||||
float dist = fabsf(p.DistToPoint(x, z, y));
|
float dist = fabsf(p.DistToPoint(x, z, y));
|
||||||
float radius = (light->GetRadius() * gl_lights_size);
|
float radius = (light->GetRadius() * gl_lights_size);
|
||||||
|
@ -180,9 +179,9 @@ bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & u
|
||||||
{
|
{
|
||||||
Vector fn, pos;
|
Vector fn, pos;
|
||||||
|
|
||||||
float x = TO_GL(light->x);
|
float x = FIXED2FLOAT(light->x);
|
||||||
float y = TO_GL(light->y);
|
float y = FIXED2FLOAT(light->y);
|
||||||
float z = TO_GL(light->z);
|
float z = FIXED2FLOAT(light->z);
|
||||||
|
|
||||||
float dist = fabsf(p.DistToPoint(x, z, y));
|
float dist = fabsf(p.DistToPoint(x, z, y));
|
||||||
float radius = (light->GetRadius() * gl_lights_size);
|
float radius = (light->GetRadius() * gl_lights_size);
|
||||||
|
|
|
@ -56,7 +56,6 @@
|
||||||
#include "gl/scene/gl_portal.h"
|
#include "gl/scene/gl_portal.h"
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -144,9 +143,9 @@ void FLightBuffer::CollectLightSources()
|
||||||
rgb.G = light->GetGreen();
|
rgb.G = light->GetGreen();
|
||||||
rgb.B = light->GetBlue();
|
rgb.B = light->GetBlue();
|
||||||
rgb.Type = (light->flags4 & MF4_SUBTRACTIVE)? 128 : (light->flags4 & MF4_ADDITIVE || foggy)? 255:0;
|
rgb.Type = (light->flags4 & MF4_SUBTRACTIVE)? 128 : (light->flags4 & MF4_ADDITIVE || foggy)? 255:0;
|
||||||
pos.X = TO_GL(light->x);
|
pos.X = FIXED2FLOAT(light->x);
|
||||||
pos.Y = TO_GL(light->y);
|
pos.Y = FIXED2FLOAT(light->y);
|
||||||
pos.Z = TO_GL(light->z);
|
pos.Z = FIXED2FLOAT(light->z);
|
||||||
pos.Distance = (light->GetRadius() * gl_lights_size);
|
pos.Distance = (light->GetRadius() * gl_lights_size);
|
||||||
light->bufferindex = pPos.Size();
|
light->bufferindex = pPos.Size();
|
||||||
pLights.Push(rgb);
|
pLights.Push(rgb);
|
||||||
|
|
|
@ -623,9 +623,9 @@ void gl_RenderModel(GLSprite * spr, int cm)
|
||||||
|
|
||||||
// Scaling and model space offset.
|
// Scaling and model space offset.
|
||||||
gl.Scalef(
|
gl.Scalef(
|
||||||
TO_GL(spr->actor->scaleX) * smf->xscale,
|
FIXED2FLOAT(spr->actor->scaleX) * smf->xscale,
|
||||||
TO_GL(spr->actor->scaleY) * smf->zscale, // y scale for a sprite means height, i.e. z in the world!
|
FIXED2FLOAT(spr->actor->scaleY) * smf->zscale, // y scale for a sprite means height, i.e. z in the world!
|
||||||
TO_GL(spr->actor->scaleX) * smf->yscale);
|
FIXED2FLOAT(spr->actor->scaleX) * smf->yscale);
|
||||||
|
|
||||||
// [BB] Apply zoffset here, needs to be scaled by 1 / smf->zscale, so that zoffset doesn't depend on the z-scaling.
|
// [BB] Apply zoffset here, needs to be scaled by 1 / smf->zscale, so that zoffset doesn't depend on the z-scaling.
|
||||||
gl.Translatef(0., smf->zoffset / smf->zscale, 0.);
|
gl.Translatef(0., smf->zoffset / smf->zscale, 0.);
|
||||||
|
@ -669,9 +669,9 @@ void gl_RenderModel(GLSprite * spr, int cm)
|
||||||
ModelToWorld.Rotate(0,0,1,pitch);
|
ModelToWorld.Rotate(0,0,1,pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelToWorld.Scale(TO_GL(spr->actor->scaleX) * smf->xscale,
|
ModelToWorld.Scale(FIXED2FLOAT(spr->actor->scaleX) * smf->xscale,
|
||||||
TO_GL(spr->actor->scaleY) * smf->zscale, // y scale for a sprite means height, i.e. z in the world!
|
FIXED2FLOAT(spr->actor->scaleY) * smf->zscale, // y scale for a sprite means height, i.e. z in the world!
|
||||||
TO_GL(spr->actor->scaleX) * smf->yscale);
|
FIXED2FLOAT(spr->actor->scaleX) * smf->yscale);
|
||||||
|
|
||||||
|
|
||||||
// [BB] Apply zoffset here, needs to be scaled by 1 / smf->zscale, so that zoffset doesn't depend on the z-scaling.
|
// [BB] Apply zoffset here, needs to be scaled by 1 / smf->zscale, so that zoffset doesn't depend on the z-scaling.
|
||||||
|
@ -735,8 +735,8 @@ void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy, int cm)
|
||||||
gl.Translatef(0., smf->zoffset / smf->zscale, 0.);
|
gl.Translatef(0., smf->zoffset / smf->zscale, 0.);
|
||||||
|
|
||||||
// [BB] Weapon bob, very similar to the normal Doom weapon bob.
|
// [BB] Weapon bob, very similar to the normal Doom weapon bob.
|
||||||
gl.Rotatef(TO_GL(ofsx)/4, 0, 1, 0);
|
gl.Rotatef(FIXED2FLOAT(ofsx)/4, 0, 1, 0);
|
||||||
gl.Rotatef(-TO_GL(ofsy-WEAPONTOP)/4, 1, 0, 0);
|
gl.Rotatef(-FIXED2FLOAT(ofsy-WEAPONTOP)/4, 1, 0, 0);
|
||||||
|
|
||||||
// [BB] For some reason the jDoom models need to be rotated.
|
// [BB] For some reason the jDoom models need to be rotated.
|
||||||
gl.Rotatef(90., 0, 1, 0);
|
gl.Rotatef(90., 0, 1, 0);
|
||||||
|
|
|
@ -124,7 +124,7 @@ extern Clipper clipper;
|
||||||
|
|
||||||
inline angle_t R_PointToAnglePrecise (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y)
|
inline angle_t R_PointToAnglePrecise (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y)
|
||||||
{
|
{
|
||||||
return quickertoint((float)(atan2f(float(y-viewy), float(x-viewx)) * (ANGLE_180/M_PI)));
|
return xs_RoundToUInt(atan2(double(y-viewy), double(x-viewx)) * (ANGLE_180/M_PI));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline angle_t vertex_t::GetViewAngle()
|
inline angle_t vertex_t::GetViewAngle()
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
#include "gl/textures/gl_texture.h"
|
#include "gl/textures/gl_texture.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
#include "gl/utility/gl_clock.h"
|
#include "gl/utility/gl_clock.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
|
|
||||||
struct DecalVertex
|
struct DecalVertex
|
||||||
{
|
{
|
||||||
|
@ -199,9 +198,9 @@ void GLWall::DrawDecal(DBaseDecal *actor, seg_t *seg, sector_t *frontSector, sec
|
||||||
blue = clamp<float>(result[2]+blue, 0, 1.0f);
|
blue = clamp<float>(result[2]+blue, 0, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE R = quickertoint(r * red);
|
BYTE R = xs_RoundToInt(r * red);
|
||||||
BYTE G = quickertoint(g * green);
|
BYTE G = xs_RoundToInt(g * green);
|
||||||
BYTE B = quickertoint(b * blue);
|
BYTE B = xs_RoundToInt(b * blue);
|
||||||
|
|
||||||
gl_ModifyColor(R,G,B, Colormap.colormap);
|
gl_ModifyColor(R,G,B, Colormap.colormap);
|
||||||
|
|
||||||
|
@ -219,13 +218,13 @@ void GLWall::DrawDecal(DBaseDecal *actor, seg_t *seg, sector_t *frontSector, sec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
a = TO_GL(actor->Alpha);
|
a = FIXED2FLOAT(actor->Alpha);
|
||||||
|
|
||||||
// now clip the decal to the actual polygon
|
// now clip the decal to the actual polygon
|
||||||
float decalwidth = tex->TextureWidth(GLUSE_PATCH) * TO_GL(actor->ScaleX);
|
float decalwidth = tex->TextureWidth(GLUSE_PATCH) * FIXED2FLOAT(actor->ScaleX);
|
||||||
float decalheight= tex->TextureHeight(GLUSE_PATCH) * TO_GL(actor->ScaleY);
|
float decalheight= tex->TextureHeight(GLUSE_PATCH) * FIXED2FLOAT(actor->ScaleY);
|
||||||
float decallefto = tex->GetLeftOffset(GLUSE_PATCH) * TO_GL(actor->ScaleX);
|
float decallefto = tex->GetLeftOffset(GLUSE_PATCH) * FIXED2FLOAT(actor->ScaleX);
|
||||||
float decaltopo = tex->GetTopOffset(GLUSE_PATCH) * TO_GL(actor->ScaleY);
|
float decaltopo = tex->GetTopOffset(GLUSE_PATCH) * FIXED2FLOAT(actor->ScaleY);
|
||||||
|
|
||||||
|
|
||||||
float leftedge = glseg.fracleft * side->TexelLength;
|
float leftedge = glseg.fracleft * side->TexelLength;
|
||||||
|
@ -276,12 +275,12 @@ void GLWall::DrawDecal(DBaseDecal *actor, seg_t *seg, sector_t *frontSector, sec
|
||||||
|
|
||||||
const PatchTextureInfo * pti=tex->BindPatch(p.colormap, actor->Translation);
|
const PatchTextureInfo * pti=tex->BindPatch(p.colormap, actor->Translation);
|
||||||
|
|
||||||
dv[1].z=dv[2].z = TO_GL(zpos);
|
dv[1].z=dv[2].z = FIXED2FLOAT(zpos);
|
||||||
dv[0].z=dv[3].z = dv[1].z - decalheight;
|
dv[0].z=dv[3].z = dv[1].z - decalheight;
|
||||||
dv[1].v=dv[2].v=pti->GetVT();
|
dv[1].v=dv[2].v=pti->GetVT();
|
||||||
|
|
||||||
dv[1].u=dv[0].u=pti->GetU(lefttex / TO_GL(actor->ScaleX));
|
dv[1].u=dv[0].u=pti->GetU(lefttex / FIXED2FLOAT(actor->ScaleX));
|
||||||
dv[3].u=dv[2].u=pti->GetU(righttex / TO_GL(actor->ScaleX));
|
dv[3].u=dv[2].u=pti->GetU(righttex / FIXED2FLOAT(actor->ScaleX));
|
||||||
dv[0].v=dv[3].v=pti->GetVB();
|
dv[0].v=dv[3].v=pti->GetVB();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@
|
||||||
#include "gl/renderer/gl_renderstate.h"
|
#include "gl/renderer/gl_renderstate.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
#include "gl/utility/gl_clock.h"
|
#include "gl/utility/gl_clock.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
#include "gl/utility/gl_templates.h"
|
#include "gl/utility/gl_templates.h"
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
|
|
||||||
|
@ -309,7 +308,7 @@ void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort)
|
||||||
GLWall * ws=&walls[drawitems[sort->itemindex].index];
|
GLWall * ws=&walls[drawitems[sort->itemindex].index];
|
||||||
GLWall * ws1;
|
GLWall * ws1;
|
||||||
|
|
||||||
bool ceiling = fh->z > TO_GL(viewz);
|
bool ceiling = fh->z > FIXED2FLOAT(viewz);
|
||||||
|
|
||||||
|
|
||||||
if (ws->ztop[0]>fh->z && ws->zbottom[0]<fh->z)
|
if (ws->ztop[0]>fh->z && ws->zbottom[0]<fh->z)
|
||||||
|
@ -368,7 +367,7 @@ void GLDrawList::SortSpriteIntoPlane(SortNode * head,SortNode * sort)
|
||||||
GLSprite * ss=&sprites[drawitems[sort->itemindex].index];
|
GLSprite * ss=&sprites[drawitems[sort->itemindex].index];
|
||||||
GLSprite * ss1;
|
GLSprite * ss1;
|
||||||
|
|
||||||
bool ceiling = fh->z > TO_GL(viewz);
|
bool ceiling = fh->z > FIXED2FLOAT(viewz);
|
||||||
|
|
||||||
if (ss->z1>fh->z && ss->z2<fh->z)
|
if (ss->z1>fh->z && ss->z2<fh->z)
|
||||||
{
|
{
|
||||||
|
@ -1063,9 +1062,9 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo
|
||||||
gl_SetFog(lightlevel, rel, &Colormap, false);
|
gl_SetFog(lightlevel, rel, &Colormap, false);
|
||||||
gltexture->Bind(Colormap.colormap);
|
gltexture->Bind(Colormap.colormap);
|
||||||
|
|
||||||
float fviewx = TO_GL(viewx);
|
float fviewx = FIXED2FLOAT(viewx);
|
||||||
float fviewy = TO_GL(viewy);
|
float fviewy = FIXED2FLOAT(viewy);
|
||||||
float fviewz = TO_GL(viewz);
|
float fviewz = FIXED2FLOAT(viewz);
|
||||||
|
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
|
|
||||||
|
@ -1142,13 +1141,13 @@ void FDrawInfo::FloodUpperGap(seg_t * seg)
|
||||||
v2=seg->linedef->v1;
|
v2=seg->linedef->v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.x1= TO_GL(v1->x);
|
ws.x1= FIXED2FLOAT(v1->x);
|
||||||
ws.y1= TO_GL(v1->y);
|
ws.y1= FIXED2FLOAT(v1->y);
|
||||||
ws.x2= TO_GL(v2->x);
|
ws.x2= FIXED2FLOAT(v2->x);
|
||||||
ws.y2= TO_GL(v2->y);
|
ws.y2= FIXED2FLOAT(v2->y);
|
||||||
|
|
||||||
ws.z1= TO_GL(frontz);
|
ws.z1= FIXED2FLOAT(frontz);
|
||||||
ws.z2= TO_GL(backz);
|
ws.z2= FIXED2FLOAT(backz);
|
||||||
|
|
||||||
// Step1: Draw a stencil into the gap
|
// Step1: Draw a stencil into the gap
|
||||||
SetupFloodStencil(&ws);
|
SetupFloodStencil(&ws);
|
||||||
|
@ -1195,13 +1194,13 @@ void FDrawInfo::FloodLowerGap(seg_t * seg)
|
||||||
v2=seg->linedef->v1;
|
v2=seg->linedef->v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.x1= TO_GL(v1->x);
|
ws.x1= FIXED2FLOAT(v1->x);
|
||||||
ws.y1= TO_GL(v1->y);
|
ws.y1= FIXED2FLOAT(v1->y);
|
||||||
ws.x2= TO_GL(v2->x);
|
ws.x2= FIXED2FLOAT(v2->x);
|
||||||
ws.y2= TO_GL(v2->y);
|
ws.y2= FIXED2FLOAT(v2->y);
|
||||||
|
|
||||||
ws.z2= TO_GL(frontz);
|
ws.z2= FIXED2FLOAT(frontz);
|
||||||
ws.z1= TO_GL(backz);
|
ws.z1= FIXED2FLOAT(backz);
|
||||||
|
|
||||||
// Step1: Draw a stencil into the gap
|
// Step1: Draw a stencil into the gap
|
||||||
SetupFloodStencil(&ws);
|
SetupFloodStencil(&ws);
|
||||||
|
|
|
@ -78,11 +78,11 @@ bool gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte
|
||||||
gltexture->TextureHeight(GLUSE_TEXTURE) != 64 ||
|
gltexture->TextureHeight(GLUSE_TEXTURE) != 64 ||
|
||||||
(gl.flags & RFL_ATI)) // for some reason skipping this does not work on ATI...
|
(gl.flags & RFL_ATI)) // for some reason skipping this does not work on ATI...
|
||||||
{
|
{
|
||||||
float uoffs=TO_GL(secplane->xoffs)/gltexture->TextureWidth(GLUSE_TEXTURE);
|
float uoffs=FIXED2FLOAT(secplane->xoffs)/gltexture->TextureWidth(GLUSE_TEXTURE);
|
||||||
float voffs=TO_GL(secplane->yoffs)/gltexture->TextureHeight(GLUSE_TEXTURE);
|
float voffs=FIXED2FLOAT(secplane->yoffs)/gltexture->TextureHeight(GLUSE_TEXTURE);
|
||||||
|
|
||||||
float xscale1=TO_GL(secplane->xscale);
|
float xscale1=FIXED2FLOAT(secplane->xscale);
|
||||||
float yscale1=TO_GL(secplane->yscale);
|
float yscale1=FIXED2FLOAT(secplane->yscale);
|
||||||
|
|
||||||
float angle=-ANGLE_TO_FLOAT(secplane->angle);
|
float angle=-ANGLE_TO_FLOAT(secplane->angle);
|
||||||
|
|
||||||
|
@ -600,7 +600,7 @@ void GLFlat::ProcessSector(sector_t * frontsector, subsector_t * sub)
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
if (((*srf)&SSRF_RENDERFLOOR) || frontsector->floorplane.ZatPoint(TO_GL(viewx), TO_GL(viewy)) <= TO_GL(viewz))
|
if (((*srf)&SSRF_RENDERFLOOR) || frontsector->floorplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) <= FIXED2FLOAT(viewz))
|
||||||
{
|
{
|
||||||
gl_drawinfo->ss_renderflags[sub-subsectors]|=SSRF_RENDERFLOOR;
|
gl_drawinfo->ss_renderflags[sub-subsectors]|=SSRF_RENDERFLOOR;
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ void GLFlat::ProcessSector(sector_t * frontsector, subsector_t * sub)
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
if (((*srf)&SSRF_RENDERCEILING) || frontsector->ceilingplane.ZatPoint(TO_GL(viewx), TO_GL(viewy)) >= TO_GL(viewz))
|
if (((*srf)&SSRF_RENDERCEILING) || frontsector->ceilingplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) >= FIXED2FLOAT(viewz))
|
||||||
{
|
{
|
||||||
gl_drawinfo->ss_renderflags[sub-subsectors]|=SSRF_RENDERCEILING;
|
gl_drawinfo->ss_renderflags[sub-subsectors]|=SSRF_RENDERCEILING;
|
||||||
|
|
||||||
|
@ -727,7 +727,7 @@ void GLFlat::ProcessSector(sector_t * frontsector, subsector_t * sub)
|
||||||
fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector));
|
fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector));
|
||||||
if (ff_top<lastceilingheight)
|
if (ff_top<lastceilingheight)
|
||||||
{
|
{
|
||||||
if (TO_GL(viewz) <= rover->top.plane->ZatPoint(TO_GL(viewx), TO_GL(viewy)))
|
if (FIXED2FLOAT(viewz) <= rover->top.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)))
|
||||||
{
|
{
|
||||||
SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG));
|
SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG));
|
||||||
Colormap.FadeColor=frontsector->ColorMap->Fade;
|
Colormap.FadeColor=frontsector->ColorMap->Fade;
|
||||||
|
@ -741,7 +741,7 @@ void GLFlat::ProcessSector(sector_t * frontsector, subsector_t * sub)
|
||||||
fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector));
|
fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector));
|
||||||
if (ff_bottom<lastceilingheight)
|
if (ff_bottom<lastceilingheight)
|
||||||
{
|
{
|
||||||
if (TO_GL(viewz)<=rover->bottom.plane->ZatPoint(TO_GL(viewx), TO_GL(viewy)))
|
if (FIXED2FLOAT(viewz)<=rover->bottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)))
|
||||||
{
|
{
|
||||||
SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG));
|
SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG));
|
||||||
Colormap.FadeColor=frontsector->ColorMap->Fade;
|
Colormap.FadeColor=frontsector->ColorMap->Fade;
|
||||||
|
@ -767,7 +767,7 @@ void GLFlat::ProcessSector(sector_t * frontsector, subsector_t * sub)
|
||||||
fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector));
|
fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector));
|
||||||
if (ff_bottom>lastfloorheight || (rover->flags&FF_FIX))
|
if (ff_bottom>lastfloorheight || (rover->flags&FF_FIX))
|
||||||
{
|
{
|
||||||
if (TO_GL(viewz) >= rover->bottom.plane->ZatPoint(TO_GL(viewx), TO_GL(viewy)))
|
if (FIXED2FLOAT(viewz) >= rover->bottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)))
|
||||||
{
|
{
|
||||||
SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG));
|
SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG));
|
||||||
Colormap.FadeColor=frontsector->ColorMap->Fade;
|
Colormap.FadeColor=frontsector->ColorMap->Fade;
|
||||||
|
@ -788,7 +788,7 @@ void GLFlat::ProcessSector(sector_t * frontsector, subsector_t * sub)
|
||||||
fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector));
|
fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector));
|
||||||
if (ff_top>lastfloorheight)
|
if (ff_top>lastfloorheight)
|
||||||
{
|
{
|
||||||
if (TO_GL(viewz) >= rover->top.plane->ZatPoint(TO_GL(viewx), TO_GL(viewy)))
|
if (FIXED2FLOAT(viewz) >= rover->top.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)))
|
||||||
{
|
{
|
||||||
SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG));
|
SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG));
|
||||||
Colormap.FadeColor=frontsector->ColorMap->Fade;
|
Colormap.FadeColor=frontsector->ColorMap->Fade;
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
#include "gl/utility/gl_clock.h"
|
#include "gl/utility/gl_clock.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
#include "gl/utility/gl_templates.h"
|
#include "gl/utility/gl_templates.h"
|
||||||
#include "gl/utility/gl_geometric.h"
|
#include "gl/utility/gl_geometric.h"
|
||||||
|
|
||||||
|
@ -309,10 +308,10 @@ inline void GLPortal::ClearClipper()
|
||||||
for(unsigned int i=0;i<lines.Size();i++)
|
for(unsigned int i=0;i<lines.Size();i++)
|
||||||
{
|
{
|
||||||
angle_t startAngle = R_PointToAnglePrecise(savedviewx, savedviewy,
|
angle_t startAngle = R_PointToAnglePrecise(savedviewx, savedviewy,
|
||||||
TO_MAP(lines[i].glseg.x2), TO_MAP(lines[i].glseg.y2));
|
FLOAT2FIXED(lines[i].glseg.x2), FLOAT2FIXED(lines[i].glseg.y2));
|
||||||
|
|
||||||
angle_t endAngle = R_PointToAnglePrecise(savedviewx, savedviewy,
|
angle_t endAngle = R_PointToAnglePrecise(savedviewx, savedviewy,
|
||||||
TO_MAP(lines[i].glseg.x1), TO_MAP(lines[i].glseg.y1));
|
FLOAT2FIXED(lines[i].glseg.x1), FLOAT2FIXED(lines[i].glseg.y1));
|
||||||
|
|
||||||
if (startAngle-endAngle>0)
|
if (startAngle-endAngle>0)
|
||||||
{
|
{
|
||||||
|
@ -673,8 +672,8 @@ void GLPlaneMirrorPortal::DrawContents()
|
||||||
|
|
||||||
gl.Enable(GL_CLIP_PLANE0+renderdepth);
|
gl.Enable(GL_CLIP_PLANE0+renderdepth);
|
||||||
// This only works properly for non-sloped planes so don't bother with the math.
|
// This only works properly for non-sloped planes so don't bother with the math.
|
||||||
//double d[4]={origin->a/65536., origin->c/65536., origin->b/65536., TO_GL(origin->d)};
|
//double d[4]={origin->a/65536., origin->c/65536., origin->b/65536., FIXED2FLOAT(origin->d)};
|
||||||
double d[4]={0, PlaneMirrorMode, 0, TO_GL(origin->d)};
|
double d[4]={0, PlaneMirrorMode, 0, FIXED2FLOAT(origin->d)};
|
||||||
gl.ClipPlane(GL_CLIP_PLANE0+renderdepth, d);
|
gl.ClipPlane(GL_CLIP_PLANE0+renderdepth, d);
|
||||||
|
|
||||||
GLRenderer->DrawScene();
|
GLRenderer->DrawScene();
|
||||||
|
@ -738,25 +737,25 @@ void GLMirrorPortal::DrawContents()
|
||||||
{
|
{
|
||||||
// any mirror--use floats to avoid integer overflow
|
// any mirror--use floats to avoid integer overflow
|
||||||
|
|
||||||
float dx = TO_GL(v2->x - v1->x);
|
float dx = FIXED2FLOAT(v2->x - v1->x);
|
||||||
float dy = TO_GL(v2->y - v1->y);
|
float dy = FIXED2FLOAT(v2->y - v1->y);
|
||||||
float x1 = TO_GL(v1->x);
|
float x1 = FIXED2FLOAT(v1->x);
|
||||||
float y1 = TO_GL(v1->y);
|
float y1 = FIXED2FLOAT(v1->y);
|
||||||
float x = TO_GL(startx);
|
float x = FIXED2FLOAT(startx);
|
||||||
float y = TO_GL(starty);
|
float y = FIXED2FLOAT(starty);
|
||||||
|
|
||||||
// the above two cases catch len == 0
|
// the above two cases catch len == 0
|
||||||
float r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy);
|
float r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy);
|
||||||
|
|
||||||
viewx = TO_MAP((x1 + r * dx)*2 - x);
|
viewx = FLOAT2FIXED((x1 + r * dx)*2 - x);
|
||||||
viewy = TO_MAP((y1 + r * dy)*2 - y);
|
viewy = FLOAT2FIXED((y1 + r * dy)*2 - y);
|
||||||
|
|
||||||
// Compensation for reendering inaccuracies
|
// Compensation for reendering inaccuracies
|
||||||
FVector2 v(-dx, dy);
|
FVector2 v(-dx, dy);
|
||||||
v.MakeUnit();
|
v.MakeUnit();
|
||||||
|
|
||||||
viewx+= TO_MAP(v[1] * renderdepth / 2);
|
viewx+= FLOAT2FIXED(v[1] * renderdepth / 2);
|
||||||
viewy+= TO_MAP(v[0] * renderdepth / 2);
|
viewy+= FLOAT2FIXED(v[0] * renderdepth / 2);
|
||||||
}
|
}
|
||||||
viewangle = 2*R_PointToAnglePrecise (GLRenderer->mirrorline->v1->x, GLRenderer->mirrorline->v1->y,
|
viewangle = 2*R_PointToAnglePrecise (GLRenderer->mirrorline->v1->x, GLRenderer->mirrorline->v1->y,
|
||||||
GLRenderer->mirrorline->v2->x, GLRenderer->mirrorline->v2->y) - startang;
|
GLRenderer->mirrorline->v2->x, GLRenderer->mirrorline->v2->y) - startang;
|
||||||
|
@ -828,7 +827,7 @@ void GLHorizonPortal::DrawContents()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
z=TO_GL(sp->texheight);
|
z=FIXED2FLOAT(sp->texheight);
|
||||||
|
|
||||||
|
|
||||||
if (gltexture && gltexture->tex->isFullbright())
|
if (gltexture && gltexture->tex->isFullbright())
|
||||||
|
@ -854,8 +853,8 @@ void GLHorizonPortal::DrawContents()
|
||||||
|
|
||||||
bool pushed = gl_SetPlaneTextureRotation(sp, gltexture);
|
bool pushed = gl_SetPlaneTextureRotation(sp, gltexture);
|
||||||
|
|
||||||
float vx=TO_GL(viewx);
|
float vx=FIXED2FLOAT(viewx);
|
||||||
float vy=TO_GL(viewy);
|
float vy=FIXED2FLOAT(viewy);
|
||||||
|
|
||||||
// Draw to some far away boundary
|
// Draw to some far away boundary
|
||||||
for(float x=-32768+vx; x<32768+vx; x+=4096)
|
for(float x=-32768+vx; x<32768+vx; x+=4096)
|
||||||
|
@ -881,7 +880,7 @@ void GLHorizonPortal::DrawContents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float vz=TO_GL(viewz);
|
float vz=FIXED2FLOAT(viewz);
|
||||||
float tz=(z-vz);///64.0f;
|
float tz=(z-vz);///64.0f;
|
||||||
|
|
||||||
// fill the gap between the polygon and the true horizon
|
// fill the gap between the polygon and the true horizon
|
||||||
|
|
|
@ -112,7 +112,7 @@ angle_t FGLRenderer::FrustumAngle()
|
||||||
// ok, this is a gross hack that barely works...
|
// ok, this is a gross hack that barely works...
|
||||||
// but at least it doesn't overestimate too much...
|
// but at least it doesn't overestimate too much...
|
||||||
double floatangle=2.0+(45.0+((tilt/1.9)))*mCurrentFoV*48.0/BaseRatioSizes[WidescreenRatio][3]/90.0;
|
double floatangle=2.0+(45.0+((tilt/1.9)))*mCurrentFoV*48.0/BaseRatioSizes[WidescreenRatio][3]/90.0;
|
||||||
angle_t a1 = ANGLE_1*toint(floatangle);
|
angle_t a1 = FLOAT_TO_ANGLE(floatangle);
|
||||||
if (a1>=ANGLE_180) return 0xffffffff;
|
if (a1>=ANGLE_180) return 0xffffffff;
|
||||||
return a1;
|
return a1;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ void FGLRenderer::SetCameraPos(fixed_t viewx, fixed_t viewy, fixed_t viewz, angl
|
||||||
|
|
||||||
mAngles.Yaw = 270.0f-fviewangle;
|
mAngles.Yaw = 270.0f-fviewangle;
|
||||||
mViewVector = FVector2(cos(DEG2RAD(fviewangle)), sin(DEG2RAD(fviewangle)));
|
mViewVector = FVector2(cos(DEG2RAD(fviewangle)), sin(DEG2RAD(fviewangle)));
|
||||||
mCameraPos = FVector3(TO_GL(viewx), TO_GL(viewy), TO_GL(viewz));
|
mCameraPos = FVector3(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ void FGLRenderer::RenderScene(int recursion)
|
||||||
|
|
||||||
if (!gl_no_skyclear) GLPortal::RenderFirstSkyPortal(recursion);
|
if (!gl_no_skyclear) GLPortal::RenderFirstSkyPortal(recursion);
|
||||||
|
|
||||||
gl_RenderState.SetCameraPos(TO_GL(viewx), TO_GL(viewy), TO_GL(viewz));
|
gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz));
|
||||||
|
|
||||||
gl_RenderState.EnableFog(true);
|
gl_RenderState.EnableFog(true);
|
||||||
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
|
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
|
||||||
|
@ -522,7 +522,7 @@ void FGLRenderer::RenderTranslucent()
|
||||||
RenderAll.Clock();
|
RenderAll.Clock();
|
||||||
|
|
||||||
gl.DepthMask(false);
|
gl.DepthMask(false);
|
||||||
gl_RenderState.SetCameraPos(TO_GL(viewx), TO_GL(viewy), TO_GL(viewz));
|
gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz));
|
||||||
|
|
||||||
// final pass: translucent stuff
|
// final pass: translucent stuff
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_sprite_threshold);
|
gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_sprite_threshold);
|
||||||
|
|
|
@ -71,8 +71,8 @@ void GLWall::MirrorPlane(secplane_t * plane, bool ceiling)
|
||||||
{
|
{
|
||||||
if (!(gl.flags&RFL_NOSTENCIL))
|
if (!(gl.flags&RFL_NOSTENCIL))
|
||||||
{
|
{
|
||||||
if (ceiling && TO_GL(viewz) >= plane->ZatPoint(TO_GL(viewx), TO_GL(viewy))) return;
|
if (ceiling && FIXED2FLOAT(viewz) >= plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) return;
|
||||||
if (!ceiling && TO_GL(viewz) <= plane->ZatPoint(TO_GL(viewx), TO_GL(viewy))) return;
|
if (!ceiling && FIXED2FLOAT(viewz) <= plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) return;
|
||||||
type=RENDERWALL_PLANEMIRROR;
|
type=RENDERWALL_PLANEMIRROR;
|
||||||
planemirror=plane;
|
planemirror=plane;
|
||||||
PutWall(0);
|
PutWall(0);
|
||||||
|
@ -136,7 +136,7 @@ void GLWall::SkyTexture(int sky1,ASkyViewpoint * skyboxx, bool ceiling)
|
||||||
if (!skyinfo.texture[0] || skyinfo.texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky;
|
if (!skyinfo.texture[0] || skyinfo.texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky;
|
||||||
skyinfo.skytexno1 = texno;
|
skyinfo.skytexno1 = texno;
|
||||||
skyinfo.x_offset[0] = ANGLE_TO_FLOAT(s->GetTextureXOffset(pos));
|
skyinfo.x_offset[0] = ANGLE_TO_FLOAT(s->GetTextureXOffset(pos));
|
||||||
skyinfo.y_offset = TO_GL(s->GetTextureYOffset(pos));
|
skyinfo.y_offset = FIXED2FLOAT(s->GetTextureYOffset(pos));
|
||||||
skyinfo.mirrored = !l->args[2];
|
skyinfo.mirrored = !l->args[2];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -246,8 +246,8 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
zbottom[0]=TO_GL(bs->ceilingplane.ZatPoint(v1));
|
zbottom[0]=FIXED2FLOAT(bs->ceilingplane.ZatPoint(v1));
|
||||||
zbottom[1]=TO_GL(bs->ceilingplane.ZatPoint(v2));
|
zbottom[1]=FIXED2FLOAT(bs->ceilingplane.ZatPoint(v2));
|
||||||
flags|=GLWF_SKYHACK; // mid textures on such lines need special treatment!
|
flags|=GLWF_SKYHACK; // mid textures on such lines need special treatment!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,8 +263,8 @@ void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex
|
||||||
fixed_t fsc2=fs->ceilingplane.ZatPoint(v2);
|
fixed_t fsc2=fs->ceilingplane.ZatPoint(v2);
|
||||||
|
|
||||||
ztop[0]=ztop[1]=32768.0f;
|
ztop[0]=ztop[1]=32768.0f;
|
||||||
zbottom[0]=TO_GL(fsc1);
|
zbottom[0]=FIXED2FLOAT(fsc1);
|
||||||
zbottom[1]=TO_GL(fsc2);
|
zbottom[1]=FIXED2FLOAT(fsc2);
|
||||||
if (ceilingsky) SkyTexture(fs->sky,fs->CeilingSkyBox, true);
|
if (ceilingsky) SkyTexture(fs->sky,fs->CeilingSkyBox, true);
|
||||||
else MirrorPlane(&fs->ceilingplane, true);
|
else MirrorPlane(&fs->ceilingplane, true);
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Special hack for Vrack2b
|
// Special hack for Vrack2b
|
||||||
if (bs->floorplane.ZatPoint(TO_GL(viewx), TO_GL(viewy)) > TO_GL(viewz)) return;
|
if (bs->floorplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) > FIXED2FLOAT(viewz)) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zbottom[0]=zbottom[1]=-32768.0f;
|
zbottom[0]=zbottom[1]=-32768.0f;
|
||||||
|
@ -310,8 +310,8 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ztop[0]=TO_GL(bs->floorplane.ZatPoint(v1));
|
ztop[0]=FIXED2FLOAT(bs->floorplane.ZatPoint(v1));
|
||||||
ztop[1]=TO_GL(bs->floorplane.ZatPoint(v2));
|
ztop[1]=FIXED2FLOAT(bs->floorplane.ZatPoint(v2));
|
||||||
flags|=GLWF_SKYHACK; // mid textures on such lines need special treatment!
|
flags|=GLWF_SKYHACK; // mid textures on such lines need special treatment!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,8 +327,8 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver
|
||||||
fixed_t fsc2=fs->floorplane.ZatPoint(v2);
|
fixed_t fsc2=fs->floorplane.ZatPoint(v2);
|
||||||
|
|
||||||
zbottom[0]=zbottom[1]=-32768.0f;
|
zbottom[0]=zbottom[1]=-32768.0f;
|
||||||
ztop[0]=TO_GL(fsc1);
|
ztop[0]=FIXED2FLOAT(fsc1);
|
||||||
ztop[1]=TO_GL(fsc2);
|
ztop[1]=FIXED2FLOAT(fsc2);
|
||||||
|
|
||||||
if (floorsky) SkyTexture(fs->sky,fs->FloorSkyBox, false);
|
if (floorsky) SkyTexture(fs->sky,fs->FloorSkyBox, false);
|
||||||
else MirrorPlane(&fs->floorplane, false);
|
else MirrorPlane(&fs->floorplane, false);
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
#include "gl/textures/gl_texture.h"
|
#include "gl/textures/gl_texture.h"
|
||||||
#include "gl/textures/gl_skyboxtexture.h"
|
#include "gl/textures/gl_skyboxtexture.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -129,9 +128,9 @@ static void SkyVertex(int r, int c)
|
||||||
}
|
}
|
||||||
if (r != 4) y+=FRACUNIT*300;
|
if (r != 4) y+=FRACUNIT*300;
|
||||||
// And finally the vertex.
|
// And finally the vertex.
|
||||||
fx =-TO_GL(x); // Doom mirrors the sky vertically!
|
fx =-FIXED2FLOAT(x); // Doom mirrors the sky vertically!
|
||||||
fy = TO_GL(y);
|
fy = FIXED2FLOAT(y);
|
||||||
fz = TO_GL(z);
|
fz = FIXED2FLOAT(z);
|
||||||
gl.Vertex3f(fx, fy - 1.f, fz);
|
gl.Vertex3f(fx, fy - 1.f, fz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
#include "gl/utility/gl_clock.h"
|
#include "gl/utility/gl_clock.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
|
|
||||||
CVAR(Bool, gl_usecolorblending, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR(Bool, gl_usecolorblending, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
CVAR(Bool, gl_sprite_blend, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
CVAR(Bool, gl_sprite_blend, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||||
|
@ -146,8 +145,8 @@ void GLSprite::Draw(int pass)
|
||||||
// fog + fuzz don't work well without some fiddling with the alpha value!
|
// fog + fuzz don't work well without some fiddling with the alpha value!
|
||||||
if (!gl_isBlack(Colormap.FadeColor))
|
if (!gl_isBlack(Colormap.FadeColor))
|
||||||
{
|
{
|
||||||
float xcamera=TO_GL(viewx);
|
float xcamera=FIXED2FLOAT(viewx);
|
||||||
float ycamera=TO_GL(viewy);
|
float ycamera=FIXED2FLOAT(viewy);
|
||||||
|
|
||||||
float dist=Dist2(xcamera,ycamera, x,y);
|
float dist=Dist2(xcamera,ycamera, x,y);
|
||||||
|
|
||||||
|
@ -224,7 +223,7 @@ void GLSprite::Draw(int pass)
|
||||||
float xcenter = (x1+x2)*0.5;
|
float xcenter = (x1+x2)*0.5;
|
||||||
float ycenter = (y1+y2)*0.5;
|
float ycenter = (y1+y2)*0.5;
|
||||||
float zcenter = (z1+z2)*0.5;
|
float zcenter = (z1+z2)*0.5;
|
||||||
float angleRad = FLOAT_TO_RAD(270. - GLRenderer->mAngles.Yaw);
|
float angleRad = DEG2RAD(270. - float(GLRenderer->mAngles.Yaw));
|
||||||
|
|
||||||
Matrix3x4 mat;
|
Matrix3x4 mat;
|
||||||
mat.MakeIdentity();
|
mat.MakeIdentity();
|
||||||
|
@ -351,8 +350,8 @@ void GLSprite::SplitSprite(sector_t * frontsector, bool translucent)
|
||||||
if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor->x,actor->y);
|
if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor->x,actor->y);
|
||||||
else lightbottom=frontsector->floorplane.ZatPoint(actor->x,actor->y);
|
else lightbottom=frontsector->floorplane.ZatPoint(actor->x,actor->y);
|
||||||
|
|
||||||
//maplighttop=TO_GL(lightlist[i].height);
|
//maplighttop=FIXED2FLOAT(lightlist[i].height);
|
||||||
maplightbottom=TO_GL(lightbottom);
|
maplightbottom=FIXED2FLOAT(lightbottom);
|
||||||
if (maplightbottom<z2) maplightbottom=z2;
|
if (maplightbottom<z2) maplightbottom=z2;
|
||||||
|
|
||||||
if (maplightbottom<z1)
|
if (maplightbottom<z1)
|
||||||
|
@ -400,8 +399,8 @@ void GLSprite::SetSpriteColor(sector_t *sector, fixed_t center_y)
|
||||||
if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor->x,actor->y);
|
if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor->x,actor->y);
|
||||||
else lightbottom=sector->floorplane.ZatPoint(actor->x,actor->y);
|
else lightbottom=sector->floorplane.ZatPoint(actor->x,actor->y);
|
||||||
|
|
||||||
//maplighttop=TO_GL(lightlist[i].height);
|
//maplighttop=FIXED2FLOAT(lightlist[i].height);
|
||||||
maplightbottom=TO_GL(lightbottom);
|
maplightbottom=FIXED2FLOAT(lightbottom);
|
||||||
if (maplightbottom<z2) maplightbottom=z2;
|
if (maplightbottom<z2) maplightbottom=z2;
|
||||||
|
|
||||||
if (maplightbottom<center_y)
|
if (maplightbottom<center_y)
|
||||||
|
@ -494,9 +493,9 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
x = TO_GL(thingx);
|
x = FIXED2FLOAT(thingx);
|
||||||
z = TO_GL(thingz-thing->floorclip);
|
z = FIXED2FLOAT(thingz-thing->floorclip);
|
||||||
y = TO_GL(thingy);
|
y = FIXED2FLOAT(thingy);
|
||||||
|
|
||||||
modelframe = gl_FindModelFrame(RUNTIME_TYPE(thing), thing->sprite, thing->frame /*, thing->state*/);
|
modelframe = gl_FindModelFrame(RUNTIME_TYPE(thing), thing->sprite, thing->frame /*, thing->state*/);
|
||||||
if (!modelframe)
|
if (!modelframe)
|
||||||
|
@ -525,7 +524,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
||||||
ul=pti->GetUR();
|
ul=pti->GetUR();
|
||||||
ur=pti->GetUL();
|
ur=pti->GetUL();
|
||||||
}
|
}
|
||||||
r.Scale(TO_GL(thing->scaleX),TO_GL(thing->scaleY));
|
r.Scale(FIXED2FLOAT(thing->scaleX),FIXED2FLOAT(thing->scaleY));
|
||||||
|
|
||||||
float rightfac=-r.left;
|
float rightfac=-r.left;
|
||||||
float leftfac=rightfac-r.width;
|
float leftfac=rightfac-r.width;
|
||||||
|
@ -550,7 +549,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
||||||
fixed_t floorh=ff->top.plane->ZatPoint(thingx, thingy);
|
fixed_t floorh=ff->top.plane->ZatPoint(thingx, thingy);
|
||||||
if (floorh==thing->floorz)
|
if (floorh==thing->floorz)
|
||||||
{
|
{
|
||||||
btm=TO_GL(floorh);
|
btm=FIXED2FLOAT(floorh);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -560,11 +559,11 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
||||||
if (thing->flags2&MF2_ONMOBJ && thing->floorz==
|
if (thing->flags2&MF2_ONMOBJ && thing->floorz==
|
||||||
thing->Sector->heightsec->floorplane.ZatPoint(thingx, thingy))
|
thing->Sector->heightsec->floorplane.ZatPoint(thingx, thingy))
|
||||||
{
|
{
|
||||||
btm=TO_GL(thing->floorz);
|
btm=FIXED2FLOAT(thing->floorz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (btm==1000000.0f)
|
if (btm==1000000.0f)
|
||||||
btm= TO_GL(thing->Sector->floorplane.ZatPoint(thingx, thingy)-thing->floorclip);
|
btm= FIXED2FLOAT(thing->Sector->floorplane.ZatPoint(thingx, thingy)-thing->floorclip);
|
||||||
|
|
||||||
float diff = z2 - btm;
|
float diff = z2 - btm;
|
||||||
if (diff >= 0 /*|| !gl_sprite_clip_to_floor*/) diff = 0;
|
if (diff >= 0 /*|| !gl_sprite_clip_to_floor*/) diff = 0;
|
||||||
|
@ -685,7 +684,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
||||||
|
|
||||||
RenderStyle = thing->RenderStyle;
|
RenderStyle = thing->RenderStyle;
|
||||||
RenderStyle.CheckFuzz();
|
RenderStyle.CheckFuzz();
|
||||||
trans = TO_GL(thing->alpha);
|
trans = FIXED2FLOAT(thing->alpha);
|
||||||
hw_styleflags = STYLEHW_Normal;
|
hw_styleflags = STYLEHW_Normal;
|
||||||
|
|
||||||
if (RenderStyle.Flags & STYLEF_TransSoulsAlpha)
|
if (RenderStyle.Flags & STYLEF_TransSoulsAlpha)
|
||||||
|
@ -840,9 +839,9 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x= TO_GL(particle->x);
|
x= FIXED2FLOAT(particle->x);
|
||||||
y= TO_GL(particle->y);
|
y= FIXED2FLOAT(particle->y);
|
||||||
z= TO_GL(particle->z);
|
z= FIXED2FLOAT(particle->z);
|
||||||
|
|
||||||
float scalefac=particle->size/4.0f;
|
float scalefac=particle->size/4.0f;
|
||||||
// [BB] The smooth particles are smaller than the other ones. Compensate for this here.
|
// [BB] The smooth particles are smaller than the other ones. Compensate for this here.
|
||||||
|
|
|
@ -54,7 +54,6 @@
|
||||||
#include "gl/scene/gl_portal.h"
|
#include "gl/scene/gl_portal.h"
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -81,7 +80,7 @@ void gl_GetSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_
|
||||||
if (!(light->flags2&MF2_DORMANT) &&
|
if (!(light->flags2&MF2_DORMANT) &&
|
||||||
(!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self))
|
(!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self))
|
||||||
{
|
{
|
||||||
float dist = FVector3( TO_GL(x - light->x), TO_GL(y - light->y), TO_GL(z - light->z) ).Length();
|
float dist = FVector3( FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z) ).Length();
|
||||||
radius = light->GetRadius() * gl_lights_size;
|
radius = light->GetRadius() * gl_lights_size;
|
||||||
|
|
||||||
if (dist < radius)
|
if (dist < radius)
|
||||||
|
@ -147,7 +146,7 @@ static int gl_SetSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subs
|
||||||
g = clamp<float>(result[1]+g, 0, 1.0f) * ThingColor.g/255.f;
|
g = clamp<float>(result[1]+g, 0, 1.0f) * ThingColor.g/255.f;
|
||||||
b = clamp<float>(result[2]+b, 0, 1.0f) * ThingColor.b/255.f;
|
b = clamp<float>(result[2]+b, 0, 1.0f) * ThingColor.b/255.f;
|
||||||
gl.Color4f(r, g, b, alpha);
|
gl.Color4f(r, g, b, alpha);
|
||||||
int addlight = quickertoint(result[0]*77 + result[1]*143 + result[2]*36);
|
int addlight = xs_RoundToInt(result[0]*77 + result[1]*143 + result[2]*36);
|
||||||
return clamp<int>(lightlevel + addlight , 0, 255);
|
return clamp<int>(lightlevel + addlight , 0, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
#include "gl/scene/gl_portal.h"
|
#include "gl/scene/gl_portal.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
#include "gl/utility/gl_clock.h"
|
#include "gl/utility/gl_clock.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
#include "gl/utility/gl_geometric.h"
|
#include "gl/utility/gl_geometric.h"
|
||||||
#include "gl/utility/gl_templates.h"
|
#include "gl/utility/gl_templates.h"
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
|
@ -484,13 +483,13 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2)
|
||||||
lightlist_t * light;
|
lightlist_t * light;
|
||||||
|
|
||||||
// ZDoom doesn't support slopes in a horizon sector so I won't either!
|
// ZDoom doesn't support slopes in a horizon sector so I won't either!
|
||||||
ztop[1] = ztop[0] = TO_GL(fs->GetPlaneTexZ(sector_t::ceiling));
|
ztop[1] = ztop[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::ceiling));
|
||||||
zbottom[1] = zbottom[0] = TO_GL(fs->GetPlaneTexZ(sector_t::floor));
|
zbottom[1] = zbottom[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::floor));
|
||||||
|
|
||||||
if (viewz < fs->GetPlaneTexZ(sector_t::ceiling))
|
if (viewz < fs->GetPlaneTexZ(sector_t::ceiling))
|
||||||
{
|
{
|
||||||
if (viewz > fs->GetPlaneTexZ(sector_t::floor))
|
if (viewz > fs->GetPlaneTexZ(sector_t::floor))
|
||||||
zbottom[1] = zbottom[0] = TO_GL(viewz);
|
zbottom[1] = zbottom[0] = FIXED2FLOAT(viewz);
|
||||||
|
|
||||||
if (fs->GetTexture(sector_t::ceiling) == skyflatnum)
|
if (fs->GetTexture(sector_t::ceiling) == skyflatnum)
|
||||||
{
|
{
|
||||||
|
@ -520,7 +519,7 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2)
|
||||||
|
|
||||||
if (viewz > fs->GetPlaneTexZ(sector_t::floor))
|
if (viewz > fs->GetPlaneTexZ(sector_t::floor))
|
||||||
{
|
{
|
||||||
zbottom[1] = zbottom[0] = TO_GL(fs->GetPlaneTexZ(sector_t::floor));
|
zbottom[1] = zbottom[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::floor));
|
||||||
if (fs->GetTexture(sector_t::floor) == skyflatnum)
|
if (fs->GetTexture(sector_t::floor) == skyflatnum)
|
||||||
{
|
{
|
||||||
SkyTexture(fs->sky, fs->FloorSkyBox, false);
|
SkyTexture(fs->sky, fs->FloorSkyBox, false);
|
||||||
|
@ -570,7 +569,7 @@ bool GLWall::SetWallCoordinates(seg_t * seg, float texturetop,
|
||||||
float length = seg->sidedef? seg->sidedef->TexelLength: Dist2(glseg.x1, glseg.y1, glseg.x2, glseg.y2);
|
float length = seg->sidedef? seg->sidedef->TexelLength: Dist2(glseg.x1, glseg.y1, glseg.x2, glseg.y2);
|
||||||
|
|
||||||
wti=gltexture->GetWorldTextureInfo();
|
wti=gltexture->GetWorldTextureInfo();
|
||||||
l_ul=wti->FloatToTexU(TO_GL(gltexture->TextureOffset(t_ofs)));
|
l_ul=wti->FloatToTexU(FIXED2FLOAT(gltexture->TextureOffset(t_ofs)));
|
||||||
texlength = wti->FloatToTexU(length);
|
texlength = wti->FloatToTexU(length);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -589,8 +588,8 @@ bool GLWall::SetWallCoordinates(seg_t * seg, float texturetop,
|
||||||
if (topleft>=bottomleft)
|
if (topleft>=bottomleft)
|
||||||
{
|
{
|
||||||
// normal case
|
// normal case
|
||||||
ztop[0]=TO_GL(topleft);
|
ztop[0]=FIXED2FLOAT(topleft);
|
||||||
zbottom[0]=TO_GL(bottomleft);
|
zbottom[0]=FIXED2FLOAT(bottomleft);
|
||||||
|
|
||||||
if (wti)
|
if (wti)
|
||||||
{
|
{
|
||||||
|
@ -607,13 +606,13 @@ bool GLWall::SetWallCoordinates(seg_t * seg, float texturetop,
|
||||||
|
|
||||||
fixed_t inter_y=topleft+FixedMul(coeff,dch);
|
fixed_t inter_y=topleft+FixedMul(coeff,dch);
|
||||||
|
|
||||||
float inter_x= TO_GL(coeff);
|
float inter_x= FIXED2FLOAT(coeff);
|
||||||
|
|
||||||
glseg.x1 = glseg.x1 + inter_x * (glseg.x2 - glseg.x1);
|
glseg.x1 = glseg.x1 + inter_x * (glseg.x2 - glseg.x1);
|
||||||
glseg.y1 = glseg.y1 + inter_x * (glseg.y2 - glseg.y1);
|
glseg.y1 = glseg.y1 + inter_x * (glseg.y2 - glseg.y1);
|
||||||
glseg.fracleft = inter_x;
|
glseg.fracleft = inter_x;
|
||||||
|
|
||||||
zbottom[0]=ztop[0]=TO_GL(inter_y);
|
zbottom[0]=ztop[0]=FIXED2FLOAT(inter_y);
|
||||||
|
|
||||||
if (wti)
|
if (wti)
|
||||||
{
|
{
|
||||||
|
@ -630,8 +629,8 @@ bool GLWall::SetWallCoordinates(seg_t * seg, float texturetop,
|
||||||
if (topright >= bottomright)
|
if (topright >= bottomright)
|
||||||
{
|
{
|
||||||
// normal case
|
// normal case
|
||||||
ztop[1]=TO_GL(topright) ;
|
ztop[1]=FIXED2FLOAT(topright) ;
|
||||||
zbottom[1]=TO_GL(bottomright) ;
|
zbottom[1]=FIXED2FLOAT(bottomright) ;
|
||||||
|
|
||||||
if (wti)
|
if (wti)
|
||||||
{
|
{
|
||||||
|
@ -649,13 +648,13 @@ bool GLWall::SetWallCoordinates(seg_t * seg, float texturetop,
|
||||||
|
|
||||||
fixed_t inter_y=topleft+FixedMul(coeff,dch);
|
fixed_t inter_y=topleft+FixedMul(coeff,dch);
|
||||||
|
|
||||||
float inter_x= TO_GL(coeff);
|
float inter_x= FIXED2FLOAT(coeff);
|
||||||
|
|
||||||
glseg.x2 = glseg.x1 + inter_x * (glseg.x2 - glseg.x1);
|
glseg.x2 = glseg.x1 + inter_x * (glseg.x2 - glseg.x1);
|
||||||
glseg.y2 = glseg.y1 + inter_x * (glseg.y2 - glseg.y1);
|
glseg.y2 = glseg.y1 + inter_x * (glseg.y2 - glseg.y1);
|
||||||
glseg.fracright = inter_x;
|
glseg.fracright = inter_x;
|
||||||
|
|
||||||
zbottom[1]=ztop[1]=TO_GL(inter_y);
|
zbottom[1]=ztop[1]=FIXED2FLOAT(inter_y);
|
||||||
if (wti)
|
if (wti)
|
||||||
{
|
{
|
||||||
//uprgt.u=lorgt.u=l_ul+wti->FloatToTexU(inter_x*length);
|
//uprgt.u=lorgt.u=l_ul+wti->FloatToTexU(inter_x*length);
|
||||||
|
@ -749,9 +748,9 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg,
|
||||||
type = (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S &&
|
type = (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S &&
|
||||||
!(gl.flags & RFL_NOSTENCIL) && gl_mirrors) ? RENDERWALL_MIRROR : _type;
|
!(gl.flags & RFL_NOSTENCIL) && gl_mirrors) ? RENDERWALL_MIRROR : _type;
|
||||||
|
|
||||||
float floatceilingref = TO_GL(ceilingrefheight) +
|
float floatceilingref = FIXED2FLOAT(ceilingrefheight) +
|
||||||
gltexture->RowOffset(TO_GL(seg->sidedef->GetTextureYOffset(texpos))) +
|
gltexture->RowOffset(FIXED2FLOAT(seg->sidedef->GetTextureYOffset(texpos))) +
|
||||||
TO_GL((peg ? (gltexture->TextureHeight(GLUSE_TEXTURE)<<FRACBITS)-lh-v_offset:0));
|
FIXED2FLOAT((peg ? (gltexture->TextureHeight(GLUSE_TEXTURE)<<FRACBITS)-lh-v_offset:0));
|
||||||
|
|
||||||
if (!SetWallCoordinates(seg, floatceilingref, topleft, topright, bottomleft, bottomright,
|
if (!SetWallCoordinates(seg, floatceilingref, topleft, topright, bottomleft, bottomright,
|
||||||
seg->sidedef->GetTextureXOffset(texpos))) return;
|
seg->sidedef->GetTextureXOffset(texpos))) return;
|
||||||
|
@ -939,7 +938,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
|
||||||
flags|=GLT_CLAMPY;
|
flags|=GLT_CLAMPY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetWallCoordinates(seg, TO_GL(texturetop), topleft, topright, bottomleft, bottomright, t_ofs);
|
SetWallCoordinates(seg, FIXED2FLOAT(texturetop), topleft, topright, bottomleft, bottomright, t_ofs);
|
||||||
|
|
||||||
if (gltexture != NULL) gltexture->SetWallScaling(FRACUNIT, FRACUNIT);
|
if (gltexture != NULL) gltexture->SetWallScaling(FRACUNIT, FRACUNIT);
|
||||||
|
|
||||||
|
@ -1125,10 +1124,10 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
|
||||||
const WorldTextureInfo * wti=gltexture->GetWorldTextureInfo();
|
const WorldTextureInfo * wti=gltexture->GetWorldTextureInfo();
|
||||||
if (!wti) return;
|
if (!wti) return;
|
||||||
|
|
||||||
to=TO_GL((rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))?
|
to=FIXED2FLOAT((rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))?
|
||||||
0:gltexture->TextureOffset(mastersd->GetTextureXOffset(side_t::mid)));
|
0:gltexture->TextureOffset(mastersd->GetTextureXOffset(side_t::mid)));
|
||||||
|
|
||||||
ul=wti->FloatToTexU(to + TO_GL(gltexture->TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid))));
|
ul=wti->FloatToTexU(to + FIXED2FLOAT(gltexture->TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid))));
|
||||||
|
|
||||||
texlength = wti->FloatToTexU(seg->sidedef->TexelLength);
|
texlength = wti->FloatToTexU(seg->sidedef->TexelLength);
|
||||||
|
|
||||||
|
@ -1137,23 +1136,23 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
|
||||||
|
|
||||||
fixed_t rowoffset=gltexture->RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid));
|
fixed_t rowoffset=gltexture->RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid));
|
||||||
to= (rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))?
|
to= (rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))?
|
||||||
0.f : gltexture->RowOffset(TO_GL(mastersd->GetTextureYOffset(side_t::mid)));
|
0.f : gltexture->RowOffset(FIXED2FLOAT(mastersd->GetTextureYOffset(side_t::mid)));
|
||||||
|
|
||||||
to += TO_GL(rowoffset);
|
to += FIXED2FLOAT(rowoffset);
|
||||||
|
|
||||||
uplft.v=wti->FloatToTexV(to + TO_GL(*rover->top.texheight-ff_topleft));
|
uplft.v=wti->FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_topleft));
|
||||||
uprgt.v=wti->FloatToTexV(to + TO_GL(*rover->top.texheight-ff_topright));
|
uprgt.v=wti->FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_topright));
|
||||||
lolft.v=wti->FloatToTexV(to + TO_GL(*rover->top.texheight-ff_bottomleft));
|
lolft.v=wti->FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_bottomleft));
|
||||||
lorgt.v=wti->FloatToTexV(to + TO_GL(*rover->top.texheight-ff_bottomright));
|
lorgt.v=wti->FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_bottomright));
|
||||||
type=RENDERWALL_FFBLOCK;
|
type=RENDERWALL_FFBLOCK;
|
||||||
gltexture->SetWallScaling(FRACUNIT, FRACUNIT);
|
gltexture->SetWallScaling(FRACUNIT, FRACUNIT);
|
||||||
CheckTexturePosition();
|
CheckTexturePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
ztop[0]=TO_GL(ff_topleft);
|
ztop[0]=FIXED2FLOAT(ff_topleft);
|
||||||
ztop[1]=TO_GL(ff_topright);
|
ztop[1]=FIXED2FLOAT(ff_topright);
|
||||||
zbottom[0]=TO_GL(ff_bottomleft);//-0.001f;
|
zbottom[0]=FIXED2FLOAT(ff_bottomleft);//-0.001f;
|
||||||
zbottom[1]=TO_GL(ff_bottomright);
|
zbottom[1]=FIXED2FLOAT(ff_bottomright);
|
||||||
|
|
||||||
if (rover->flags&(FF_TRANSLUCENT|FF_ADDITIVETRANS|FF_FOG))
|
if (rover->flags&(FF_TRANSLUCENT|FF_ADDITIVETRANS|FF_FOG))
|
||||||
{
|
{
|
||||||
|
@ -1503,10 +1502,10 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector,
|
||||||
vertexes[0]=v1;
|
vertexes[0]=v1;
|
||||||
vertexes[1]=v2;
|
vertexes[1]=v2;
|
||||||
|
|
||||||
glseg.x1= TO_GL(v1->x);
|
glseg.x1= FIXED2FLOAT(v1->x);
|
||||||
glseg.y1= TO_GL(v1->y);
|
glseg.y1= FIXED2FLOAT(v1->y);
|
||||||
glseg.x2= TO_GL(v2->x);
|
glseg.x2= FIXED2FLOAT(v2->x);
|
||||||
glseg.y2= TO_GL(v2->y);
|
glseg.y2= FIXED2FLOAT(v2->y);
|
||||||
Colormap=frontsector->ColorMap;
|
Colormap=frontsector->ColorMap;
|
||||||
flags = (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE)? GLWF_FOGGY : 0;
|
flags = (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE)? GLWF_FOGGY : 0;
|
||||||
|
|
||||||
|
@ -1532,26 +1531,26 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector,
|
||||||
{
|
{
|
||||||
ffh1=frontsector->floorplane.ZatPoint(v1);
|
ffh1=frontsector->floorplane.ZatPoint(v1);
|
||||||
ffh2=frontsector->floorplane.ZatPoint(v2);
|
ffh2=frontsector->floorplane.ZatPoint(v2);
|
||||||
zfloor[0]=TO_GL(ffh1);
|
zfloor[0]=FIXED2FLOAT(ffh1);
|
||||||
zfloor[1]=TO_GL(ffh2);
|
zfloor[1]=FIXED2FLOAT(ffh2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ffh1 = ffh2 = -frontsector->floorplane.d;
|
ffh1 = ffh2 = -frontsector->floorplane.d;
|
||||||
zfloor[0] = zfloor[1] = TO_GL(ffh2);
|
zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frontsector->ceilingplane.a | frontsector->ceilingplane.b)
|
if (frontsector->ceilingplane.a | frontsector->ceilingplane.b)
|
||||||
{
|
{
|
||||||
fch1=frontsector->ceilingplane.ZatPoint(v1);
|
fch1=frontsector->ceilingplane.ZatPoint(v1);
|
||||||
fch2=frontsector->ceilingplane.ZatPoint(v2);
|
fch2=frontsector->ceilingplane.ZatPoint(v2);
|
||||||
zceil[0]= TO_GL(fch1);
|
zceil[0]= FIXED2FLOAT(fch1);
|
||||||
zceil[1]= TO_GL(fch2);
|
zceil[1]= FIXED2FLOAT(fch2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fch1 = fch2 = frontsector->ceilingplane.d;
|
fch1 = fch2 = frontsector->ceilingplane.d;
|
||||||
zceil[0] = zceil[1] = TO_GL(fch2);
|
zceil[0] = zceil[1] = FIXED2FLOAT(fch2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1742,10 +1741,10 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t *
|
||||||
vertexes[0]=v1;
|
vertexes[0]=v1;
|
||||||
vertexes[1]=v2;
|
vertexes[1]=v2;
|
||||||
|
|
||||||
glseg.x1= TO_GL(v1->x);
|
glseg.x1= FIXED2FLOAT(v1->x);
|
||||||
glseg.y1= TO_GL(v1->y);
|
glseg.y1= FIXED2FLOAT(v1->y);
|
||||||
glseg.x2= TO_GL(v2->x);
|
glseg.x2= FIXED2FLOAT(v2->x);
|
||||||
glseg.y2= TO_GL(v2->y);
|
glseg.y2= FIXED2FLOAT(v2->y);
|
||||||
glseg.fracleft=0;
|
glseg.fracleft=0;
|
||||||
glseg.fracright=1;
|
glseg.fracright=1;
|
||||||
|
|
||||||
|
@ -1762,14 +1761,14 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t *
|
||||||
topflat=frontsector->GetTexture(sector_t::ceiling); // for glowing textures
|
topflat=frontsector->GetTexture(sector_t::ceiling); // for glowing textures
|
||||||
bottomflat=frontsector->GetTexture(sector_t::floor);
|
bottomflat=frontsector->GetTexture(sector_t::floor);
|
||||||
|
|
||||||
zfloor[0] = zfloor[1] = TO_GL(ffh);
|
zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh);
|
||||||
|
|
||||||
gltexture=FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), true);
|
gltexture=FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), true);
|
||||||
|
|
||||||
if (gltexture)
|
if (gltexture)
|
||||||
{
|
{
|
||||||
type=RENDERWALL_BOTTOM;
|
type=RENDERWALL_BOTTOM;
|
||||||
SetWallCoordinates(seg, TO_GL(bfh), bfh, bfh, ffh, ffh, 0);
|
SetWallCoordinates(seg, FIXED2FLOAT(bfh), bfh, bfh, ffh, ffh, 0);
|
||||||
PutWall(false);
|
PutWall(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,6 @@
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
#include "gl/utility/gl_clock.h"
|
#include "gl/utility/gl_clock.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
#include "gl/utility/gl_templates.h"
|
#include "gl/utility/gl_templates.h"
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, gl_seamless)
|
EXTERN_CVAR(Bool, gl_seamless)
|
||||||
|
@ -158,9 +157,9 @@ void GLWall::SetupLights()
|
||||||
|
|
||||||
Vector fn, pos;
|
Vector fn, pos;
|
||||||
|
|
||||||
float x = TO_GL(node->lightsource->x);
|
float x = FIXED2FLOAT(node->lightsource->x);
|
||||||
float y = TO_GL(node->lightsource->y);
|
float y = FIXED2FLOAT(node->lightsource->y);
|
||||||
float z = TO_GL(node->lightsource->z);
|
float z = FIXED2FLOAT(node->lightsource->z);
|
||||||
float dist = fabsf(p.DistToPoint(x, z, y));
|
float dist = fabsf(p.DistToPoint(x, z, y));
|
||||||
float radius = (node->lightsource->GetRadius() * gl_lights_size);
|
float radius = (node->lightsource->GetRadius() * gl_lights_size);
|
||||||
float scale = 1.0f / ((2.f * radius) - dist);
|
float scale = 1.0f / ((2.f * radius) - dist);
|
||||||
|
@ -313,8 +312,8 @@ void GLWall::RenderFogBoundary()
|
||||||
// as the shader version but it's an acceptable compromise.
|
// as the shader version but it's an acceptable compromise.
|
||||||
float fogdensity=gl_GetFogDensity(lightlevel, Colormap.FadeColor);
|
float fogdensity=gl_GetFogDensity(lightlevel, Colormap.FadeColor);
|
||||||
|
|
||||||
float xcamera=TO_GL(viewx);
|
float xcamera=FIXED2FLOAT(viewx);
|
||||||
float ycamera=TO_GL(viewy);
|
float ycamera=FIXED2FLOAT(viewy);
|
||||||
|
|
||||||
float dist1=Dist2(xcamera,ycamera, glseg.x1,glseg.y1);
|
float dist1=Dist2(xcamera,ycamera, glseg.x1,glseg.y1);
|
||||||
float dist2=Dist2(xcamera,ycamera, glseg.x2,glseg.y2);
|
float dist2=Dist2(xcamera,ycamera, glseg.x2,glseg.y2);
|
||||||
|
|
|
@ -53,7 +53,6 @@
|
||||||
#include "gl/models/gl_models.h"
|
#include "gl/models/gl_models.h"
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
|
|
||||||
EXTERN_CVAR (Bool, r_drawplayersprites)
|
EXTERN_CVAR (Bool, r_drawplayersprites)
|
||||||
EXTERN_CVAR(Float, transsouls)
|
EXTERN_CVAR(Float, transsouls)
|
||||||
|
@ -267,7 +266,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
trans = TO_GL(vis.alpha);
|
trans = FIXED2FLOAT(vis.alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now draw the different layers of the weapon
|
// now draw the different layers of the weapon
|
||||||
|
|
|
@ -60,7 +60,6 @@
|
||||||
#include "gl/textures/gl_bitmap.h"
|
#include "gl/textures/gl_bitmap.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, gl_render_precise)
|
EXTERN_CVAR(Bool, gl_render_precise)
|
||||||
EXTERN_CVAR(Int, gl_lightmode)
|
EXTERN_CVAR(Int, gl_lightmode)
|
||||||
|
@ -832,12 +831,12 @@ fixed_t FMaterial::RowOffset(fixed_t rowoffset) const
|
||||||
if (tempScaleX == FRACUNIT)
|
if (tempScaleX == FRACUNIT)
|
||||||
{
|
{
|
||||||
if (wti.scaley==1.f || tex->bWorldPanning) return rowoffset;
|
if (wti.scaley==1.f || tex->bWorldPanning) return rowoffset;
|
||||||
else return quickertoint(rowoffset/wti.scaley);
|
else return xs_RoundToInt(rowoffset/wti.scaley);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (tex->bWorldPanning) return FixedDiv(rowoffset, tempScaleY);
|
if (tex->bWorldPanning) return FixedDiv(rowoffset, tempScaleY);
|
||||||
else return quickertoint(rowoffset/wti.scaley);
|
else return xs_RoundToInt(rowoffset/wti.scaley);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -856,7 +855,7 @@ float FMaterial::RowOffset(float rowoffset) const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (tex->bWorldPanning) return rowoffset / TO_GL(tempScaleY);
|
if (tex->bWorldPanning) return rowoffset / FIXED2FLOAT(tempScaleY);
|
||||||
else return rowoffset / wti.scaley;
|
else return rowoffset / wti.scaley;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -872,12 +871,12 @@ fixed_t FMaterial::TextureOffset(fixed_t textureoffset) const
|
||||||
if (tempScaleX == FRACUNIT)
|
if (tempScaleX == FRACUNIT)
|
||||||
{
|
{
|
||||||
if (wti.scalex==1.f || tex->bWorldPanning) return textureoffset;
|
if (wti.scalex==1.f || tex->bWorldPanning) return textureoffset;
|
||||||
else return quickertoint(textureoffset/wti.scalex);
|
else return xs_RoundToInt(textureoffset/wti.scalex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (tex->bWorldPanning) return FixedDiv(textureoffset, tempScaleX);
|
if (tex->bWorldPanning) return FixedDiv(textureoffset, tempScaleX);
|
||||||
else return quickertoint(textureoffset/wti.scalex);
|
else return xs_RoundToInt(textureoffset/wti.scalex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,7 +896,7 @@ float FMaterial::TextureOffset(float textureoffset) const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (tex->bWorldPanning) return textureoffset / TO_GL(tempScaleX);
|
if (tex->bWorldPanning) return textureoffset / FIXED2FLOAT(tempScaleX);
|
||||||
else return textureoffset/wti.scalex;
|
else return textureoffset/wti.scalex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,7 @@ void CheckBench()
|
||||||
FString compose;
|
FString compose;
|
||||||
|
|
||||||
compose.Format("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n",
|
compose.Format("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n",
|
||||||
level.mapname, level.LevelName.GetChars(), TO_GL(viewx), TO_GL(viewy), TO_GL(viewz),
|
level.mapname, level.LevelName.GetChars(), FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz),
|
||||||
ANGLE_TO_FLOAT(viewangle), ANGLE_TO_FLOAT(viewpitch));
|
ANGLE_TO_FLOAT(viewangle), ANGLE_TO_FLOAT(viewpitch));
|
||||||
|
|
||||||
AppendRenderStats(compose);
|
AppendRenderStats(compose);
|
||||||
|
|
|
@ -2,15 +2,8 @@
|
||||||
#ifndef __GLC_CONVERT
|
#ifndef __GLC_CONVERT
|
||||||
#define __GLC_CONVERT
|
#define __GLC_CONVERT
|
||||||
|
|
||||||
#define TO_GL(v) ((float)(v)/FRACUNIT)
|
#include "m_fixed.h"
|
||||||
#define TO_MAP(f) (fixed_t)quickertoint((f)*FRACUNIT)
|
|
||||||
#define ANGLE_TO_FLOAT(ang) ((float)((ang) * 180. / ANGLE_180))
|
#define ANGLE_TO_FLOAT(ang) ((float)((ang) * 180. / ANGLE_180))
|
||||||
#define FLOAT_TO_ANGLE(ang) (angle_t)((ang) / 180. * ANGLE_180)
|
#define FLOAT_TO_ANGLE(ang) xs_RoundToUInt((ang) / 180. * ANGLE_180)
|
||||||
|
|
||||||
#define ANGLE_TO_RAD(ang) ((float)((ang) * M_PI / ANGLE_180))
|
|
||||||
#define RAD_TO_ANGLE(ang) (angle_t)((ang) / M_PI * ANGLE_180)
|
|
||||||
|
|
||||||
#define FLOAT_TO_RAD(ang) float((ang) * M_PI / 180.)
|
|
||||||
#define RAD_TO_FLOAT(ang) float((ang) / M_PI * 180.)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include "gl/utility/gl_convert.h"
|
|
||||||
#include "gl/utility/gl_geometric.h"
|
#include "gl/utility/gl_geometric.h"
|
||||||
|
|
||||||
static Vector axis[3] =
|
static Vector axis[3] =
|
||||||
|
@ -230,10 +229,10 @@ void Plane::Set(secplane_t &plane)
|
||||||
{
|
{
|
||||||
float a, b, c, d;
|
float a, b, c, d;
|
||||||
|
|
||||||
a = TO_GL(plane.a);
|
a = FIXED2FLOAT(plane.a);
|
||||||
b = TO_GL(plane.b);
|
b = FIXED2FLOAT(plane.b);
|
||||||
c = TO_GL(plane.c);
|
c = FIXED2FLOAT(plane.c);
|
||||||
d = TO_GL(plane.d);
|
d = FIXED2FLOAT(plane.d);
|
||||||
|
|
||||||
m_normal.Set(a, c, b);
|
m_normal.Set(a, c, b);
|
||||||
//m_normal.Normalize(); the vector is already normalized
|
//m_normal.Normalize(); the vector is already normalized
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "basicinlines.h"
|
#include "basicinlines.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "xs_Float.h"
|
||||||
|
|
||||||
#define MAKESAFEDIVSCALE(x) \
|
#define MAKESAFEDIVSCALE(x) \
|
||||||
inline SDWORD SafeDivScale##x (SDWORD a, SDWORD b) \
|
inline SDWORD SafeDivScale##x (SDWORD a, SDWORD b) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -134,4 +136,8 @@ inline SDWORD ModDiv (SDWORD num, SDWORD den, SDWORD *dmval)
|
||||||
return num % den;
|
return num % den;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define FLOAT2FIXED(f) xs_Fix<16>::ToFix(f)
|
||||||
|
#define FIXED2FLOAT(f) ((f) / float(65536))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -348,20 +348,4 @@ __forceinline SDWORD ksgn (SDWORD a)
|
||||||
__asm adc eax,0
|
__asm adc eax,0
|
||||||
}
|
}
|
||||||
|
|
||||||
__forceinline int toint (float v)
|
|
||||||
{
|
|
||||||
SQWORD res;
|
|
||||||
__asm fld v;
|
|
||||||
__asm fistp res;
|
|
||||||
return (int)res;
|
|
||||||
}
|
|
||||||
|
|
||||||
__forceinline int quickertoint (float v)
|
|
||||||
{
|
|
||||||
SDWORD res;
|
|
||||||
__asm fld v;
|
|
||||||
__asm fistp res;
|
|
||||||
return (int)res;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning (default: 4035)
|
#pragma warning (default: 4035)
|
||||||
|
|
|
@ -328,9 +328,7 @@ angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x, fixed_t y)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we have to use the slower but more precise floating point atan2 function here.
|
// we have to use the slower but more precise floating point atan2 function here.
|
||||||
// (use quickertoint to speed this up because the CRT's conversion is rather slow and
|
return xs_RoundToUInt(atan2(double(y), double(x)) * (ANGLE_180/M_PI));
|
||||||
// this is used in time critical code.)
|
|
||||||
return quickertoint((float)(atan2f(float(y), float(x)) * (ANGLE_180/M_PI)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,7 @@ void R_MapTiltedPlane (int y, int x1)
|
||||||
{
|
{
|
||||||
uz = (iz + plane_sz[0]*width) * planelightfloat;
|
uz = (iz + plane_sz[0]*width) * planelightfloat;
|
||||||
vz = iz * planelightfloat;
|
vz = iz * planelightfloat;
|
||||||
R_CalcTiltedLighting (toint (vz), toint (uz), width);
|
R_CalcTiltedLighting (xs_RoundToInt(vz), xs_RoundToInt(uz), width);
|
||||||
}
|
}
|
||||||
|
|
||||||
uz = plane_su[2] + plane_su[1]*(centery-y) + plane_su[0]*(x1-centerx);
|
uz = plane_su[2] + plane_su[1]*(centery-y) + plane_su[0]*(x1-centerx);
|
||||||
|
|
|
@ -2006,29 +2006,29 @@ void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat)
|
||||||
x = WallSX1;
|
x = WallSX1;
|
||||||
|
|
||||||
l = top / bot;
|
l = top / bot;
|
||||||
swall[x] = quickertoint (l * WallDepthScale + WallDepthOrg);
|
swall[x] = xs_RoundToInt(l * WallDepthScale + WallDepthOrg);
|
||||||
lwall[x] = quickertoint (l * xrepeat);
|
lwall[x] = xs_RoundToInt(l * xrepeat);
|
||||||
// As long as l is invalid, step one column at a time so that
|
// As long as l is invalid, step one column at a time so that
|
||||||
// we can get as many correct texture columns as possible.
|
// we can get as many correct texture columns as possible.
|
||||||
while (l > 1.0 && x+1 < WallSX2)
|
while (l > 1.0 && x+1 < WallSX2)
|
||||||
{
|
{
|
||||||
l = (top += WallUoverZstep) / (bot += WallInvZstep);
|
l = (top += WallUoverZstep) / (bot += WallInvZstep);
|
||||||
x++;
|
x++;
|
||||||
swall[x] = quickertoint (l * WallDepthScale + WallDepthOrg);
|
swall[x] = xs_RoundToInt(l * WallDepthScale + WallDepthOrg);
|
||||||
lwall[x] = quickertoint (l * xrepeat);
|
lwall[x] = xs_RoundToInt(l * xrepeat);
|
||||||
}
|
}
|
||||||
l *= xrepeat;
|
l *= xrepeat;
|
||||||
while (x+4 < WallSX2)
|
while (x+4 < WallSX2)
|
||||||
{
|
{
|
||||||
top += topinc; bot += botinc;
|
top += topinc; bot += botinc;
|
||||||
ol = l; l = top / bot;
|
ol = l; l = top / bot;
|
||||||
swall[x+4] = quickertoint (l * WallDepthScale + WallDepthOrg);
|
swall[x+4] = xs_RoundToInt(l * WallDepthScale + WallDepthOrg);
|
||||||
lwall[x+4] = quickertoint (l *= xrepeat);
|
lwall[x+4] = xs_RoundToInt(l *= xrepeat);
|
||||||
|
|
||||||
i = (ol+l) * 0.5f;
|
i = (ol+l) * 0.5f;
|
||||||
lwall[x+2] = quickertoint (i);
|
lwall[x+2] = xs_RoundToInt(i);
|
||||||
lwall[x+1] = quickertoint ((ol+i) * 0.5f);
|
lwall[x+1] = xs_RoundToInt((ol+i) * 0.5f);
|
||||||
lwall[x+3] = quickertoint ((l+i) * 0.5f);
|
lwall[x+3] = xs_RoundToInt((l+i) * 0.5f);
|
||||||
swall[x+2] = ((swall[x]+swall[x+4])>>1);
|
swall[x+2] = ((swall[x]+swall[x+4])>>1);
|
||||||
swall[x+1] = ((swall[x]+swall[x+2])>>1);
|
swall[x+1] = ((swall[x]+swall[x+2])>>1);
|
||||||
swall[x+3] = ((swall[x+4]+swall[x+2])>>1);
|
swall[x+3] = ((swall[x+4]+swall[x+2])>>1);
|
||||||
|
@ -2038,25 +2038,25 @@ void PrepWall (fixed_t *swall, fixed_t *lwall, fixed_t walxrepeat)
|
||||||
{
|
{
|
||||||
top += topinc * 0.5f; bot += botinc * 0.5f;
|
top += topinc * 0.5f; bot += botinc * 0.5f;
|
||||||
ol = l; l = top / bot;
|
ol = l; l = top / bot;
|
||||||
swall[x+2] = quickertoint (l * WallDepthScale + WallDepthOrg);
|
swall[x+2] = xs_RoundToInt(l * WallDepthScale + WallDepthOrg);
|
||||||
lwall[x+2] = quickertoint (l *= xrepeat);
|
lwall[x+2] = xs_RoundToInt(l *= xrepeat);
|
||||||
|
|
||||||
lwall[x+1] = quickertoint ((l+ol)*0.5f);
|
lwall[x+1] = xs_RoundToInt((l+ol)*0.5f);
|
||||||
swall[x+1] = (swall[x]+swall[x+2])>>1;
|
swall[x+1] = (swall[x]+swall[x+2])>>1;
|
||||||
x += 2;
|
x += 2;
|
||||||
}
|
}
|
||||||
if (x+1 < WallSX2)
|
if (x+1 < WallSX2)
|
||||||
{
|
{
|
||||||
l = (top + WallUoverZstep) / (bot + WallInvZstep);
|
l = (top + WallUoverZstep) / (bot + WallInvZstep);
|
||||||
swall[x+1] = quickertoint (l * WallDepthScale + WallDepthOrg);
|
swall[x+1] = xs_RoundToInt(l * WallDepthScale + WallDepthOrg);
|
||||||
lwall[x+1] = quickertoint (l * xrepeat);
|
lwall[x+1] = xs_RoundToInt(l * xrepeat);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
for (x = WallSX1; x < WallSX2; x++)
|
for (x = WallSX1; x < WallSX2; x++)
|
||||||
{
|
{
|
||||||
frac = top / bot;
|
frac = top / bot;
|
||||||
lwall[x] = quickertoint (frac * xrepeat);
|
lwall[x] = xs_RoundToInt(frac * xrepeat);
|
||||||
swall[x] = quickertoint (frac * WallDepthScale + WallDepthOrg);
|
swall[x] = xs_RoundToInt(frac * WallDepthScale + WallDepthOrg);
|
||||||
top += WallUoverZstep;
|
top += WallUoverZstep;
|
||||||
bot += WallInvZstep;
|
bot += WallInvZstep;
|
||||||
}
|
}
|
||||||
|
@ -2108,39 +2108,39 @@ void PrepLWall (fixed_t *lwall, fixed_t walxrepeat)
|
||||||
x = WallSX1;
|
x = WallSX1;
|
||||||
|
|
||||||
l = top / bot;
|
l = top / bot;
|
||||||
lwall[x] = quickertoint (l * xrepeat);
|
lwall[x] = xs_RoundToInt(l * xrepeat);
|
||||||
// As long as l is invalid, step one column at a time so that
|
// As long as l is invalid, step one column at a time so that
|
||||||
// we can get as many correct texture columns as possible.
|
// we can get as many correct texture columns as possible.
|
||||||
while (l > 1.0 && x+1 < WallSX2)
|
while (l > 1.0 && x+1 < WallSX2)
|
||||||
{
|
{
|
||||||
l = (top += WallUoverZstep) / (bot += WallInvZstep);
|
l = (top += WallUoverZstep) / (bot += WallInvZstep);
|
||||||
lwall[++x] = quickertoint (l * xrepeat);
|
lwall[++x] = xs_RoundToInt(l * xrepeat);
|
||||||
}
|
}
|
||||||
l *= xrepeat;
|
l *= xrepeat;
|
||||||
while (x+4 < WallSX2)
|
while (x+4 < WallSX2)
|
||||||
{
|
{
|
||||||
top += topinc; bot += botinc;
|
top += topinc; bot += botinc;
|
||||||
ol = l; l = top / bot;
|
ol = l; l = top / bot;
|
||||||
lwall[x+4] = quickertoint (l *= xrepeat);
|
lwall[x+4] = xs_RoundToInt(l *= xrepeat);
|
||||||
|
|
||||||
i = (ol+l) * 0.5f;
|
i = (ol+l) * 0.5f;
|
||||||
lwall[x+2] = quickertoint (i);
|
lwall[x+2] = xs_RoundToInt(i);
|
||||||
lwall[x+1] = quickertoint ((ol+i) * 0.5f);
|
lwall[x+1] = xs_RoundToInt((ol+i) * 0.5f);
|
||||||
lwall[x+3] = quickertoint ((l+i) * 0.5f);
|
lwall[x+3] = xs_RoundToInt((l+i) * 0.5f);
|
||||||
x += 4;
|
x += 4;
|
||||||
}
|
}
|
||||||
if (x+2 < WallSX2)
|
if (x+2 < WallSX2)
|
||||||
{
|
{
|
||||||
top += topinc * 0.5f; bot += botinc * 0.5f;
|
top += topinc * 0.5f; bot += botinc * 0.5f;
|
||||||
ol = l; l = top / bot;
|
ol = l; l = top / bot;
|
||||||
lwall[x+2] = quickertoint (l *= xrepeat);
|
lwall[x+2] = xs_RoundToInt(l *= xrepeat);
|
||||||
lwall[x+1] = quickertoint ((l+ol)*0.5f);
|
lwall[x+1] = xs_RoundToInt((l+ol)*0.5f);
|
||||||
x += 2;
|
x += 2;
|
||||||
}
|
}
|
||||||
if (x+1 < WallSX2)
|
if (x+1 < WallSX2)
|
||||||
{
|
{
|
||||||
l = (top + WallUoverZstep) / (bot + WallInvZstep);
|
l = (top + WallUoverZstep) / (bot + WallInvZstep);
|
||||||
lwall[x+1] = quickertoint (l * xrepeat);
|
lwall[x+1] = xs_RoundToInt(l * xrepeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix for rounding errors
|
// fix for rounding errors
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
// This file was automatically generated by the
|
// This file was automatically generated by the
|
||||||
// updaterevision tool. Do not edit by hand.
|
// updaterevision tool. Do not edit by hand.
|
||||||
|
|
||||||
#define ZD_SVN_REVISION_STRING "1987"
|
#define ZD_SVN_REVISION_STRING "1991"
|
||||||
#define ZD_SVN_REVISION_NUMBER 1987
|
#define ZD_SVN_REVISION_NUMBER 1991
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include "p_lnspec.h"
|
#include "p_lnspec.h"
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
#include "thingdef_exp.h"
|
#include "thingdef_exp.h"
|
||||||
|
#include "m_fixed.h"
|
||||||
|
|
||||||
int testglobalvar = 1337; // just for having one global variable to test with
|
int testglobalvar = 1337; // just for having one global variable to test with
|
||||||
DEFINE_GLOBAL_VARIABLE(testglobalvar)
|
DEFINE_GLOBAL_VARIABLE(testglobalvar)
|
||||||
|
|
|
@ -1230,7 +1230,4 @@ typedef TRotator<float> FRotator;
|
||||||
typedef TMatrix3x3<float> FMatrix3x3;
|
typedef TMatrix3x3<float> FMatrix3x3;
|
||||||
typedef TAngle<float> FAngle;
|
typedef TAngle<float> FAngle;
|
||||||
|
|
||||||
#define FLOAT2FIXED(f) fixed_t((f) * float(65536))
|
|
||||||
#define FIXED2FLOAT(f) ((f) / float(65536))
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
224
src/xs_Float.h
Normal file
224
src/xs_Float.h
Normal file
|
@ -0,0 +1,224 @@
|
||||||
|
// ====================================================================================================================
|
||||||
|
// ====================================================================================================================
|
||||||
|
// xs_Float.h
|
||||||
|
//
|
||||||
|
// Source: "Know Your FPU: Fixing Floating Fast"
|
||||||
|
// http://www.stereopsis.com/sree/fpu2006.html
|
||||||
|
//
|
||||||
|
// xs_CRoundToInt: Round toward nearest, but ties round toward even (just like FISTP)
|
||||||
|
// xs_ToInt: Round toward zero, just like the C (int) cast
|
||||||
|
// xs_FloorToInt: Round down
|
||||||
|
// xs_CeilToInt: Round up
|
||||||
|
// xs_RoundToInt: Round toward nearest, but ties round up
|
||||||
|
// ====================================================================================================================
|
||||||
|
// ====================================================================================================================
|
||||||
|
#ifndef _xs_FLOAT_H_
|
||||||
|
#define _xs_FLOAT_H_
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
// Defines
|
||||||
|
// ====================================================================================================================
|
||||||
|
#ifndef _xs_DEFAULT_CONVERSION
|
||||||
|
#define _xs_DEFAULT_CONVERSION 0
|
||||||
|
#endif //_xs_DEFAULT_CONVERSION
|
||||||
|
|
||||||
|
|
||||||
|
#if __BIG_ENDIAN__
|
||||||
|
#define _xs_iexp_ 0
|
||||||
|
#define _xs_iman_ 1
|
||||||
|
#else
|
||||||
|
#define _xs_iexp_ 1 //intel is little endian
|
||||||
|
#define _xs_iman_ 0
|
||||||
|
#endif //BigEndian_
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define finline inline
|
||||||
|
#else
|
||||||
|
#define finline __forceinline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
union _xs_doubleints
|
||||||
|
{
|
||||||
|
real64 val;
|
||||||
|
uint32 ival[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#define _xs_doublecopysgn(a,b) ((int32*)&a)[_xs_iexp_]&=~(((int32*)&b)[_xs_iexp_]&0x80000000)
|
||||||
|
#define _xs_doubleisnegative(a) ((((int32*)&a)[_xs_iexp_])|0x80000000)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
// Constants
|
||||||
|
// ====================================================================================================================
|
||||||
|
const real64 _xs_doublemagic = real64 (6755399441055744.0); //2^52 * 1.5, uses limited precisicion to floor
|
||||||
|
const real64 _xs_doublemagicdelta = (1.5e-8); //almost .5f = .5f + 1e^(number of exp bit)
|
||||||
|
const real64 _xs_doublemagicroundeps = (.5f-_xs_doublemagicdelta); //almost .5f = .5f - 1e^(number of exp bit)
|
||||||
|
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
// Prototypes
|
||||||
|
// ====================================================================================================================
|
||||||
|
static int32 xs_CRoundToInt (real64 val, real64 dmr = _xs_doublemagic);
|
||||||
|
static int32 xs_ToInt (real64 val, real64 dme = -_xs_doublemagicroundeps);
|
||||||
|
static int32 xs_FloorToInt (real64 val, real64 dme = _xs_doublemagicroundeps);
|
||||||
|
static int32 xs_CeilToInt (real64 val, real64 dme = _xs_doublemagicroundeps);
|
||||||
|
static int32 xs_RoundToInt (real64 val);
|
||||||
|
|
||||||
|
//int32 versions
|
||||||
|
finline static int32 xs_CRoundToInt (int32 val) {return val;}
|
||||||
|
finline static int32 xs_ToInt (int32 val) {return val;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
// Fix Class
|
||||||
|
// ====================================================================================================================
|
||||||
|
template <int32 N> class xs_Fix
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef int32 Fix;
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
// Basic Conversion from Numbers
|
||||||
|
// ====================================================================================================================
|
||||||
|
finline static Fix ToFix (int32 val) {return val<<N;}
|
||||||
|
finline static Fix ToFix (real64 val) {return xs_ConvertToFixed(val);}
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
// Basic Conversion to Numbers
|
||||||
|
// ====================================================================================================================
|
||||||
|
finline static real64 ToReal (Fix f) {return real64(f)/real64(1<<N);}
|
||||||
|
finline static int32 ToInt (Fix f) {return f>>N;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// ====================================================================================================================
|
||||||
|
// Helper function - mainly to preserve _xs_DEFAULT_CONVERSION
|
||||||
|
// ====================================================================================================================
|
||||||
|
finline static int32 xs_ConvertToFixed (real64 val)
|
||||||
|
{
|
||||||
|
#if _xs_DEFAULT_CONVERSION==0
|
||||||
|
return xs_CRoundToInt(val, _xs_doublemagic/(1<<N));
|
||||||
|
#else
|
||||||
|
return (long)((val)*(1<<N));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
// ====================================================================================================================
|
||||||
|
// Inline implementation
|
||||||
|
// ====================================================================================================================
|
||||||
|
// ====================================================================================================================
|
||||||
|
finline static int32 xs_CRoundToInt(real64 val, real64 dmr)
|
||||||
|
{
|
||||||
|
#if _xs_DEFAULT_CONVERSION==0
|
||||||
|
_xs_doubleints uval;
|
||||||
|
uval.val = val + dmr;
|
||||||
|
return uval.ival[_xs_iman_];
|
||||||
|
#else
|
||||||
|
return int32(floor(val+.5));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
finline static int32 xs_ToInt(real64 val, real64 dme)
|
||||||
|
{
|
||||||
|
/* unused - something else I tried...
|
||||||
|
_xs_doublecopysgn(dme,val);
|
||||||
|
return xs_CRoundToInt(val+dme);
|
||||||
|
return 0;
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1400
|
||||||
|
// VC++ 2005's standard cast is a little bit faster than this
|
||||||
|
// magic number code. (Which is pretty amazing!) SSE has the
|
||||||
|
// fastest C-style float->int conversion, but unfortunately,
|
||||||
|
// checking for SSE support every time you need to do a
|
||||||
|
// conversion completely negates its performance advantage.
|
||||||
|
return int32(val);
|
||||||
|
#else
|
||||||
|
#if _xs_DEFAULT_CONVERSION==0
|
||||||
|
return (val<0) ? xs_CRoundToInt(val-dme) :
|
||||||
|
xs_CRoundToInt(val+dme);
|
||||||
|
#else
|
||||||
|
return int32(val);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
finline static int32 xs_FloorToInt(real64 val, real64 dme)
|
||||||
|
{
|
||||||
|
#if _xs_DEFAULT_CONVERSION==0
|
||||||
|
return xs_CRoundToInt (val - dme);
|
||||||
|
#else
|
||||||
|
return floor(val);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
finline static int32 xs_CeilToInt(real64 val, real64 dme)
|
||||||
|
{
|
||||||
|
#if _xs_DEFAULT_CONVERSION==0
|
||||||
|
return xs_CRoundToInt (val + dme);
|
||||||
|
#else
|
||||||
|
return ceil(val);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
finline static int32 xs_RoundToInt(real64 val)
|
||||||
|
{
|
||||||
|
#if _xs_DEFAULT_CONVERSION==0
|
||||||
|
// Yes, it is important that two fadds be generated, so you cannot override the dmr
|
||||||
|
// passed to xs_CRoundToInt with _xs_doublemagic + _xs_doublemagicdelta. If you do,
|
||||||
|
// you'll end up with Banker's Rounding again.
|
||||||
|
return xs_CRoundToInt (val + _xs_doublemagicdelta);
|
||||||
|
#else
|
||||||
|
return floor(val+.5);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
// ====================================================================================================================
|
||||||
|
// Unsigned variants
|
||||||
|
// ====================================================================================================================
|
||||||
|
// ====================================================================================================================
|
||||||
|
finline static uint32 xs_CRoundToUInt(real64 val)
|
||||||
|
{
|
||||||
|
return (uint32)xs_CRoundToInt(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
finline static uint32 xs_FloorToUInt(real64 val)
|
||||||
|
{
|
||||||
|
return (uint32)xs_FloorToInt(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
finline static uint32 xs_CeilToUInt(real64 val)
|
||||||
|
{
|
||||||
|
return (uint32)xs_CeilToUInt(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
finline static uint32 xs_RoundToUInt(real64 val)
|
||||||
|
{
|
||||||
|
return (uint32)xs_RoundToInt(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ====================================================================================================================
|
||||||
|
// ====================================================================================================================
|
||||||
|
#endif // _xs_FLOAT_H_
|
Loading…
Add table
Add a link
Reference in a new issue