Jump to content

Object in view


Alienhead
 Share

Recommended Posts

I've been combing the api docs, but haven't found a way to determine if an entity is in view or not, either by off-screen or blocked by another object.  I suppose a raycast  from the camera to the entity would help with the blocked views but as far as the OnScreen or InView determinations? 

Link to comment
Share on other sites

The calculation to tell if an object is in view is not too hard. Transform the entity's position from world space to camera space. If the X or Y position (whichever is bigger) is greater than the Z position it's out of view. This assumes a 90 degree vertical and horizontal FOV, but it's good enough for "can the enemy see me".

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

When I use the cull commands I get a system hang when loading a new map .  If I don't initiate any culling commands it goes through with the map change.

--Map change ---------------------
    if window:KeyHit(Key.F12) then
        Time:Pause()
        System:GCSuspend()

        --Load the next map
        Clearmap()
        Loadmap(1)
        LoadPlayer()

        System:GCResume() -- !!!!!!!!!!!!!!!!!!!!!!  Hangs up right here
        Time:Resume()

    end    

Link to comment
Share on other sites

Okay here's my full work around,  besides from 'having to use' the Asset.Unmanaged flag,  I've created a simple lua table to hold each and every parented entity, before calling world:Clear() I cycle through the parented list and unparent.. then call world clear..   so far no lockups or freezes or silent crashes and the mesh deformation has stopped.  Now to go back through all the code and set the parent/unparent stuff correctly so i can do away with the quick hack. :)

Scratch that,   still happening on further testing ;(

Link to comment
Share on other sites

A really good chance that when you have the following situation occur the game session randomly ( or as of late - not so randomly ) crashes without warning, error or cause. 

Create  a sphere ( or any object or pre loaded or live loaded object )

Attach anything to it via SetParent()

In my case I have a long slow traveling bullet that I attach several smoke trail emitters to as it is in flight. 

At any point if anything parented to the main parenting object is removed  :: 

                          if em.ent:GetParent() ~= nil then em.ent:SetParent(nil) end                        
                          em.ent:Release()

This is a normal call, nothing happens out of the ordinary here..  the emitter ( or whatever  is attached via code ), is removed as it should be.

The problem comes later,  it can be 5 mins or 30 mins ( or worse yet, sometimes never at all )...  but when you Release() the parent entity- be it ent:Release()  or by world:Clear()  the entire game session crashes with no errors, warning or syntax.

 

I've really found it best,   if your parenting items shorterm -, is to Hide() them instead of releasing them and just let them die with the -parent on release() or clear().  

 

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...