Bounding Box and ShapeNumber-Image questions
Long, long time ago I experimented with libfive, but because it wasn’t written in Rust it was not a good fit for my use case and workflow. Now we have fidget and I like it very much. I started tinkering around towards a 3D graphical editor which syncs with script code. Right now is just a slightly modified viewer demo, where one can mouse select the different shapes (and later, the idea is to allow operations on the selected shapes)
The first question I have: How can we get bounding box of a shape ? Unless there is a better way to do it, I need the bounding boxes for centering and scaling-to-fill-the-view of the shapes. In mesh based modeling we just iterate through the vertices to find min and max for each dimension. In case it is non-trivial in fidget, I thought one could just turn shapes into a mesh (if it is fast enough now), but I hope there is a better direct way.
The other issue is more like a suggestion, somehow related to PR https://github.com/mkeeter/fidget/pull/282
On the rendered shapes on screen, to associate a mouse click position with a shape, I keep the following data structure:
/// Single-channel shape-number image
pub type ShapeImage = fidget::render::Image<Option<u16>>;
Would it make sense to make such a definition part of fidget, like the depth and norm maps ? I think, for any kind of UI interaction with rendered shapes something like this is needed.
I'm glad to hear about people playing with Fidget!
The first question I have: How can we get bounding box of a shape ?
I'm not sure there's a strategy for doing this in the general case: if someone hands you a large math expression, how would you prove that it could never be less than zero somewhere off in the far distance? In the past, I've tried to do interval evaluation with half-infinite intervals (e.g. x,y,z = [100, +infinity]), but have found it hard to get useful bounds.
If you're building shapes from known primitives (spheres, cubes, etc), then you could track that metadata. Otherwise, I've always had users specify their bounds for meshing and rendering.
Would it make sense to make such a definition part of fidget, like the depth and norm maps ?
Possibly! I've been thinking about a first-class Tag type, which could be used as metadata in math expressions (i.e. a Op::Tag(Expression, Tag) which propagates its first argument), but I need to do some more experiments to decide how it would be useful.