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

A little bit QoL cleaning up... #84

Merged
merged 6 commits into from
Mar 7, 2024
Merged

Conversation

Richardn2002
Copy link
Collaborator

...that I believe could benefit main before I finish ecs stuff on my own branch.

Put data def and parsing code to proper places:

  • try_from() and associated error types for string->enum mappings should go under format/
  • node data should all be defined under node/

`try_from()` and associated error types for string->enum mappings should go under format/
node data should all be defined under node/
I am sorry.
Copy link
Member

@Speykious Speykious left a comment

Choose a reason for hiding this comment

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

Not sold on most of these changes.

The introduction of the enums module is confusing because it doesn't mean anything in particular in regards to the implementation, it just stores various TryFrom implementations that happen to be currently used by the payload module. If you put it there because you want to signify that it's for deserializing, we might as well replace these impls with deserialize_[EnumType] functions within payload and remove enums, because a TryFrom implementation conveys more meaning than its current use case.

I disagree with moving TransformOffset and InterpMode to node::data. At this stage Matrix would get in there too. It would just put the structs further away from their implementation blocks. I think it's completely fine that someone coming to the codebase excepts TransformOffset to be in the transform module.

inox2d/src/math/transform.rs Outdated Show resolved Hide resolved
inox2d/src/math/interp.rs Outdated Show resolved Hide resolved
@Richardn2002
Copy link
Collaborator Author

Rationale for enum.rs: There are tons of reserved strings that carry a meaning according to the standard. These namings for enum variants make up a portion of such reserved strings. Namings for json fields make up the rest of such reserved strings.
And these reserved strings should all go under format/ apparently as they are related to the format. Any mistake (for example that angle length bug just resolved recently) or future extension of formats introducing new variants, should be able to be resolved in a way that is localized under format/.
Not to say all the UnknownXXXError error types are only used in payload.rs.

I am fine with file renames or putting the try_from to other places, but I believe these try_from s should be localized.

@Richardn2002
Copy link
Collaborator Author

On where to put TransformOffset and InterpolateMode, my rationale is, put all data that makes up nodes under node/, preparing for defining components under node/. And math merely provides helper functions on how to manipulate data, instead of being the definers of data.

Like, PhysicsModel and PhysicsState are under node, while actual physics calculations are outside, under physics.

Copy link
Member

@Speykious Speykious left a comment

Choose a reason for hiding this comment

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

Looking great now :D
Love it when less code does the same thing.

@Speykious Speykious merged commit 72d6cea into Inochi2D:main Mar 7, 2024
11 checks passed
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