Open dungeon2567 opened 9 months ago
I'm not sure I understand the ask. Are you saying you want to overlap a cone against a set of spheres and segments, or do you want separate checks like coneSphere(...)
, coneSegment(...)
?
I want to overlap a cone against a set of spheres and segments
But both works
this is for a topdown game, for visibility checks
We would need to add coneSphereOverlap
and coneSegmentOverlap
tests. I don't have any links to existing implementations for these, but I'm open to adding them.
this is for a topdown game, for visibility checks
Cool!
bool overlapsWith(const Cone& cone) const {
if (isCircle()) {
float dist = std::sqrt(Math::sqr(position.x - cone.position.x) + Math::sqr(position.y - cone.position.y));
if (dist + radius() < cone.minDistance || dist - radius() > cone.maxDistance) {
return false;
}
// Calculate the direction vector from the cone's position to the circle center
Vector2 toCircle = { position.x - cone.position.x, position.y - cone.position.y };
// Calculate the angle between the direction vector and the cone's rotation vector
float dotProduct = toCircle.x * cone.rotation.x + toCircle.y * cone.rotation.y;
float angle = std::acos(dotProduct / (dist * 1.0));
return angle <= cone.fieldOfView / 2.0f;
}
return false;
}
I have generated this using ChatGPT for cone and circle but for segment i have no idea (and chatgpt can`t do it)
and chatgpt can`t do it
Why not?
I suspect that chatgpt generated function may not catching all intersection cases, because it only seems to compare the angle of the cone against the vector going through the center point of the sphere.
It would be nice to generate visual test for this, like we have for the other collision functions. That would give me some confidence that this code is actually working.
It is not working, only range check is working
and chatgpt can`t do it
Why not?
I have tried but all codes he generate is broken.
I would imagine somewhere on the web are high quality cone-sphere and cone-segment intersection tests. If you find any I'm happy to integrate them into this library. :)
PRs also welcome!
Im thing about doing that for cone sphere (reducing it cone-circle). but i
m not sure how yet.
This might be good. It looks like it may be robust: https://github.com/mosra/magnum/blob/53c1549e69af552d28d5da8fc4dcdd0e9a1cad60/src/Magnum/Math/Intersection.h#L529-L556
Let me know how this works for you, if the routine seems robust I'm happy to include it in this module.
Ok, i think it should work. As my game is using a BVH and i still don`t have a code to calculate AABB of frustrum i have not tested it visually (except some values)
just out of curiosity what are you using for a renderer?
Nothing, it is a mmorpg backend. But for the frontend i`m using unreal engine 5
that's a really interesting architecture, have yet to encounter that. Are you keeping a devlog anywhere?
No, i have just started. But i will do it soon.
This is my mmorpg on unity using same architecture but ... unity is dead
Is there any way to implement cone -> sphere and segment overlap system?