-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
raytrace:cast(object, origin, direction) is good not for all situations as I understand.
Sometimes it's better to cast from one point to another one and get first or all intersections.
For example, I use construction like this in old version of 3Dreamengine to detect mouseclicks at mobs:
local _pos = dream:pixelToPoint(vec3(mX, mY, 0));
local _point = dream:pixelToPoint(vec3(mX, mY, length_of_cast_ray));
local _segment = collision:newSegment(_pos, _point);
for i = 1, #_mobs do
local _collider = _mobs[i][1]:GetCollider ();
if _collider and collision:collide(_segment, _collider, true) then
…
end;
end;
--Collider can be created for every mob like:
local _collider = collision:newMesh (object);
As you can see I use vec3 points (pixelToPoint returns them) for raycast, using an object here can be not so good. Of course I can raycast all mobs in a cycle and use mobs like first param for raytrace cast. But for some reason this is not the best variant.
So, the question is: is it possible to add vec3 --> vec3 raycast method with limitation of the cast distance? It's good to get first hited object, or all hited objects in an array.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels