Skip to content

Commit

Permalink
Merge pull request #68 from Alpha200/master
Browse files Browse the repository at this point in the history
Added filter in PhysicsBodyComponent
  • Loading branch information
azakhary committed Dec 23, 2015
2 parents 0ca737d + b72c66c commit 0c824a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.Filter;

public class PhysicsBodyComponent implements Component {
public int bodyType;
Expand All @@ -21,6 +22,7 @@ public class PhysicsBodyComponent implements Component {
public float density;
public float friction;
public float restitution;
public Filter filter;

public Body body;

Expand All @@ -39,5 +41,6 @@ public PhysicsBodyComponent() {
density = 1;
friction = 1;
restitution = 1;
filter = new Filter();
}
}
11 changes: 5 additions & 6 deletions src/com/uwsoft/editor/renderer/physics/PhysicsBodyLoader.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package com.uwsoft.editor.renderer.physics;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.physics.box2d.*;
import com.uwsoft.editor.renderer.components.physics.PhysicsBodyComponent;

/**
Expand Down Expand Up @@ -48,6 +43,10 @@ public Body createBody(World world, PhysicsBodyComponent physicsComponent, Vecto
fixtureDef.restitution = physicsComponent.restitution;

fixtureDef.isSensor = physicsComponent.sensor;

fixtureDef.filter.maskBits = physicsComponent.filter.maskBits;
fixtureDef.filter.groupIndex = physicsComponent.filter.groupIndex;
fixtureDef.filter.categoryBits = physicsComponent.filter.categoryBits;
}

BodyDef bodyDef = new BodyDef();
Expand Down

0 comments on commit 0c824a5

Please sign in to comment.