Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/gecko0307/dagon
Browse files Browse the repository at this point in the history
  • Loading branch information
gecko0307 committed Oct 10, 2021
2 parents ddc35ca + 2dc926c commit 0e7f387
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 7 additions & 2 deletions extensions/newton/src/dagon/ext/newton/rigidbody.d
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ class NewtonRigidBody: Owner
torque += t;
}

void createUpVectorConstraint(Vector3f up)
NewtonJoint* createUpVectorConstraint(Vector3f up)
{
NewtonJoint* joint = NewtonConstraintCreateUpVector(world.newtonWorld, up.arrayof.ptr, newtonBody);
return NewtonConstraintCreateUpVector(world.newtonWorld, up.arrayof.ptr, newtonBody);
}

void velocity(Vector3f v) @property
Expand All @@ -176,6 +176,11 @@ class NewtonRigidBody: Owner
return v;
}

void addImpulse(Vector3f deltaVelocity, Vector3f impulsePoint, double dt)
{
NewtonBodyAddImpulse(newtonBody, deltaVelocity.arrayof.ptr, impulsePoint.arrayof.ptr, dt);
}

void onCollision(NewtonRigidBody otherBody)
{
collisionCallback(this, otherBody);
Expand Down
10 changes: 6 additions & 4 deletions src/dagon/ui/firstpersonview.d
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class FirstPersonViewComponent: EntityComponent
float pitchLimitMax = 60.0f;
float pitchLimitMin = -60.0f;

Quaternionf baseOrientation = Quaternionf.identity;

this(EventManager em, Entity e)
{
super(em, e);
Expand Down Expand Up @@ -100,12 +102,12 @@ class FirstPersonViewComponent: EntityComponent
auto rotPitch = rotationQuaternion(Vector3f(1.0f,0.0f,0.0f), degtorad(pitch));
auto rotTurn = rotationQuaternion(Vector3f(0.0f,1.0f,0.0f), degtorad(turn));

Quaternionf q = rotTurn * rotPitch;
Quaternionf orientation = baseOrientation * rotTurn * rotPitch;

entity.transformation =
translationMatrix(entity.position) *
q.toMatrix4x4 *
scaleMatrix(entity.scaling);
(translationMatrix(entity.position) *
orientation.toMatrix4x4 *
scaleMatrix(entity.scaling));

entity.invTransformation = entity.transformation.inverse;

Expand Down

0 comments on commit 0e7f387

Please sign in to comment.