Jump to content

Is there a way to make Pick() faster?


Brutile
 Share

Recommended Posts

I'm working on a voxel game, and I'm using camera->Pick() to get the position to add or remove a block, but it seems to be really slow. between 5 and 10 ms on its own. I've set all objects to pick mode 0 except the chunks close to the player. Is there something I can do to speed things up, like use a different method or something?

Link to comment
Share on other sites

Is it only slow the first time you call it before recalculating your blocks? Also, you should be using a small range for the pick distance.

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

Oh, I see what you mean about recalculating blocks. I left out surface->Update(), which it needs to calculate the pick. it is now 0 to 1 ms. I just need to update the surface in a new update cycle so the frames don't drop :P

Link to comment
Share on other sites

I noticed you are using the Camera pick function. You can set the Pick distance when you use the entity pick instead-

http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitypick-r158

 

might be worth testing out to see if it goes any quicker but it sounds like you got it working pretty good.

Link to comment
Share on other sites

I may be totally misunderstanding you and if I am then disregard this.

But the Entity::Pick() function works pretty much the same as the Camera::Pick(). The only difference I can see is the option for x and y coordinates for the screen(while using camera pick) and the option for Vec3 starting pos and Vec3 ending pos(while using entity pick).

Link to comment
Share on other sites

I think Camera::Pick would be faster because it does AABB tests before geometry tests. Entity::Pick is used internally, and really shouldn't be used by the end user, except in special cases.

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

Well I learned something today! I've only been using pick::entity so far for whatever reason.

This information could be useful in the documentation because I would still be using Entity::Pick over Camera::Pick as there is no way to tell that Entity::Pick 'shouldn't be used by the end user, except in special cases.'

Link to comment
Share on other sites

I am wondering. Why shouldn't entity->pick used by the user?

 

The only thing it is useful for is when i use for example the mouse to click on something.

 

But as soon as i want another entity to check for something like in a Realtime Strategy Game i need to use entity->pick.

  • Upvote 1
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...