Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
a0ec86ce
Commit
a0ec86ce
authored
5 years ago
by
Lactozilla
Browse files
Options
Downloads
Patches
Plain Diff
Fix powers-of-two checks
parent
e3df9cc6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/r_plane.c
+30
-18
30 additions, 18 deletions
src/r_plane.c
with
30 additions
and
18 deletions
src/r_plane.c
+
30
−
18
View file @
a0ec86ce
...
@@ -652,12 +652,18 @@ static void R_DrawSkyPlane(visplane_t *pl)
...
@@ -652,12 +652,18 @@ static void R_DrawSkyPlane(visplane_t *pl)
boolean
R_CheckPowersOfTwo
(
void
)
boolean
R_CheckPowersOfTwo
(
void
)
{
{
if
(
ds_flatwidth
&
(
ds_flatwidth
-
1
))
boolean
wpow2
=
(
!
(
ds_flatwidth
&
(
ds_flatwidth
-
1
)));
ds_powersoftwo
=
false
;
boolean
hpow2
=
(
!
(
ds_flatheight
&
(
ds_flatheight
-
1
)));
else
if
(
ds_flatheight
&
(
ds_flatheight
-
1
))
ds_powersoftwo
=
false
;
// Initially, the flat isn't powers-of-two-sized.
else
if
(
ds_flatwidth
==
ds_flatheight
)
ds_powersoftwo
=
false
;
// But if the width and height are powers of two,
// and are EQUAL, then it's okay :]
if
((
ds_flatwidth
==
ds_flatheight
)
&&
(
wpow2
&&
hpow2
))
ds_powersoftwo
=
true
;
ds_powersoftwo
=
true
;
// Just return ds_powersoftwo.
return
ds_powersoftwo
;
return
ds_powersoftwo
;
}
}
...
@@ -806,6 +812,7 @@ void R_DrawSinglePlane(visplane_t *pl)
...
@@ -806,6 +812,7 @@ void R_DrawSinglePlane(visplane_t *pl)
size_t
size
;
size_t
size
;
ffloor_t
*
rover
;
ffloor_t
*
rover
;
levelflat_t
*
levelflat
;
levelflat_t
*
levelflat
;
boolean
rawflat
=
false
;
if
(
!
(
pl
->
minx
<=
pl
->
maxx
))
if
(
!
(
pl
->
minx
<=
pl
->
maxx
))
return
;
return
;
...
@@ -968,6 +975,7 @@ void R_DrawSinglePlane(visplane_t *pl)
...
@@ -968,6 +975,7 @@ void R_DrawSinglePlane(visplane_t *pl)
// It's a raw flat.
// It's a raw flat.
else
else
{
{
rawflat
=
true
;
R_CheckFlatLength
(
size
);
R_CheckFlatLength
(
size
);
flat
=
ds_source
;
flat
=
ds_source
;
}
}
...
@@ -978,8 +986,11 @@ void R_DrawSinglePlane(visplane_t *pl)
...
@@ -978,8 +986,11 @@ void R_DrawSinglePlane(visplane_t *pl)
if
(
ds_source
==
NULL
)
if
(
ds_source
==
NULL
)
return
;
return
;
// Check if the flat has dimensions that are powers-of-two numbers.
// Raw flats always have dimensions that are powers-of-two numbers.
if
(
R_CheckPowersOfTwo
())
if
(
rawflat
)
ds_powersoftwo
=
true
;
// Otherwise, check if this texture or patch has such dimensions.
else
if
(
R_CheckPowersOfTwo
())
{
{
R_CheckFlatLength
(
ds_flatwidth
*
ds_flatheight
);
R_CheckFlatLength
(
ds_flatwidth
*
ds_flatheight
);
if
(
spanfunc
==
basespanfunc
)
if
(
spanfunc
==
basespanfunc
)
...
@@ -1116,26 +1127,27 @@ void R_DrawSinglePlane(visplane_t *pl)
...
@@ -1116,26 +1127,27 @@ void R_DrawSinglePlane(visplane_t *pl)
ds_sz
.
z
*=
focallengthf
;
ds_sz
.
z
*=
focallengthf
;
// Premultiply the texture vectors with the scale factors
// Premultiply the texture vectors with the scale factors
#define SFMULT 65536.f
if
(
ds_powersoftwo
)
if
(
ds_powersoftwo
)
{
{
#define SFMULT 65536.f*(1<<nflatshiftup)
ds_su
.
x
*=
(
SFMULT
*
(
1
<<
nflatshiftup
));
ds_su
.
y
*=
(
SFMULT
*
(
1
<<
nflatshiftup
));
ds_su
.
z
*=
(
SFMULT
*
(
1
<<
nflatshiftup
));
ds_sv
.
x
*=
(
SFMULT
*
(
1
<<
nflatshiftup
));
ds_sv
.
y
*=
(
SFMULT
*
(
1
<<
nflatshiftup
));
ds_sv
.
z
*=
(
SFMULT
*
(
1
<<
nflatshiftup
));
}
else
{
// I'm essentially multiplying the vectors by FRACUNIT...
ds_su
.
x
*=
SFMULT
;
ds_su
.
x
*=
SFMULT
;
ds_su
.
y
*=
SFMULT
;
ds_su
.
y
*=
SFMULT
;
ds_su
.
z
*=
SFMULT
;
ds_su
.
z
*=
SFMULT
;
ds_sv
.
x
*=
SFMULT
;
ds_sv
.
x
*=
SFMULT
;
ds_sv
.
y
*=
SFMULT
;
ds_sv
.
y
*=
SFMULT
;
ds_sv
.
z
*=
SFMULT
;
ds_sv
.
z
*=
SFMULT
;
#undef SFMULT
}
else
{
ds_su
.
x
*=
65536
.
f
;
ds_su
.
y
*=
65536
.
f
;
ds_su
.
z
*=
65536
.
f
;
ds_sv
.
x
*=
65536
.
f
;
ds_sv
.
y
*=
65536
.
f
;
ds_sv
.
z
*=
65536
.
f
;
}
}
#undef SFMULT
if
(
spanfunc
==
R_DrawTranslucentSpan_8
)
if
(
spanfunc
==
R_DrawTranslucentSpan_8
)
spanfunc
=
R_DrawTiltedTranslucentSpan_8
;
spanfunc
=
R_DrawTiltedTranslucentSpan_8
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment