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

Overlapping test methods for math shape types. #795

Open
vpenades opened this issue Feb 1, 2022 · 8 comments
Open

Overlapping test methods for math shape types. #795

vpenades opened this issue Feb 1, 2022 · 8 comments
Assignees
Labels
area-Maths enhancement good first issue help wanted

Comments

@vpenades
Copy link

@vpenades vpenades commented Feb 1, 2022

Summary of feature

Math library has 2D and 3D common shape types like Ray2D, Ray3D, Cube, Sphere, etc

It could be useful to have Ray2D and Ray3D to have methods to return the intesection with shapes and volumes.

Also, test methods to get whether shapes and volumens overlap.

Comments

Area/volume overlapping is a very common practice for graphics development in areas like frutum culling, collision detection, etc

Does this have a proposal?

no

@vpenades vpenades added the enhancement label Feb 1, 2022
@HurricanKai
Copy link
Member

@HurricanKai HurricanKai commented Feb 1, 2022

While this may be useful, it is quite out of the scope of our maths library. Frustum culling, Collision detection, etc. should all not be done by directly using these types anyways, either this should be deferred to the GPU or done using some optimization system on the CPU - likely the job of another library (for example Bepu Physics for physics/collision detection)

@Perksey
Copy link
Member

@Perksey Perksey commented Feb 1, 2022

It could be useful to have Ray2D and Ray3D to have methods to return the intesection with shapes and volumes.

This doesn't seem like a bad idea (the other stuff in Comments though is out of scope as Kai suggested), @HurricanKai we could just leave this open to see if anyone from the community picks up on it?

@vpenades
Copy link
Author

@vpenades vpenades commented Feb 1, 2022

Although I agree that frustum culling and collision detection require ultra-optimized types, this doesn't mean the types provided by Silk don't implement some commom methods.

If Matrix4x4 has multiply, Inverse, etc.... I don't see why Sphere can't have a DistanceTo(Sphere), or an OverlapsWith(Sphere) or Intersects method, which are common use cases for shapes and volumes. Then the users can choose whether to use these types for their scenarios or not.

I understand the concern about adding methods to these types, because once you open the box, the number of methods you can add is countless, but I think there's some stuff that can be added without harm.

@Perksey
Copy link
Member

@Perksey Perksey commented Feb 1, 2022

@vpenades for our reference, would you be willing to implement these methods if we said we're happy to have them?

@vpenades
Copy link
Author

@vpenades vpenades commented Feb 1, 2022

I could give a try, I am new to Silk, but I have some of these methods already implemented in similar types (using float)

There's also public, well known implementations in other projects, like the old XNA.

@Perksey
Copy link
Member

@Perksey Perksey commented Feb 1, 2022

@HurricanKai free contribution? iirc we have IntersectsWith methods elsewhere; raycasting APIs seem in scope for silk.net as other maths libraries have this (e.g. unity's maths lib). I agree anything more, like Full-blown culling, is defo out-of-scope.

@HurricanKai
Copy link
Member

@HurricanKai HurricanKai commented Feb 1, 2022

Basic .IntersectsWith methods seem fine to me

@HurricanKai HurricanKai reopened this Feb 1, 2022
@Perksey Perksey added good first issue help wanted labels Feb 1, 2022
@vpenades
Copy link
Author

@vpenades vpenades commented Feb 1, 2022

So if I understand the architecture correctly, it would be something like this?

Ray2D.Intersections.cs

  • IntersectsWith(Circle)
  • IntersectsWith(Rectangle)
  • IntersectsWith(Box2D)

Ray3D.Intersections.cs

  • IntersectsWith(Plane)
  • IntersectsWith(Sphere)
  • IntersectsWith(Cube)
  • IntersectsWith(Box3D)

Also, I understand the common grammar would be like this:

bool IntersectsWith(shape, out Scalar distanceFactor);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Maths enhancement good first issue help wanted
Projects
Status: Todo
Development

No branches or pull requests

3 participants