Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2Classic
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
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
chromaticpipe
SRB2Classic
Commits
3c39edc1
Commit
3c39edc1
authored
7 months ago
by
Hanicef
Browse files
Options
Downloads
Patches
Plain Diff
Fall back to old algorithm when on the line
parent
a90f495b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/r_main.c
+49
-0
49 additions, 0 deletions
src/r_main.c
src/r_main.h
+11
-2
11 additions, 2 deletions
src/r_main.h
with
60 additions
and
2 deletions
src/r_main.c
+
49
−
0
View file @
3c39edc1
...
...
@@ -246,6 +246,55 @@ static void FlipCam2_OnChange(void)
SendWeaponPref2
();
}
//
// R_PointOnSide
// Traverse BSP (sub) tree,
// check point against partition plane.
// Returns side 0 (front) or 1 (back).
//
// killough 5/2/98: reformatted
//
INT32
R_OldPointOnSide
(
fixed_t
x
,
fixed_t
y
,
node_t
*
restrict
node
)
{
if
(
!
node
->
dx
)
return
x
<=
node
->
x
?
node
->
dy
>
0
:
node
->
dy
<
0
;
if
(
!
node
->
dy
)
return
y
<=
node
->
y
?
node
->
dx
<
0
:
node
->
dx
>
0
;
fixed_t
dx
=
(
x
>>
1
)
-
(
node
->
x
>>
1
);
fixed_t
dy
=
(
y
>>
1
)
-
(
node
->
y
>>
1
);
// Try to quickly decide by looking at sign bits.
// also use a mask to avoid branch prediction
INT32
mask
=
(
node
->
dy
^
node
->
dx
^
dx
^
dy
)
>>
31
;
return
(
mask
&
((
node
->
dy
^
dx
)
<
0
))
|
// (left is negative)
(
~
mask
&
(
FixedMul
(
dy
,
node
->
dx
>>
FRACBITS
)
>=
FixedMul
(
node
->
dy
>>
FRACBITS
,
dx
)));
}
// killough 5/2/98: reformatted
INT32
R_OldPointOnSegSide
(
fixed_t
x
,
fixed_t
y
,
seg_t
*
line
)
{
fixed_t
lx
=
line
->
v1
->
x
;
fixed_t
ly
=
line
->
v1
->
y
;
fixed_t
ldx
=
line
->
v2
->
x
-
lx
;
fixed_t
ldy
=
line
->
v2
->
y
-
ly
;
if
(
!
ldx
)
return
x
<=
lx
?
ldy
>
0
:
ldy
<
0
;
if
(
!
ldy
)
return
y
<=
ly
?
ldx
<
0
:
ldx
>
0
;
fixed_t
dx
=
(
x
>>
1
)
-
(
lx
>>
1
);
fixed_t
dy
=
(
y
>>
1
)
-
(
ly
>>
1
);
// Try to quickly decide by looking at sign bits.
if
((
ldy
^
ldx
^
dx
^
dy
)
<
0
)
return
(
ldy
^
dx
)
<
0
;
// (left is negative)
return
FixedMul
(
dy
,
ldx
>>
FRACBITS
)
>=
FixedMul
(
ldy
>>
FRACBITS
,
dx
);
}
//
// R_PointToAngle
// To get a global angle from cartesian coordinates,
...
...
This diff is collapsed.
Click to expand it.
src/r_main.h
+
11
−
2
View file @
3c39edc1
...
...
@@ -71,11 +71,17 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
#define NUMCOLORMAPS 32
INT32
R_OldPointOnSide
(
fixed_t
x
,
fixed_t
y
,
node_t
*
node
);
INT32
R_OldPointOnSegSide
(
fixed_t
x
,
fixed_t
y
,
seg_t
*
line
);
// Utility functions.
static
inline
INT32
R_PointOnSide
(
fixed_t
x
,
fixed_t
y
,
node_t
*
node
)
{
// use cross product to determine side quickly
return
((
INT64
)
y
-
node
->
y
)
*
node
->
dx
-
((
INT64
)
x
-
node
->
x
)
*
node
->
dy
>
0
;
INT64
v
=
((
INT64
)
y
-
node
->
y
)
*
node
->
dx
-
((
INT64
)
x
-
node
->
x
)
*
node
->
dy
;
if
(
v
==
0
)
// if we're on the line, use the old algorithm
return
R_OldPointOnSide
(
x
,
y
,
node
);
return
v
>
0
;
}
static
inline
INT32
R_PointOnSegSide
(
fixed_t
x
,
fixed_t
y
,
seg_t
*
line
)
...
...
@@ -86,7 +92,10 @@ static inline INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line)
fixed_t
ldy
=
line
->
v2
->
y
-
ly
;
// use cross product to determine side quickly
return
((
INT64
)
y
-
ly
)
*
ldx
-
((
INT64
)
x
-
lx
)
*
ldy
>
0
;
INT64
v
=
((
INT64
)
y
-
ly
)
*
ldx
-
((
INT64
)
x
-
lx
)
*
ldy
>
0
;
if
(
v
==
0
)
// if we're on the line, use the old algorithm
return
R_OldPointOnSegSide
(
x
,
y
,
line
);
return
v
>
0
;
}
angle_t
R_PointToAngle
(
fixed_t
x
,
fixed_t
y
);
...
...
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