Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Shapes being deleted automatically after position is set far enough away  (Read 1339 times)

0 Members and 1 Guest are viewing this topic.

SharkFin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Edit:    This has been solved. I was dividing by zero, and is not a problem with SFML. My bad

I'm creating a flocking simulation based around http://www.red3d.com/cwr/boids/. I'm getting a problem though.
The flocking is working fine, whatever, but when I try to make the boids wrap around (x position greater than the width, set width to 0 and vice versa), they flash where they should be but then are deleted. I'm using
sf::CircleShape shape(10.f);
shape.setPosition(sf::Vector2f(x,y));
but when the position is set far enough away from it's current position, it is deleted.
The same thing happened with a double pendulum simulation that I attempted yesterday. The physics were all broken which didn't make sense, but the thing would spin faster and faster until sfml just deleted the shapes. (the physics breaking is not the issue here, it's sfml deleting things)
Is there some way to specifically avoid having sfml delete things, or is there a way to turn it off entirely?
« Last Edit: February 25, 2019, 09:08:34 pm by SharkFin »

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Shapes being deleted automatically after position is set far enough away
« Reply #1 on: February 25, 2019, 08:14:20 pm »
SFML doesn't delete anything :o and it displays everything you ask to be displayed.

SharkFin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Shapes being deleted automatically after position is set far enough away
« Reply #2 on: February 25, 2019, 08:22:09 pm »
Yeah well it sure looks like it's deleting it. When there are only a few pieces making large movements sfml is fine with it, but the more there are, the more likely they are to be removed. It seems to me like a memory management thing that sfml is doing, but it definitely happens.

SharkFin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Shapes being deleted automatically after position is set far enough away
« Reply #3 on: February 25, 2019, 08:59:23 pm »
Hm no I have some weird bug in my code. The fact that I had the same bug in my other program raised some suspicion. Thanks for your answer.. This one's my bad I think. (still don't know what the bug is exactly but I know it is a bug)

Edit: Yep sorry about this, Turns out I was dividing by zero at one point in my code... Sorry for the pointless post, and my cockyness.. Thanks for the reply though!
« Last Edit: February 25, 2019, 09:06:34 pm by SharkFin »

 

anything