Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test 2D colliders for edge cases #125

Open
twaritwaikar opened this issue Oct 28, 2019 · 2 comments
Open

Test 2D colliders for edge cases #125

twaritwaikar opened this issue Oct 28, 2019 · 2 comments
Labels
bug/code Some code isn't working right subject: Awerere Related to the physics engine

Comments

@twaritwaikar
Copy link
Member

Master: v3

OS version: Windows 10

Our 2D collision algorithms are homegrown and need testing regularly after every change.

Create tests for each type of 2D collision possible with our available colliders (circle, rectangle, line, plane)

@twaritwaikar twaritwaikar added bug/code Some code isn't working right subject: Awerere Related to the physics engine labels Oct 28, 2019
@twaritwaikar twaritwaikar removed the gci label Nov 8, 2019
@BoldHonor
Copy link

BoldHonor commented Apr 20, 2020

i like to use constraints in another thread that checks and separates bodies
std::thread physicsConstraintThread(&physics::runConstraints,Constraints);
for like max of 5 to 10 times a fram so it wont be laggy while checking
The only problem with my code is i havent written my vector mats yet so i need to use angles

 void physics::constraints(collider& c1,collider& c2)
{
Vector2f moveAmount=Vector2f(0,0);
Vector2f direction = c2.location-c1.location;
float angle = atan(direction.y/direction.x);
if(angle>-1*c1.depth && angle<c1.depth)
{
    if(mod(direction.y)<(c1.bounds.height/2 + c2.bounds.height/2)-1)
    moveAmount.x= signum(c2.location.x-c1.location.x);
   
}
else
{
    if(mod(direction.x)<(c1.bounds.width/2 + c2.bounds.width/2)-1)
    moveAmount.y= 0.2*signum(c2.location.y-c1.location.y);
      
}
 c2.move(Vector2f(c2.physicsStepRatio.x* /*(c2.velocity.x+0.00001)*/ moveAmount.x,c2.physicsStepRatio.y* /*(c2.velocity.y+0.00001)*/ moveAmount.y));
// c2.move(moveAmount);
 c1.move(Vector2f(c1.physicsStepRatio.x* /*(c1.velocity.x+0.00001)*/ moveAmount.x*-1,c1.physicsStepRatio.y* /*(c1.velocity.y+0.00001)*/ moveAmount.y*-1));
//c1.move(Vector2f(moveAmount.x*-1,moveAmount.y*-1));

}

@twaritwaikar
Copy link
Member Author

@BoldHonor Do you see any performance improvements by resolving constraints like this?

Is there a specific reason that you spawn only a single thread to check constraints?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/code Some code isn't working right subject: Awerere Related to the physics engine
Projects
None yet
Development

No branches or pull requests

2 participants