Jump to content

Getting a collection of Entities through RayCast


Joshua
 Share

Recommended Posts

Is it possible to perform a single raycast (Pick Event) and return a collection of pointers to intersected Entities by using the available pickevent? From my understanding, the current pickevent will either return a single pointer to the closest intersection result, or the first intersection result found.

 

The only way that I can think of to do this would be to implement a recursive raycast in which the pickevent would return the closest intersection between p0 and p1, then do another pickevent using p1 as p0 and using a new point as p1. The method would continue in a similar fashion until there was no intersection between the raycast and an entity. I think this method would work, however it seems very daunting and may create a lot of overhead to perform one raycast. I understand that the current pickevent has a recursive parameter, however I believe that the recursive method, if true, will recurse inside the Entities Hierarchy and not past the initial intersected entity. Please advise.

 

Syntax

  • bool Pick(const Vec3& p0, const Vec3& p1, Pick& pick, float radius = 0.0, bool closest=false, bool recursive=false, int collisiontype=0)

Parameters

  • p0: the origin of the ray in global coordinates.
  • p1: the terminal end of the ray in global coordinates.
  • pick: a pick object to contain pick information.
  • radius: the radius of the ray. If the radius is greater than 0.0, a slower swept sphere collision will be performed.
  • closest: if set to true, the closest intersection will be found, otherwise the operation will return as soon as a single intersection is found.
  • recursive: if set to true, the entity's sub-hierarchy will be tested recursively.
  • collisiontype: if specified, the entity collision type of all children will be tested against this, and non-colliding entities will be skipped.

Link to comment
Share on other sites

DudeAwesome's suggestion will work fine. In LE2 you had a PickFilter callback which was really handy for this kind of thing.

 

We had a slightly different problem, scan large areas containing 1 to many widely spaced entities (for simulating radar sweeps). We would first compute an axis aligned bounding box for the scan volume, then generate a collection of potential entities using worldforeachentityinaabbdo then reject based on angle of entity to the source. The final step was performing line of sight tests on the remaining collection. Since radar sweeps occur every few seconds it's not a problem spreading the task over time.

 

A different problem but the above might help someone else trying to do the same.

  • Upvote 1

6600 2.4G / GTX 460 280.26 / 4GB Windows 7

Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT

Tricubic Studios Ltd. ~ Combat Helo

Link to comment
Share on other sites

I am trying to do is take a Wall object that holds a linked list of Leadwerks::Entity and perform a 'slice' operation, vertically or horizontally at a specific location on the wall, splitting the wall into two sections, or more.

 

I was able to achieve an effect of this nature by passing in a percentage to the slice method, creating a new Entity, resizing the existing Entity to the left portion of the wall, then resizing the new Entity to the remaining portion of the wall, where the overall size, shape, rotation and scale are determined by the Wall object. The problem I started to run into was if I wanted to slice into a Wall where there had already been slices, I would need to perform a rayCast at the slice position, from the top of the wall to the bottom of the wall, and perform the slice operation for every Entity the rayCast collided with.

 

I have tried DudeAwesome's suggestion which was very similar to the method I described in my initial post, however my rayCast is returning False. My source for the SliceVerticle method is below as a reference http://dpaste.com/hold/1564912/

 

I have created several different versions of the SliceVerticle method and stored different iterations so it is possible that my mathematic calculations are wrong, or missing.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...