Page 16 of 23

Re: [library] bump.lua v3.1.4 - Collision Detection

Posted: Wed Nov 18, 2015 9:26 pm
by kikito
Sarcose wrote:I think trying to use bump directly to implement pushing and pulling is asking to make it into a physics engine.
I would not have said it better. Thanks.
alexzhengyi wrote:The idea of add a collision type such as 'push' is just from the platform demo.
It may make implements this kinds of collisions easier.This is the simple use case.But if there is wall just on top of the player, just simply update the player's y position may make the player cross the wall.
For another complicated use case,for example the play is pushing a solid box by 2 pixel , and the box is 1 pixel from a wall,then we can not just update this box like the platform demo.the play and the box both can just move 1 pixel.
See the previous quote. Bump is not a physics lib - it is a collision detection and (secondarily) a collision resolution lib. Physics is something you don't want me to get involved in. It took me years to have a working collision detection, and I only use boxes. If someone wants to implement a physics engine which used bump for collision detections, he's got my blessing. But I won't (can't) do that. In any case, I thank you for your interest and feedback!

Re: [library] bump.lua v3.1.4 - Collision Detection

Posted: Thu Jan 14, 2016 7:44 pm
by Davidobot
Jasoco, I just made a quick prototype for slopes. Use the arrows keys and space to move around.
You can change the slant in line 120 of main.lua.
Press tab to see how the magic works. Enjoy~!

Re: [library] bump.lua v3.1.4 - Collision Detection

Posted: Fri Jan 15, 2016 12:04 am
by Jasoco
Very interesting concept. Surprised I didn't think of that. Basically a moving platform that aligns itself with the player's X position and moves along the slope. I might have to do some toying around with that idea. Thanks for the idea! Maybe kikito can give some input too.

Re: [library] bump.lua v3.1.4 - Collision Detection

Posted: Fri Jan 15, 2016 6:51 pm
by Davidobot
Jasoco wrote:Very interesting concept. Surprised I didn't think of that. Basically a moving platform that aligns itself with the player's X position and moves along the slope. I might have to do some toying around with that idea. Thanks for the idea! Maybe kikito can give some input too.
No problem, I was actually put-off by how simple the idea is, so at first I thought it wouldn't work because if it did, I would have expected you to already have done it. lol.
Btw, that version uses math.sin for the slop, instead of math.tan, so it's a bit off. Here's the fixed one.

Re: [library] bump.lua v3.1.4 - Collision Detection

Posted: Fri Jan 15, 2016 11:55 pm
by kikito
@Davidobot, your solution is highly creative, congratulations!

I wouldn't go as far as saying that it is "the definitive answer to slopes in bump", but it is better than what has been shown so far. Thanks for sharing it.

My real-life workload has escalated significantly since I started a new job last summer, and I have not been able to look into this yet I am afraid. I know however that the proper solution is creating 4 new collision types (8 if you want to allow "corner" and "vertical center" variants). Each collision type would be similar to "slide", but with a modified rect_getSegmentIntersectionIndices function. The regular one calculates the intersection between a line and a rectangle, like this:

Code: Select all

+----------+           +----------+
|          |           |  XX      |
|          |           |XX        |
|          |  ==>     XO          |
|          |        XX |          |
|          |           |          |
+----------+           +----------+
What is needed is another version of this algorithm which is able to calculate the intersection between a line and a "rectangle which is missing a corner" (as well as some math to calculate exactly how much corner to "cut"):

Code: Select all

   /-------+               /------+
  /        |              OX      |
 /         |            XX        |
/          |  ==>     XX/         |
|          |        XX |          |
|          |           |          |
+----------+           +----------+
This would make things move like they are supposed to without needing to add platforms, etc. Unfortunately, this is the kind of mathy stuff I don't really enjoy doing, and I haven't had the will to spend my little free time researching this.

(Pull requests are welcome, by the way :)!)

Re: [library] bump.lua v3.1.4 - Collision Detection

Posted: Sat Jan 16, 2016 5:24 pm
by bzSteve
@Davidobot, I like where you're going with this and that you're working to add a useful feature to an already great library. Thanks.

I had a problem, though. I added a block in love.load that intersects the slope and tried to move up the slope and fell through to the floor.

Code: Select all

addBlock(100, 500, 200, 10)

Re: [library] bump.lua v3.1.4 - Collision Detection

Posted: Sat Jan 16, 2016 10:29 pm
by Davidobot
Oh, things like that will happen. That was just a quick and dirty way to test out a idea I had. I'll work on refining it more.
Thank you for all the kind comments too. ^~^

Re: [library] bump.lua v3.1.4 - Collision Detection

Posted: Sun Jan 17, 2016 10:11 am
by 4aiman
Hi!
I've tried your bump-demo-3.1.0.love just now and it segfaults 2/3 of launches after I press either right or up.
Is there anything I can do/provide to find the source of this behaviour?

Re: [library] bump.lua v3.1.4 - Collision Detection

Posted: Sun Jan 17, 2016 10:29 am
by bobbyjones
Segfaults? Does the demo use ffi? If not then segfaults is a very weird behavior. If you mean an error then it may need to be updated to 0.10.0.

Re: [library] bump.lua v3.1.4 - Collision Detection

Posted: Sun Jan 17, 2016 3:16 pm
by kikito
4aiman wrote:Hi!
I've tried your bump-demo-3.1.0.love just now and it segfaults 2/3 of launches after I press either right or up.
Is there anything I can do/provide to find the source of this behaviour?
bump.lua (or its demos) don't use anything that would provoke a segfault. There is no ffi, no shaders, no canvases, and no use of love.physics. It should also work in both 0.9.x and 0.10.x.

The camera in the demo uses love.graphics.translate, but that is a safe thing to do as far as I know. Does your computer segfault with other games or programs? Have you tried running it from the console, to see if it leaves any message before it "dies"? Also, is your keyboard ok? Pressing "escape" closes the demo, maybe it "presses it" due to a hardware error.