use of nars.rover.physics.ContactPoint in project narchy by automenta.
the class DrawerRunnable method run.
@Override
public void run() {
// TODO< need to be set from outside >
float timeStep = 0.0f;
if (!panel.render()) {
return;
}
if (mouseTracing && mouseJoint == null) {
final float delay = 0.1f;
acceleration.x = 2 / delay * (1 / delay * (mouseWorld.x - mouseTracerPosition.x) - mouseTracerVelocity.x);
acceleration.y = 2 / delay * (1 / delay * (mouseWorld.y - mouseTracerPosition.y) - mouseTracerVelocity.y);
mouseTracerVelocity.x += timeStep * acceleration.x;
mouseTracerVelocity.y += timeStep * acceleration.y;
mouseTracerPosition.x += timeStep * mouseTracerVelocity.x;
mouseTracerPosition.y += timeStep * mouseTracerVelocity.y;
pshape.m_p.set(mouseTracerPosition);
pshape.m_radius = 2;
pshape.computeAABB(paabb, identity, 0);
}
if (mouseJoint != null) {
mouseJoint.getAnchorB(p1);
Vec2 p2 = mouseJoint.getTarget();
draw.drawSegment(p1, p2, mouseColor);
}
if (false) /*settings.getSetting(TestbedSettings.DrawContactPoints).enabled*/
{
final float k_impulseScale = 0.1f;
final float axisScale = 0.3f;
// TODO< need to be get from DrawingContactListener >
int pointCount = 0;
for (int i = 0; i < pointCount; i++) {
ContactPoint point = points[i];
if (point.state == Collision.PointState.ADD_STATE) {
draw.drawPoint(point.position, 10f, color1);
} else if (point.state == Collision.PointState.PERSIST_STATE) {
draw.drawPoint(point.position, 5f, color2);
}
if (settings.getSetting(TestbedSettings.DrawContactNormals).enabled) {
p1.set(point.position);
p2.set(point.normal).mulLocal(axisScale).addLocal(p1);
draw.drawSegment(p1, p2, color3);
} else if (settings.getSetting(TestbedSettings.DrawContactImpulses).enabled) {
p1.set(point.position);
p2.set(point.normal).mulLocal(k_impulseScale).mulLocal(point.normalImpulse).addLocal(p1);
draw.drawSegment(p1, p2, color5);
}
if (settings.getSetting(TestbedSettings.DrawFrictionImpulses).enabled) {
Vec2.crossToOutUnsafe(point.normal, 1, tangent);
p1.set(point.position);
p2.set(tangent).mulLocal(k_impulseScale).mulLocal(point.tangentImpulse).addLocal(p1);
draw.drawSegment(p1, p2, color5);
}
}
}
panel.paintScreen();
drawingQueued.set(false);
}
Aggregations