Fisica, world.step

Hello, i’m working with the Fisica library by Ricard Marxer. There were no problems until we started using classes and objects to make the code look more understandable. The problem seems to be in the world.step function, that gives me this error:
“AssertionError: Too many pairs (16384 shape AABB overlaps) - this usually means you have too many bodies, or you need to increase Settings.maxPairs.”

Here is a part of my code:

import fisica.*; // IMPORTAMOS LIBRERIA  

FWorld mundo;  // DECLARAMOS MUNDO

ladrillos_1n l1n;

void setup() {
  // INICIALIZAMOS LIBRERIA Y MUNDO
  Fisica.init( this ); 
  mundo = new FWorld(); 
  size( 800, 800 );

  mundo.setGravity(0, 1000); // ASIGNAMOS GRAVEDAD
  mundo.setGrabbable(false); // OBJETOS NO CLICKEABLES

  l1n= new ladrillos_1n();
}

void draw() {

  mundo.step();
  mundo.draw();
  background(255);
  l1n.dibujarLadrillos_1n(200, 350, 600, 350);
}

class ladrillos_1n {
  float posX1_, posY1_, posX2_, posY2_;

  ladrillos_1n() {
    posX1_= 0;
    posY1_= 0;
    posX2_= 0;
    posY2_= 0;
  }

  void dibujarLadrillos_1n(float posX1_, float posY1_, float posX2_, float posY2_) {
    FBox ladrillo1 = new FBox( 70, 15 );  
    ladrillo1.setPosition( posX1_, posY1_ );
    ladrillo1.setStatic( true );
    ladrillo1.setFill(200);
    mundo.add( ladrillo1 );

    FBox ladrillo2 = new FBox( 70, 15 );  
    ladrillo2.setPosition( posX2_, posY2_ );
    ladrillo2.setStatic(true);
    ladrillo2.setFill(200);
    mundo.add( ladrillo2 );
  }
}

Please format your code :blush:

It consist on these two steps:

  1. In your code editor (PDE, VS code, Eclipse, etc) ensure you execute the beautifier function. This function automatically indents your code. Auto-indenting makes your code easier to read and helps catching bugs due to mismatch parenthesis, for instance. In the PDE, you use the key combination: ctrl+t
  2. You copy and paste your code in the forum. Then you select the code and you hit the formatting button aka. the button with this symbol: </>

That’s it! Please notice you do not create a new post in case you need to format something you already posted. You can edit your post, copy the code to the PDE, indent the code properly there and then past it back here, format the code and >> save << the edits.

Extra info:

Formatting your code makes everybody’s life easier, your code looks much better plus it ensures your code integrity is not affected by the forum’s formatting (Do you know the forum processes markup code?) Please visit the sticky posts or the FAQ section/post to learn about this, other advantages and super powers you can get in this brand new forum.

Kf

Main page for this library: http://www.ricardmarxer.com/fisica/

To clarify, the problem is in the draw function: mundo.step();?

Also, please avoid this: l1n The reason: It is hard to tell if the first letter is uppercase i or lowercase l. Just use another better name. Always avoid ambiguity when naming your objects, classes, functions, etc…

Check if this previous post can assist: https://forum.processing.org/one/topic/fisica-question-shapes-infinitely-created-in-class-fcontact.html

Kf

1 Like