« first day (3408 days earlier)      last day (1616 days later) » 

 
4 hours later…
6:09 AM
@genaray is your game offline or online? What platform do you use? What kind of game is it?
 
7:07 AM
Hello friends, I have a question regarding collision of circle shape. I am using sfml to create circles colliding and bouncing off simulation. But in the middle of collisions, sometimes two balls stick together a bit and behave very strangely
 
hello
what's wrong with them exactly?
 
 
oh I see two circles stuck and spinning
It's good that the simulation is deterministic, you can add IDs to circles and add a condition checking time and IDs to debug it more easily
btw, how do you calculate the force which causes them to bounce?
 
 
3 hours later…
9:56 AM
@jeea Could the problem be when a new circle spawns? How are collisions handled of you spawn two circles in almost the same point?
 
10:50 AM
@trollingchar I use conservation of momentum, assuming no dissipation
@TomTsagk I thought that but the circle only spawns on top right corner
and the sticking circles problem starts at other places than that also
@trollingchar I am only calculating momentum exchange of a pair at a time, so if three bodies are colliding at the same time, then this might give inaccurate result
 
But the bug happens when there are two objects. I would debug like this: record parameters of these objects, spawn two objects with these parameters, and see what happens in the function where the force is calculated. At the first glance, it seems that force is actually attracting objects to each other, like Earth and Moon, and that's why there is a spinning movement.
Also rendering forces will probably make this example easier to debug
 
11:40 AM
It reminds me of my own engine's bugs, one of which caused grenades stick to the ceiling and descend if it was diagonal.
 
@trollingchar also in my simulation i am only considering circles collide if their distance of centres is less than their sum of radii. So in nth clock tick if there is no collision and in (n+1)th if there is collision then it means the collision occured somewhere in between, but i didnt account for that, is that leading to error
I mean this :
4
Q: Resolving a Circle-Circle Collision

GusI am writing software that extends Circle-Rectangle collision detection (intersection) to include responses to the collision. Circle-edge and circle-rectangle are rather straight-forward. But circle-circle has me stumped. For example, let two circles collide, one red and one green, in a discret...

 
nwp
@jeea From what I can see I guess there are 3 circles involved. One of them gets hit from both sides at the same time. The first collision puts it to one side and the second collision to the other inside the circle. For reproduction I'd try 3 circles, middle one not moving, the other ones at the same distance and speed hitting the middle one.
I suspect that once the distance between the circles is negative that the math goes crazy, causing the weird sticky effect where they should repel each other but with negative force, thus making them stick.
 
12:36 PM
@nwp yes this is a problem, as is shown in this gif!
the three red balls start symmetrically, centre one is stationary in y direction, and other two symmetrically moving toward it in y direction
In my code, all red balls are stored in a vector, and first red ball from top is first element, middle one is second element, third from top is third element, so interaction of 1-2 is handled first, then 1-3. This gives a result different from the reality where we consider all three interaction together, which results in middle ball remaining with 0 y velocity after the collision!
 
If you want to make all interactions happen "simultaneously", it means you want to make them independent on objects' order. Maybe separating the algorithm into phases will achieve this goal: at first we move all objects, and they don't depend on each other, then we use positions to calculate forces and offsets (without modifying positions because we use them!), and then we add offsets to prevent objects from overlapping.
 
1:00 PM
o my god another deadlock in my code I must think again how it made its way there
 
1:24 PM
I'm gonna make a specific page on me site where I can have a unique kitty frolicking adventure page where everything is clean
 
 
2 hours later…
3:09 PM
@jeea Is that possible that both circles are going in about the same direction at about the same speed and that would cause the behaviour, they're kind of sharing forces until something external comes and disturbs the 'system'?
 
 
3 hours later…
5:51 PM
@Vaillancourt I rechecked the collision logic, and hopefully this is fixed now, I was making mistake in not considering which bodies are colliding. earlier I only checked if the bodies are touching then they are colliding. Now I added a condition that they must move towards each other by checking dot product of the difference of normal velocities with the displacement vector of their centres.
dotProduct(jVel - iVel, disp) > 0
 
Looks good!
 
nwp
I like how they hit each other with the one in the center again at the end, just to make sure.
 
But now I am still worried about multiple collision at once, following your recommendation of experimenting different position, i tried this symmetrical system. But here the problem of not considering all collisions at once is more obvious. The system is symmetrical, left body is element 1, right body is element 2, and body on down is element 3 in the red ball vector. ALso i iterate i = 0 to 2, j = i+1 to 2 for checking collisions
 
6:07 PM
Do you need that to be symmetrical?
 
Yes but I dont expect my code to give symmetrical because I am only checking pairwise collision, not checking all three or more together
 
Yes, the behaviour you get is expected.
 
nwp
It becomes symmetrical if you do what trollingchar said and do the calculation on objects without updating them and then applying all the changes at once.
 
Yep
Detect all collisions first, then propagate the forces second.
That would give me a headache.
 
i am using sfml for graphics, and will using any physics engine like box2d solve this problem
 
6:14 PM
Oh, well having someone else do the thinking for your, free of charge, is even better :P
 
nwp
6:46 PM
This makes me want to screw around with my ECS again. I ran into this problem too and made a readonly phase and an update phase for that. And the idea was that the readonly phase could be multithreaded. If only I was less lazy or had people to do stuff with me.
 
Achieving something only by oneself can be challenging.
 
Or impossible in some cases. Try building a mothership in EVE-Online by yourself. Would probably take thousands of years. Or more. :)
 
What if I used multiple accounts?
I guess I still wouldn't have time to harvest all that is needed.
 
7:01 PM
yes
that is the issue
harvest the stuff, then manufacture all those parts
 
Or just spend a lot of cash, sell the PLEX, buy everything.
Gotta be a rich bastard. Then you'll most likely get blow up in no time because you won't be able to operate it, or something :P
Wasn't there a story about someone running a "bank" that would reinvest the money in the market, but at some point just vanished with the money, only to reappear a few months after with a mothership?
 
7:23 PM
In perfect symmetry case, we know after collision, the result will be symmetric, so momentum of each of upper ball will be equal
1 hour ago, by jeea
user image
But how we handle the case when 3 body collide, like in this example, but with different masses, or a bit of asymmetry?
My first thought is that we first, as nwp and trollingchar and others said, to first find out the bodies undergoing collision at the same time.
In this case the lower body is said to be colliding with upper two. But how can we know, in asymmetric collision, the distribution of momentum finally
 
I'm not exactly sure. If you will end up using box2d, why don't you use it now?
 
I was just trying to make it myself, but I think I will need to learn this box2d
I mean theoretically I am puzzled how it should behave in a nonsymmetric situation. In symmetric situation, we can solve as given here:
2
A: Calculating a 3 way circle collision

Victor LiuLet's assume for now all the balls have the same mass $m$ and radius $r$, and the red balls are at rest, and the blue ball has velocity $v$. The total momentum of the system is $mv$, and total energy $\frac{1}{2}mv^2$. We assume the collision is elastic. After collision, the red balls will be mo...

 
This looks like a problem that could have been solved in a game. I guess you have to calculate the force and spread it according to the main direction the circle is going? I don't know.
 
7:40 PM
Looks like this can be useful
I be better off just using the box2d or something
 
Yeah, maybe that'll work better..
 
8:02 PM
Hello, i cant understand how to set viewport in sfml for box2d and why i need to do that
 
What is the code that you have so far?
 
sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Red Ball C++");
			window.setFramerateLimit(60);
			sf::Sprite sprite;
			sf::Texture texture;
			texture.loadFromFile("Assets/Textures/objects1.png");
			sprite.setTexture(texture);
			sprite.setTextureRect(sf::IntRect(81,0,61,61));
			sprite.setScale(sf::Vector2f(1, 1));
			b2BodyDef def;
			def.position.Set(20, 1);
			def.type = b2_dynamicBody;
			b2PolygonShape shape;
			shape.SetAsBox(30,10);
			b2Body *body = world.CreateBody(&def);
			body->CreateFixture(&shape, 1);
 
When you paste code like that, use the "fixed font" button, it will format it.
 
Okay,sorry.
 
No worries :)
 
8:05 PM
I mean view is view. I dont understand how it converts positions of physics.
How it can.
Oh you mean i need to set view the way it only captures my bodies?
 
The view will not convert the position of physics, the view will tell the window what portion of your world to display in the view.
Yes.
If that's what you want.
If only one of your bodies is really important, and you want to follow that body, you'll update the view every frame, setting its center to the position of that body:
view.setCenter(200.f, 200.f);
If you have multiple bodies that you want to see, every frame, you'll have to check the axis aligned bounding box of all your bodies (including their size), and update the size of the view (with the center):
view.setCenter(sf::Vector2f(350.f, 300.f));
view.setSize(sf::Vector2f(200.f, 200.f));
This will effectively scale your sprites so that they fit in the window.
 
(Note that you need to account for the aspect ratio of your window when setting the size, otherwise it'll be stretched.)
 
But default view does the same.
I guess thats not what i want. I m not looking for my entities on window or anything.
 
You just want them zommed in?
 
8:17 PM
No. I thought it was all about positioning. So i wouldnt have to use pixels when setting up position of my sprites.
So i have to multiply position of my box2d body on size of that object in pixels? For example: pos.x * 32?
to set my sprite right onto physic body?
 
You position them based on their "real world" position, not using the pixels positions; you let SFML work with the pixels.
Hold on
Ok, nevermind.
 
real world position?
 
You set the position of the sprite the same as the position of the body.
 
yes correct
but that doesnt work
 
what doesn't work?
What do you get?
 
8:26 PM
where s the button to convert text into code?
 
When you paste the code (multiple lines) it appears beside the "upload..." button.
 
def.position.Set(50, 1);
for (b2Body *i = world.GetBodyList(); i != 0; i = i->GetNext())
{
	if (i->GetType() == b2_dynamicBody)
	{
		b2Vec2 pos = i->GetPosition();
		sprite.setPosition(pos.x, pos.y);
		window.draw(sprite);
	}
}
 
Yes, ok, this is the code I would use too! And what is the result that you get?
 
First line does nothing. It doesnt change position of the body.
 
Ah, do you apply any force to the body?
(I have not worked with Box2d.)
 
8:31 PM
ah sorry
it does
i mean it does change position of a body.
 
Ok, so your body moves; does your sprite move too?
 
but how much pixels 1 meter would be by default?
in my example
yes.it does move.
 
How important are the pixels?
 
When i m going to buid map i m going to need that info. I think.
build*
Im going to need to know how much is one block in pixels.
 
I would guess here that one pixel is one meter.
 
8:36 PM
Okay i see.
 
Because you use the default view.
You might want to define your "physics" parameters first.
What type of game are you making?
 
For what?
Platformer
what parameters?
 
Ok, well you might want to start to decide things the size of your character is a bloc of 1 meter per 1 meter (like small mario) or 1 meter per two meters, like mario on mushroom, then decide it's acceleration (thinking in MKS).
Then you decide how many pixels you want to stuff in one of these 1 meter tiles (for example).
You can start to work with your gameplay first, using big gray boxes, then you can decide how many pixels you can afford.
How much details do you need.
Sorry, it's so clear for me, I'm not sure if I'm able to explain it right.
 
How many pixels i can afford? Why is that? You can just zoom your world no?
 
Yeah :)
But if you use higher resolution textures, it means more time and money needed to craft these textures.
 
8:43 PM
^
high res textures also take a ton of ram to load
In our menu on a shipped game, the camera panned around a small 3d env inside a church for flavor
on a desk in a corner was a small document. It had a 2048x2048 texture. :O
 
Also, you need to account for multiple pixel resolution on different devices. If you think it pixels, things can get complicated.
@Almo I suspect someone received a lump of coal in their stockings that year. :P
 
Okay i see. See you later. Have a nice day folks.
 
@RundogieRundogie See you later :)
 
@Vaillancourt :D
 

« first day (3408 days earlier)      last day (1616 days later) »