Syomus / ProceduralToolkit

Procedural generation library for Unity
https://assetstore.unity.com/packages/tools/utilities/procedural-toolkit-16508
MIT License
2.59k stars 225 forks source link

Add missing Geometry algorithms #12

Open BasmanovDaniil opened 6 years ago

BasmanovDaniil commented 6 years ago

https://github.com/Syomus/ProceduralToolkit/wiki/Geometry-algorithms http://www.realtimerendering.com/intersections.html

D - Distance C - Closest point(s) I - Intersection

2D Line Ray Segment Circle2
Point D, C, I D, C, I D, C, I D, C, I
Line D, C, I D, C, I D, C, I D, C, I
Ray D, C, I D, C, I D, C, I
Segment D, C, I D, C, I
Circle2 D, C, I
3D Line Ray Segment Sphere Circle3
Point D, C, I D, C, I D, C, I D, C, I -
Line I - - D, C, I -
Ray - - D, C, I -
Segment - D, C, I -
Sphere D, C, I -
Circle3 -
MarcusElg commented 5 years ago

can you explain what you the point of this is? How does it affect the generators?

BasmanovDaniil commented 5 years ago

@MCrafterzz Some of the more advanced generators require robust geometric primitives and algorithms, a recent example of this is the roof generator. As of now it is possible to generate polygonal roofs, but that was not the case before the introduction of the geometry library. Or, say, you want to make a city generator and you need to find an intersection of two roads, Unity doesn't provide any tools to solve that problem, but with the new methods it is quite easy. 3D intersections are less useful, so while they can still be helpful for spawning and in some other cases, I would prefer to test and optimise the existing methods, rather than investing further in 3D. This page is here mostly for completness, it would be nice to be able to find a distance between 3D lines, but it is not a pressing issue. Ideally I would like to have a feature set similar to Physics, maybe the new API in 2018.3 will solve that.

MarcusElg commented 5 years ago

Intresting thx for the reply. A procedural city would defently be cool, is that something planned or is it just possible to use this library for it? The building generator looks very useful will probably use it in the future. What are the plans with this library, most issues are just these geometry things.

BasmanovDaniil commented 5 years ago

@MCrafterzz, The current plan is to develop the building generator into something more useful and aplicable in real scenarios, and as a means to that I am playing around with city generation. Don't expect to see the city generator any time soon though. After that I intend to focus more on 2D generation such as dungeons, caves and floor plans, I already have working code for all of this, but it will require vigorous refactoring before the public release. I will try to move some of the tasks from my private tracker to github issues during this weekend so there will be something else besides "geometry things" 😄

MarcusElg commented 5 years ago

Please post your city generation progress here on github even though it isn't finished, would be cool to see!