How fast is Linepick on modern computers?
Blitz3D Forums/Blitz3D Programming/How fast is Linepick on modern computers?
| ||
Blitz3D has the problem of full sliding collisions not working well for floors (characters slide down when standing still). Slide2 is not any better because characters will travel up slopes at unrealistically slow speeds. That leaves the only option for gravity is to use the MeshY equivalent of TerrainY. And that involves a Linepick and PickedY. I'll never understand why platformers are so non-existent, especially as indie games. They're by far my favorite genre! So I'm completely dedicated to finishing one (though it is a bit tricky in B3D sometimes). My question is... how often can I get away with a Linepick? It's known as being slow, but that was years ago... since then, computer speed has tripled... twice. Linepick is calculated on the CPU right? And I'm guessing that if I only call it ever other frame, then for 5-10 characters at a time, I would need to call it 150-300 times a second. That should be nothing, right? If that's too much, is there a way to do proper gravity through CollisionY perhaps? |
| ||
Sliding collsions on the ground with natural behaviour on slopes needs a little more than the built in collision handler. Most people use one linepick toward the ground to determine the slope steepness and then they apply gravity accordingly. Personally I even use 4 linepicks, skipping PickedNX completely, by calculating the height diffrences of the 4 pickedYs. No matter what, if you're doing linepicks then you have to make sure they will never have to pick large distances, that's what's makeing them slow. Picking the ground under the feet can be done with acceptable speed. To prevent picking nothing (slow!), eg. when the player jumps from platform A to B, you may parent a dummy mesh under the player, eg. 1 "meter" under his feet, so you'll never do a wide range pick, but nonetheless you will detect when there is no ground. Depending on the ground distance, as well as the slope angle, you will then have to set gravity dynamicly. You may however stop the player from sliding down (on-ice artefact) non-steep slopes by repositioning the player at the old XZ after update world, If he didn't walk, but XZ was altered by updateworld due to sliding collision. It takes a couple of steps to make this thing work decently, but it's worth the troubles. One thing: stairs may produce new problems with the 4 linepicks method. But it should be possible to work around it with the right offset in proportion to the collsion radius (assuming player vs map is sphere vs polygon collision). For the optional Linepick Parameters you maybe should make some isolated speed tests by your own. |
| ||
I had 20 or 30 test vehicles on a complex mesh doing 4 linepicks per vehicle at 60fps with no issues, so it's not that slow. One thing I found was that specifying a radius for the linepick seemed to slow it down, even if the radius was tiny. Leaving the radius empty seemed to make it faster. Also, as jfk says keep the pick distance small for best results. You only need to test very close to the character's feet - if no mesh is found then gameplay-wise it doesn't matter if they're a foot from the ground or a mile, so there's no point raycasting for that mile. |
| ||
Ah thank you. That's exactly what I wanted to hear. =D |