-
Notifications
You must be signed in to change notification settings - Fork 945
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
Accessor methods for geom::Primitives? #1176
Comments
I'm open to this - does anybody else have an opinion? |
To be honest, I am opposed to this. The classes in the I would personally like to see a few clean, small classes just for intersection and collision purposes, in the cinder namespace, or a different namespace altogether. Apart from With that being said, I see no reason why we would not offer simple conversion operators, e.g. from |
Thanks for your feedback guys, That said I'd be happy working on what we think would be the right approach (isn't this the right moment to bring back If we go that road, I guess it would be good to have a base class or at least a shared common interface. Probably something along those lines (based on bool contains( const vec3 &point ) const;
bool intersects( const Primitive &other ) const;
bool intersects( const Ray &ray ) const;
int intersect( const Ray &ray, float *min, float *max ) const;
void transform( const mat4 &transform );
Primitive transformed( const mat4 &transform ) const; And obviously add the new types to our So again this merely my two cents on a not-so-urgent topic. ps: @paulhoux: I can definitely see some uses for the |
A capsule usually is the best bounding shape for human characters. It's also nice to have when culling linear lights (tubes). And a |
Regarding |
One more thing: I would not add a bunch of methods to
|
I don't see any problems with adding getters for geom properties that are settable, it seems logical to me. However, we have previously discussed that geometric tests (like what AxisAlignedBox, OrientedBox, etc are for) is out of the scope of the ci::geom namespace. So if there is a ci::Cone and a ci::geom::Cone, the former is for testing while the latter is for generating geometry, however both can expose all of their properties with getters.. |
Well, I get Paul's point. And if we end up having both classes, there wont really be a need to access the properties of That said, lets try to think about a few more use cases where those getters might come handy. Most of the time the It's not a big deal, but it kind of limit those classes to "initialisation classes". If this is the intent, and I would understand it, I wouldn't add anything else to those classes. If it's not, I don't see why it would be an issue (apart from the semantical / conceptual one I mentioned above). |
The only reason why I think getters for those properties haven't been added is that they got overlooked as the geom architecture was the main focus and in constant flux throughout the last development cycle. Same reason many of the methods don't have one line doxygen docs - in my opinion both of these should be added for completeness. Aside from that, in general the design philosophy is to make cinder types transparent to the user, so if there is a property that is settable, it is also gettable, unless there is some valid reason to not have one or the other. Say you just want to print the dimensions of a geom that was constructed through some abstract factory (like script), it would be annoying not to be able to see the size or dimensions from code. Concerning the confusion between |
I agree; the setters should almost always have matching getters, but |
@simongeilfus Did you ever put together any of the changes for this? I'm running into a very similar issue integrating Cinder with NVIDIA PhysX. It seems to me the quickest "fix" is just to add getters for anything we can set, such as The next best thing would be some way to convert the GPU object generated from I'd be happy to do any combination of the above if it would be accepted in principle. (tagging @paulhoux and @richardeakin in case their opinions have changed at all in the past 7 years ;) ) |
What about using the |
How does the It seems like I would only have access to the mesh vertices, which wouldn't provide me with information about the primitives (like As you demonstrated in your first post, there's a lot of convenience in the |
…llowing suggestion in cinder#1176
I'm using the
geom
API a lot and was wondering if it would make sense to add accessor methods to the different primitive classes. I understand the idea for classes likeci::geom::Capsule
orci::geom::Cube
is more about carrying the geometry and attributes around than representing the primitive itself. But as there's very little reasons for creating more math classes along the existingci::Sphere
,ci::AxisAlignedBox
, etc..., I was wondering if we could extend the geom classes to have accessor methods (just to get access to the protectedmRadius, mSize, mLength
,...).The downside of this is that the interface would be a tiny bit more cluttered, but on the other hand it would offer more flexibility. It would for example allow us to use the same data for both gl objects and a physics engine. To be honest I don't see a lot of other use cases, except for scene serialisation and physics engine integration. But it's a small change that might open some nice doors.
(Edit: Probably any library or engine that has the concept of geometric primitives would benefit from this small change.)
So for instance having this:
Would allow that kind of code :
I can work on a PR if this is something you would accept.
The text was updated successfully, but these errors were encountered: