Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@fjtrujy
Copy link
Member

@fjtrujy fjtrujy commented Jun 8, 2025

Description

Some improvements around the sceguLight* functions:

  • Keeps removing magic numbers
  • Reduce the static memory used
  • Makes more readable each sceGuLight* implementation
  • Some other minor changes

Cheers

Copy link
Member

@sharkwouter sharkwouter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still some changes in the result of the new code compared to the old code. You can see this in the gu/lights example.

sendCommandf(settings->zpos,position->z);
if (components == GU_POWERED_DIFFUSE) {
ctype = GU_DIFFUSE_AND_SPECULAR;
} else if (components == GU_DIFFUSE_AND_SPECULAR) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (components == GU_DIFFUSE_AND_SPECULAR) {
} else if (components == GU_DIFFUSE_AND_SPECULAR || components == 0) {

Otherwise the result will be different if the value given is 0.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that sending 0 should use just DIFFUSE

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code was kind = (components^6) < 1 ? 1 : 0;, which results in kind being set to 1 if components is set to 0 or 6. So setting it to DIFFUSE instead of DIFFUSE_AND_SPECULAR in the case of 0 would be an API change. Do you think the original behavior is a bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it looks a bug of our previous implementation…

@fjtrujy fjtrujy force-pushed the sceguLight branch 3 times, most recently from e9f4b4d to 3263b0c Compare June 9, 2025 15:11
@fjtrujy fjtrujy changed the title Improve sceGu functions Improve sceGuLight* functions Jun 9, 2025
@fjtrujy fjtrujy merged commit 5168b3f into pspdev:master Jun 9, 2025
1 check passed
@fjtrujy fjtrujy deleted the sceguLight branch June 9, 2025 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants