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

Additional Geometric Primitives #2290

Open
morphogencc opened this issue May 25, 2022 · 0 comments
Open

Additional Geometric Primitives #2290

morphogencc opened this issue May 25, 2022 · 0 comments

Comments

@morphogencc
Copy link
Contributor

morphogencc commented May 25, 2022

The geom:: namespace seems to have a pretty complete listing of GPU representations of shapes, but there's very few of the corresponding classes in the ci:: namespace. There's ci::Rect<T>, ci::Sphere, and ci::AxisAlignedBox, and I'm not sure there's much else...

For 2D Shapes it'd be great if they had a similar interface to Rect:

        void		transform( const Mat3T &matrix );
        RectT	transformed( const Mat3T &matrix ) const;
        bool	contains( const glm::tvec2<Y, glm::defaultp> &pt ) const
        bool	contains( const Vec2T &pt ) const	
        bool	intersects( const RectT &rect ) const;
        T		distance( const Vec2T &pt ) const;
        T		distanceSquared( const Vec2T &pt ) const;

and for 3D Shapes if they followed the Sphere interface:

	bool	intersects( const AxisAlignedBox &box ) const;
	bool	intersects( const Ray &ray ) const;
	int		intersect( const Ray &ray, float *intersection ) const;
	int		intersect( const Ray &ray, float *min, float *max ) const;
	vec3	closestPoint( const Ray &ray ) const;
	Sphere	transformed( const mat4 &transform ) const;

I'm imagining that these would be useful for hit-testing in various applications, where perhaps you don't want an entire physics system just to figure out if objects overlap / intersect / contain a point.

Based off of some threads I've read here, it seems that other primitives are missing mostly because they haven't been a priority / need for anyone yet, not because anyone is against them existing -- if this is correct, then I may go ahead and build a few for a current project and add them.

It'd be great to collate thoughts on what the consistent interface might be across multiples of these objects (and if perhaps they should inherit from a parent class that defines this interface?).

A preliminary list of ideas:

2D Shapes

  • ci::Circle
  • ci::RotatedRect
  • ci::Triangle

3D Shapes

  • ci::Box
  • ci::Capsule
  • ci::Cylinder
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

No branches or pull requests

1 participant