Jump to content

Entity::RemoveHook Access Voilation


martyj
 Share

Recommended Posts

In the non-beta branch.

 

When removing a hook on an entity in the Hook's callback, an access violation occurs.

 

When removing a hook on an entity NOT in the hook, everything works as expected.

 

Code:

 

void tempHook(Entity* entity)
{
if (Window::GetCurrent()->KeyHit(Key::J))
{
 entity->RemoveHook(Entity::UpdateWorldHook, tempHook);
}
}

bool App::Start()
{
temp = Model::Box(3, 3, 3);
temp->AddHook(Entity::UpdateWorldHook, tempHook);
return true;
}

Link to comment
Share on other sites

I see.

 

Does having an update hook effect performance much? I have an object that I add an update hook on when it gets interacted with, then I hide the object.

 

After x number of seconds, I show the object, and would like to remove the hook as it's no longer needed to check to see if it should show.

 

What would be the best way to do this?

Link to comment
Share on other sites

Ah I see.

 

If you aren't doing this with tons of objects it should be fine.

 

The actor class I talk about here could probably handle this. You could just remove the actor from the entity in the function and it should be okay:

http://www.leadwerks.com/werkspace/topic/15235-actor-class-for-c-entity-management/

 

It's not ready to use yet, but it might be a good option in the future.

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

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