About Store Forum Documentation Contact
Donations:
207$/mo



Post Reply 
Incorrect pointer from Physics.ray [Closed]
Author Message
Harton Offline
Member

Post: #1
Incorrect pointer from Physics.ray [Closed]
When checking the object under cursor, function Physics.ray returned incorrect pointer. Anyone know why? Everything is the same as in tutorial "..\Tutorials\Source\Advanced\5 - Projects (here all files from a single directory need to be included in project)\02 - Inventory\"


Attached File(s) Image(s)
   
(This post was last modified: 01-07-2013 12:15 PM by Harton.)
01-05-2013 01:27 PM
Visit this user's website Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #2
RE: Incorrect pointer from Physics.ray
It is not a incorrect pointer. phys_hit.obj can be NULL.

In this example, only will have a real memory address when mouse is over a Game::Obj avoiding objects with flag AG_CONTROLLER (character). ie, it will contain memory address when the mouse is over the blunt.

IRC: irc.freenode.net
Channel: #Esenthel
(This post was last modified: 01-05-2013 03:20 PM by cmontiel.)
01-05-2013 03:15 PM
Find all posts by this user Quote this message in a reply
Harton Offline
Member

Post: #3
RE: Incorrect pointer from Physics.ray
Quote:It is not a incorrect pointer. phys_hit.obj can be NULL.
I know. But why control moved to if block? Ray function hit something, right?

Quote:In this example, only will have a real memory address when mouse is over a Game::Obj avoiding objects with flag AG_CONTROLLER (character). ie, it will contain memory address when the mouse is over the blunt.
You are right. The mouse is over the object and then the control goes into if block. But always phys_hit.obj contains NULL. And I don't know why...
01-05-2013 04:18 PM
Visit this user's website Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #4
RE: Incorrect pointer from Physics.ray
Quote:I know. But why control moved to if block? Ray function hit something, right?

No, Physics.ray(...) can return true without hit objects.

Quote:You are right. The mouse is over the object and then the control goes into if block. But always phys_hit.obj contains NULL. And I don't know why...

Not always...

Try something like

Code:
GObjUnderCursor = phys_hit.obj;
if(GObjUnderCursor != NULL)
{
// breakpoint down here
int x = 0;
}

It should stops when mouse is over the blunt.

IRC: irc.freenode.net
Channel: #Esenthel
01-05-2013 05:09 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Incorrect pointer from Physics.ray
phys_hit.obj is set to Actor.obj
actor.obj can be null (like terrain actor)
01-06-2013 10:46 PM
Find all posts by this user Quote this message in a reply
Harton Offline
Member

Post: #6
RE: Incorrect pointer from Physics.ray
I'm sorry for the trouble! It was my fault, my oversight.
I forgot to initialize the physics of the object ...
01-07-2013 12:15 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply