Skip to content

Raycast method cast params #64

@CrossroadInTheVoid

Description

@CrossroadInTheVoid

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions