From b7f0be761cf4b066c44014a9db26cf63ecb5161d Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Tue, 31 Mar 2015 16:27:09 -0700 Subject: [PATCH] gun buildings fall on creation, dice stops correctly --- examples/controllers/hydra/gun.js | 4 ++-- examples/dice.js | 2 +- libraries/physics/src/CharacterController.cpp | 10 +++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/controllers/hydra/gun.js b/examples/controllers/hydra/gun.js index 8bea5d623e..9a00e181f6 100644 --- a/examples/controllers/hydra/gun.js +++ b/examples/controllers/hydra/gun.js @@ -282,7 +282,7 @@ function makePlatform(gravity, scale, size) { z: pos.z - (separation * size / 2.0) + z * separation }, dimensions: dimensions, color: { red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255 }, - velocity: { x: 0, y: 0, z: 0 }, + velocity: { x: 0, y: 0.05, z: 0 }, gravity: { x: 0, y: gravity, z: 0 }, lifetime: TARGET_LIFE, damping: 0.1, @@ -297,7 +297,7 @@ function makePlatform(gravity, scale, size) { type: "Box", position: { x: pos.x, y: pos.y - separation / 2.0, z: pos.z }, dimensions: { x: 2.0 * separation * size, y: separation / 2.0, z: 2.0 * separation * size }, - color: { red: 128, green: 128, blue: 128 }, + color: { red: 100, green: 100, blue: 100 }, lifetime: TARGET_LIFE }); diff --git a/examples/dice.js b/examples/dice.js index 2aefcf90fe..823ad1cb9b 100644 --- a/examples/dice.js +++ b/examples/dice.js @@ -92,7 +92,7 @@ function mousePressEvent(event) { var clickedText = false; var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y}); if (clickedOverlay == offButton) { - deleteDice(); + Script.stop(); } else if (clickedOverlay == diceButton) { var HOW_HARD = 2.0; var position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation())); diff --git a/libraries/physics/src/CharacterController.cpp b/libraries/physics/src/CharacterController.cpp index 09c6b5599f..808d984f72 100644 --- a/libraries/physics/src/CharacterController.cpp +++ b/libraries/physics/src/CharacterController.cpp @@ -212,6 +212,9 @@ btVector3 CharacterController::perpindicularComponent(const btVector3& direction } const btVector3 LOCAL_UP_AXIS(0.0f, 1.0f, 0.0f); +const float DEFAULT_GRAVITY = 3.5f; +const float TERMINAL_VELOCITY = 55.0f; +const float JUMP_SPEED = 2.5f; CharacterController::CharacterController(AvatarData* avatarData) { assert(avatarData); @@ -226,9 +229,9 @@ CharacterController::CharacterController(AvatarData* avatarData) { _velocityTimeInterval = 0.0f; _verticalVelocity = 0.0f; _verticalOffset = 0.0f; - _gravity = 5.0f; // slower than Earth's - _maxFallSpeed = 55.0f; // Terminal velocity of a sky diver in m/s. - _jumpSpeed = 5.0f; + _gravity = DEFAULT_GRAVITY; // slower than Earth's + _maxFallSpeed = TERMINAL_VELOCITY; // Terminal velocity of a sky diver in m/s. + _jumpSpeed = JUMP_SPEED; _isOnGround = false; _isJumping = false; _isHovering = true; @@ -343,6 +346,7 @@ bool CharacterController::recoverFromPenetration(btCollisionWorld* collisionWorl return penetration; } + void CharacterController::scanDown(btCollisionWorld* world) { // we test with downward raycast and if we don't find floor close enough then turn on "hover" btKinematicClosestNotMeRayResultCallback callback(_ghostObject);