port R_PointToPseudoAngle for Opengl sector clipping from PrBoom+ #98

Closed
alufolie91 wants to merge 8 commits from pseudoangle into Saturn-Next
pull from: pseudoangle
alufolie91 commented 2024-02-01 01:18:22 +01:00 (Migrated from github.com)

this should speed up opengl sector clipping a bit
didnt notice any negative side effects or rendering issues at all but gave me a slight performance boost on certain maps that suffer from view distance related performance issue
Note: Software renderer wont use this as it kinda needs more precision/ somewhat exact angles or else itll break

R_PointToPseudoAngle
Returns the pseudoangle between the line p1 to (infinity, p1.y) and the
line from p1 to p2. The pseudoangle has the property that the ordering of
points by true angle anround p1 and ordering of points by pseudoangle are the
same.

For clipping exact angles are not needed. Only the ordering matters.
This is about as fast as the fixed point R_PointToAngle2 but without
the precision issues associated with that function.

this should speed up opengl sector clipping a bit didnt notice any negative side effects or rendering issues at all but gave me a slight performance boost on certain maps that suffer from view distance related performance issue Note: Software renderer wont use this as it kinda needs more precision/ somewhat exact angles or else itll break > R_PointToPseudoAngle > Returns the pseudoangle between the line p1 to (infinity, p1.y) and the > line from p1 to p2. The pseudoangle has the property that the ordering of > points by true angle anround p1 and ordering of points by pseudoangle are the > same. > > For clipping exact angles are not needed. Only the ordering matters. > This is about as fast as the fixed point R_PointToAngle2 but without > the precision issues associated with that function.
Indev450 (Migrated from github.com) approved these changes 2024-02-11 21:10:31 +01:00
Indev450 (Migrated from github.com) left a comment

Had no issues from short test, code wise looks good too

Had no issues from short test, code wise looks good too
alufolie91 (Migrated from github.com) reviewed 2024-02-12 07:35:55 +01:00
@@ -431,0 +470,4 @@
double vecy = (double)y - viewy;
double epsilon = 1e-9;
if (fabs(vecx) < epsilon && fabs(vecy) < epsilon)
alufolie91 (Migrated from github.com) commented 2024-02-12 07:35:55 +01:00

well im just a little unsure, it used to check if both vec are zero, which the compiler didnt like, but comparing if its smaller than 1e-9 epsilon should be fine?

well im just a little unsure, it used to check if both vec are zero, which the compiler didnt like, but comparing if its smaller than 1e-9 epsilon should be fine?
Indev450 (Migrated from github.com) reviewed 2024-02-12 11:15:45 +01:00
@@ -431,0 +470,4 @@
double vecy = (double)y - viewy;
double epsilon = 1e-9;
if (fabs(vecx) < epsilon && fabs(vecy) < epsilon)
Indev450 (Migrated from github.com) commented 2024-02-12 11:15:45 +01:00

Compiler complains because even though double is pretty precise, it is still not perfect so two numbers that are logically same might give you result that is very close to zero but not equals zero, so "double equals zero" will be false almost always. Tho here you can just change type from double to INT64 and check if it equals 0 (it will be faster and still correct since both y and viewy are fixed_t, which is integer)

Didn't pay attention to this part at first, my bad

Ok i need to always look at full code my bad again ><

Compiler complains because even though double is pretty precise, it is still not perfect so two numbers that are logically same might give you result that is very close to zero but not equals zero, so "double equals zero" will be false almost always. ~~Tho here you can just change type from double to INT64 and check if it equals 0 (it will be faster and still correct since both y and viewy are fixed_t, which is integer)~~ ~~Didn't pay attention to this part at first, my bad~~ Ok i need to always look at full code my bad again ><
alufolie91 (Migrated from github.com) reviewed 2024-02-12 14:21:24 +01:00
@@ -431,0 +470,4 @@
double vecy = (double)y - viewy;
double epsilon = 1e-9;
if (fabs(vecx) < epsilon && fabs(vecy) < epsilon)
alufolie91 (Migrated from github.com) commented 2024-02-12 14:21:24 +01:00

oki changed it to INT64
1186294931891953768

oki changed it to INT64 ![1186294931891953768](https://github.com/Indev450/SRB2Kart-Saturn/assets/136046486/9e31f7b9-bd04-42d8-864c-3b0406c77a9a)
alufolie91 (Migrated from github.com) reviewed 2024-02-12 14:34:53 +01:00
@@ -431,0 +470,4 @@
double vecy = (double)y - viewy;
double epsilon = 1e-9;
if (fabs(vecx) < epsilon && fabs(vecy) < epsilon)
alufolie91 (Migrated from github.com) commented 2024-02-12 14:34:53 +01:00

lmao nvm it broke everything

lmao nvm it broke everything
alufolie91 commented 2024-02-13 06:15:44 +01:00 (Migrated from github.com)

actually, after profiling some more, this actually seems slower than R_PointToAngle64 it doesent clip things well enough and while the function itself may be faster, it makes the game render alot more things making this optimization useless
(tho didnt compare to R_PointToAngleEX yet)
so im gonna close this

actually, after profiling some more, this actually seems slower than R_PointToAngle64 it doesent clip things well enough and while the function itself may be faster, it makes the game render alot more things making this optimization useless (tho didnt compare to R_PointToAngleEX yet) so im gonna close this

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: saturn/SRB2Kart-Saturn#98