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

Add ShapeVars helper type; use it in rendering + meshing #190

Merged
merged 5 commits into from
Nov 17, 2024
Merged

Conversation

mkeeter
Copy link
Owner

@mkeeter mkeeter commented Nov 17, 2024

Fixes #182 and #183

See the CHANGELOG diff for details

@mkeeter
Copy link
Owner Author

mkeeter commented Nov 17, 2024

cc @waywardmonkeys for review; I can't tag you directly until you accept the invite and join the project as a collaborator 😄

fidget/src/mesh/octree.rs Show resolved Hide resolved
@@ -158,7 +167,16 @@ impl VoxelRenderConfig {
&self,
shape: Shape<F>,
) -> (Vec<u32>, Vec<[u8; 3]>) {
crate::render::render3d::<F>(shape, self)
self.run_with_vars::<F>(shape, &Default::default())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sometimes you're using ShapeVars::default() and sometimes Default::default(). Can it always just be ShapeVars::default() for consistency and readability?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good point – I started using ShapeVars::new() instead, since it's slightly shorter.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated
functions for shapes with supplementary variables
- Change `ShapeBulkEval::eval_v` to take **single** variables (i.e. `x`, `y`,
`z` vary but each variables are contant). Add `ShapeBulkEval::eval_vs` if
`x`, `y`, `z` and variables are _all_ changing through the slices.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This part is just confusing to me, but maybe because it is late at night. But maybe expand a bit somewhere? (The comments on eval_vs didn't help me either.)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Added some more comments to the eval_v and eval_vs docstrings

/// Note that this cannot store `X`, `Y`, `Z` variables (which are passed in as
/// first-class arguments); it only stores [`Var::V`] values (identified by
/// their inner [`VarIndex`]).
pub struct ShapeVars<F>(HashMap<VarIndex, F>);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this using a HashMap an intermediate step along the way to using a Vec / smallvec?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Perhaps! I'm inclined to leave it until someone starts noticing it gating performance, which I suspect is a long ways off.

@mkeeter mkeeter enabled auto-merge (squash) November 17, 2024 19:53
@mkeeter mkeeter merged commit 3b94b8c into main Nov 17, 2024
13 checks passed
@mkeeter mkeeter deleted the shape-vars branch November 17, 2024 19:56
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.

Representation of sets of variables
2 participants