Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements "noncar" physics #122

Merged
merged 14 commits into from
May 3, 2022
Merged

Implements "noncar" physics #122

merged 14 commits into from
May 3, 2022

Conversation

dethrace-labs
Copy link
Owner

NonCars are what the game calls pieces of the track that you can interact with. For example, streetlights can be bent and snapped off, benches can be pushed around etc.

  • Implements all the physics functions required for this to work
  • Uncomments RemoveDoubleSided
  • Fixes auto-generated br_material and br_model structs to align better with real usage
  • Culling globally disabled in gl_renderer to fix issues with streetlights not rendering from all angles. This matches what we know of the 3dfx version, for example.
noncarphysics.short.mp4

Copy link
Collaborator

@madebr madebr left a comment

Choose a reason for hiding this comment

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

Super!

Comment on lines 58 to 65
#define BrVector3Mul(v1, v2, v3) \
do { \
(v1)->v[0] = (v2)->v[0] * (v3)->v[0]; \
(v1)->v[1] = (v2)->v[1] * (v3)->v[1]; \
(v1)->v[2] = (v2)->v[2] * (v3)->v[2]; \
} while (0)

#define BrVector3Div(v1, v2, v3) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

These functions/macro's are not documented in the brender documentation, from foone.
I would move these to a dethrace header and loose the Br prefix.
This would also keep dethrace working, with (the soon-to-be-open-sourced 🤞) real BRender.

I was not 100% confident though about the naming: vector's already have dot + cross multiplication, and a divide simply does not exist.

But some googling shows me that other engines have added is nonetheless, it's a convenience to have.

unity3 has:
I googled a bit and found this for unity: https://docs.unity3d.com/ScriptReference/Vector3.Scale.html
C# has:
https://docs.microsoft.com/en-us/dotnet/api/system.numerics.vector3.multiply?view=net-6.0
https://docs.microsoft.com/en-us/dotnet/api/system.numerics.vector3.divide?view=net-6.0
UnrealScript allowed vect(1,2,3) * vect(2,3,4) = vect(2,6,12):
https://wiki.beyondunreal.com/Legacy:UnrealScript_Vector_Maths

Copy link
Owner Author

Choose a reason for hiding this comment

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

yes, good call. I was being lazy :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

To be clear, I"m fine with adding these.
I want to be lazy too :D

Copy link
Owner Author

Choose a reason for hiding this comment

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

no, thank you for pointing it out! I'm making the change as you suggest!

#define DOUBLESIDED_FLAG_COLOR_MAP (br_pixelmap*)12345
#define DOUBLESIDED_USER_FLAG (void*)12345
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps we need to do something as following?

typedef struct {
    int flags;
} dethrace_material_props;

#define DR_MATUFLAGS_DOUBLE_SIDED 0x01

A nuisance with this approach is the need for allocation, but should be do-able when using BrResAllocate (which will automatically de-allocate when the parent is de-allocated).

Copy link
Owner Author

Choose a reason for hiding this comment

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

your idea is better in all ways :)

However, since (void*)12345 is what the OG code does, I'd leave refactoring to be cleaner to a different repo/branch

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, then it's totally fine. I thought this was custom code to fix the lanterns.

Copy link
Owner Author

Choose a reason for hiding this comment

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

ah cool. Yeah, I'm holding firm to any code in src/DETHRACE that doesn't come from OG has to be wrapped in the FIX_BUGS macro

dethrace-labs and others added 3 commits May 3, 2022 13:32
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
@dethrace-labs dethrace-labs merged commit 2db34d2 into main May 3, 2022
@dethrace-labs dethrace-labs deleted the noncar-physics branch May 3, 2022 02:05
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