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
85c53b35
Commit
85c53b35
authored
4 years ago
by
Lactozilla
Browse files
Options
Downloads
Patches
Plain Diff
Use old routine for PO2 spans
parent
d5e9005d
No related branches found
No related tags found
1 merge request
!1464
Fix slope plane rotation and alignment (resolves #508)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/r_plane.c
+76
-32
76 additions, 32 deletions
src/r_plane.c
with
76 additions
and
32 deletions
src/r_plane.c
+
76
−
32
View file @
85c53b35
...
@@ -789,6 +789,78 @@ static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_
...
@@ -789,6 +789,78 @@ static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_
R_CalculateSlopeVectors
();
R_CalculateSlopeVectors
();
}
}
/*
Essentially: We can't & the components along the regular axes when the plane is rotated.
This is because the distance on each regular axis in order to loop is different.
We rotate them, & the components, add them together, & them again, and then rotate them back.
These three seperate & operations are done per axis in order to prevent overflows.
toast 10/04/17
*/
static
inline
void
R_AdjustSlopeCoordinates
(
visplane_t
*
pl
)
{
const
fixed_t
modmask
=
((
1
<<
(
32
-
nflatshiftup
))
-
1
);
const
fixed_t
cosinecomponent
=
FINECOSINE
(
pl
->
plangle
>>
ANGLETOFINESHIFT
);
const
fixed_t
sinecomponent
=
FINESINE
(
pl
->
plangle
>>
ANGLETOFINESHIFT
);
fixed_t
ox
=
(
FixedMul
(
pl
->
slope
->
o
.
x
,
cosinecomponent
)
&
modmask
)
-
(
FixedMul
(
pl
->
slope
->
o
.
y
,
sinecomponent
)
&
modmask
);
fixed_t
oy
=
(
-
FixedMul
(
pl
->
slope
->
o
.
x
,
sinecomponent
)
&
modmask
)
-
(
FixedMul
(
pl
->
slope
->
o
.
y
,
cosinecomponent
)
&
modmask
);
fixed_t
temp
=
ox
&
modmask
;
oy
&=
modmask
;
ox
=
FixedMul
(
temp
,
cosinecomponent
)
+
FixedMul
(
oy
,
-
sinecomponent
);
// negative sine for opposite direction
oy
=
-
FixedMul
(
temp
,
-
sinecomponent
)
+
FixedMul
(
oy
,
cosinecomponent
);
if
(
xoffs
||
yoffs
)
{
temp
=
xoffs
;
xoffs
=
(
FixedMul
(
temp
,
cosinecomponent
)
&
modmask
)
+
(
FixedMul
(
yoffs
,
sinecomponent
)
&
modmask
);
yoffs
=
(
-
FixedMul
(
temp
,
sinecomponent
)
&
modmask
)
+
(
FixedMul
(
yoffs
,
cosinecomponent
)
&
modmask
);
temp
=
xoffs
&
modmask
;
yoffs
&=
modmask
;
xoffs
=
FixedMul
(
temp
,
cosinecomponent
)
+
FixedMul
(
yoffs
,
-
sinecomponent
);
// ditto
yoffs
=
-
FixedMul
(
temp
,
-
sinecomponent
)
+
FixedMul
(
yoffs
,
cosinecomponent
);
}
xoffs
-=
(
pl
->
slope
->
o
.
x
-
ox
);
yoffs
+=
(
pl
->
slope
->
o
.
y
+
oy
);
}
static
inline
void
R_AdjustSlopeCoordinatesNPO2
(
visplane_t
*
pl
)
{
const
fixed_t
modmaskw
=
(
ds_flatwidth
<<
FRACBITS
);
const
fixed_t
modmaskh
=
(
ds_flatheight
<<
FRACBITS
);
const
fixed_t
cosinecomponent
=
FINECOSINE
(
pl
->
plangle
>>
ANGLETOFINESHIFT
);
const
fixed_t
sinecomponent
=
FINESINE
(
pl
->
plangle
>>
ANGLETOFINESHIFT
);
fixed_t
ox
=
(
FixedMul
(
pl
->
slope
->
o
.
x
,
cosinecomponent
)
%
modmaskw
)
-
(
FixedMul
(
pl
->
slope
->
o
.
y
,
sinecomponent
)
%
modmaskh
);
fixed_t
oy
=
(
-
FixedMul
(
pl
->
slope
->
o
.
x
,
sinecomponent
)
%
modmaskw
)
-
(
FixedMul
(
pl
->
slope
->
o
.
y
,
cosinecomponent
)
%
modmaskh
);
fixed_t
temp
=
ox
%
modmaskw
;
oy
%=
modmaskh
;
ox
=
FixedMul
(
temp
,
cosinecomponent
)
+
FixedMul
(
oy
,
-
sinecomponent
);
// negative sine for opposite direction
oy
=
-
FixedMul
(
temp
,
-
sinecomponent
)
+
FixedMul
(
oy
,
cosinecomponent
);
if
(
xoffs
||
yoffs
)
{
temp
=
xoffs
;
xoffs
=
(
FixedMul
(
temp
,
cosinecomponent
)
%
modmaskw
)
+
(
FixedMul
(
yoffs
,
sinecomponent
)
%
modmaskh
);
yoffs
=
(
-
FixedMul
(
temp
,
sinecomponent
)
%
modmaskw
)
+
(
FixedMul
(
yoffs
,
cosinecomponent
)
%
modmaskh
);
temp
=
xoffs
%
modmaskw
;
yoffs
%=
modmaskh
;
xoffs
=
FixedMul
(
temp
,
cosinecomponent
)
+
FixedMul
(
yoffs
,
-
sinecomponent
);
// ditto
yoffs
=
-
FixedMul
(
temp
,
-
sinecomponent
)
+
FixedMul
(
yoffs
,
cosinecomponent
);
}
xoffs
-=
(
pl
->
slope
->
o
.
x
-
ox
);
yoffs
+=
(
pl
->
slope
->
o
.
y
+
oy
);
}
void
R_DrawSinglePlane
(
visplane_t
*
pl
)
void
R_DrawSinglePlane
(
visplane_t
*
pl
)
{
{
levelflat_t
*
levelflat
;
levelflat_t
*
levelflat
;
...
@@ -967,38 +1039,10 @@ void R_DrawSinglePlane(visplane_t *pl)
...
@@ -967,38 +1039,10 @@ void R_DrawSinglePlane(visplane_t *pl)
if
(
pl
->
slope
)
if
(
pl
->
slope
)
{
{
const
fixed_t
modmaskw
=
(
ds_powersoftwo
)
?
(
ds_flatwidth
<<
FRACBITS
)
-
1
:
(
signed
)(
0xFFFFFFFF
);
if
(
ds_powersoftwo
)
const
fixed_t
modmaskh
=
(
ds_powersoftwo
)
?
(
ds_flatheight
<<
FRACBITS
)
-
1
:
(
signed
)(
0xFFFFFFFF
);
R_AdjustSlopeCoordinates
(
pl
);
else
/*
R_AdjustSlopeCoordinatesNPO2
(
pl
);
Essentially: We can't & the components along the regular axes when the plane is rotated.
This is because the distance on each regular axis in order to loop is different.
We rotate them, & the components, add them together, & them again, and then rotate them back.
These three seperate & operations are done per axis in order to prevent overflows.
toast 10/04/17
*/
const
fixed_t
cosinecomponent
=
FINECOSINE
(
pl
->
plangle
>>
ANGLETOFINESHIFT
);
const
fixed_t
sinecomponent
=
FINESINE
(
pl
->
plangle
>>
ANGLETOFINESHIFT
);
fixed_t
ox
=
(
FixedMul
(
pl
->
slope
->
o
.
x
,
cosinecomponent
)
&
modmaskw
)
-
(
FixedMul
(
pl
->
slope
->
o
.
y
,
sinecomponent
)
&
modmaskh
);
fixed_t
oy
=
(
-
FixedMul
(
pl
->
slope
->
o
.
x
,
sinecomponent
)
&
modmaskw
)
-
(
FixedMul
(
pl
->
slope
->
o
.
y
,
cosinecomponent
)
&
modmaskh
);
fixed_t
temp
=
ox
&
modmaskw
;
oy
&=
modmaskh
;
ox
=
FixedMul
(
temp
,
cosinecomponent
)
+
FixedMul
(
oy
,
-
sinecomponent
);
// negative sine for opposite direction
oy
=
-
FixedMul
(
temp
,
-
sinecomponent
)
+
FixedMul
(
oy
,
cosinecomponent
);
temp
=
xoffs
;
xoffs
=
(
FixedMul
(
temp
,
cosinecomponent
)
&
modmaskw
)
+
(
FixedMul
(
yoffs
,
sinecomponent
)
&
modmaskh
);
yoffs
=
(
-
FixedMul
(
temp
,
sinecomponent
)
&
modmaskw
)
+
(
FixedMul
(
yoffs
,
cosinecomponent
)
&
modmaskh
);
temp
=
xoffs
&
modmaskw
;
yoffs
&=
modmaskh
;
xoffs
=
FixedMul
(
temp
,
cosinecomponent
)
+
FixedMul
(
yoffs
,
-
sinecomponent
);
// ditto
yoffs
=
-
FixedMul
(
temp
,
-
sinecomponent
)
+
FixedMul
(
yoffs
,
cosinecomponent
);
xoffs
-=
(
pl
->
slope
->
o
.
x
-
ox
);
yoffs
+=
(
pl
->
slope
->
o
.
y
+
oy
);
if
(
planeripple
.
active
)
if
(
planeripple
.
active
)
{
{
...
...
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