mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:18:52 +02:00
No more .f
This commit is contained in:
parent
c2adc6256e
commit
ae3bcc8f06
59 changed files with 278 additions and 278 deletions
|
@ -401,8 +401,8 @@ int AudioMixer::addStreamToMixForListeningNodeWithStream(AudioMixerClientData* l
|
||||||
|
|
||||||
if (distanceBetween < RADIUS_OF_HEAD) {
|
if (distanceBetween < RADIUS_OF_HEAD) {
|
||||||
// Diminish effect if source would be inside head
|
// Diminish effect if source would be inside head
|
||||||
penumbraFilterGainL += (1.f - penumbraFilterGainL) * (1.f - distanceBetween / RADIUS_OF_HEAD);
|
penumbraFilterGainL += (1.0f - penumbraFilterGainL) * (1.0f - distanceBetween / RADIUS_OF_HEAD);
|
||||||
penumbraFilterGainR += (1.f - penumbraFilterGainR) * (1.f - distanceBetween / RADIUS_OF_HEAD);
|
penumbraFilterGainR += (1.0f - penumbraFilterGainR) * (1.0f - distanceBetween / RADIUS_OF_HEAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wantDebug = false;
|
bool wantDebug = false;
|
||||||
|
|
|
@ -146,11 +146,11 @@ void AvatarMixer::broadcastAvatarData() {
|
||||||
float distanceToAvatar = glm::length(myPosition - otherPosition);
|
float distanceToAvatar = glm::length(myPosition - otherPosition);
|
||||||
// The full rate distance is the distance at which EVERY update will be sent for this avatar
|
// The full rate distance is the distance at which EVERY update will be sent for this avatar
|
||||||
// at a distance of twice the full rate distance, there will be a 50% chance of sending this avatar's update
|
// at a distance of twice the full rate distance, there will be a 50% chance of sending this avatar's update
|
||||||
const float FULL_RATE_DISTANCE = 2.f;
|
const float FULL_RATE_DISTANCE = 2.0f;
|
||||||
|
|
||||||
// Decide whether to send this avatar's data based on it's distance from us
|
// Decide whether to send this avatar's data based on it's distance from us
|
||||||
if ((_performanceThrottlingRatio == 0 || randFloat() < (1.0f - _performanceThrottlingRatio))
|
if ((_performanceThrottlingRatio == 0 || randFloat() < (1.0f - _performanceThrottlingRatio))
|
||||||
&& (distanceToAvatar == 0.f || randFloat() < FULL_RATE_DISTANCE / distanceToAvatar)) {
|
&& (distanceToAvatar == 0.0f || randFloat() < FULL_RATE_DISTANCE / distanceToAvatar)) {
|
||||||
QByteArray avatarByteArray;
|
QByteArray avatarByteArray;
|
||||||
avatarByteArray.append(otherNode->getUUID().toRfc4122());
|
avatarByteArray.append(otherNode->getUUID().toRfc4122());
|
||||||
avatarByteArray.append(otherAvatar.toByteArray());
|
avatarByteArray.append(otherAvatar.toByteArray());
|
||||||
|
|
|
@ -700,8 +700,8 @@ bool OctreeServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
statsString += "\r\n";
|
statsString += "\r\n";
|
||||||
|
|
||||||
const char* memoryScaleLabel;
|
const char* memoryScaleLabel;
|
||||||
const float MEGABYTES = 1000000.f;
|
const float MEGABYTES = 1000000.0f;
|
||||||
const float GIGABYTES = 1000000000.f;
|
const float GIGABYTES = 1000000000.0f;
|
||||||
float memoryScale;
|
float memoryScale;
|
||||||
if (OctreeElement::getTotalMemoryUsage() / MEGABYTES < 1000.0f) {
|
if (OctreeElement::getTotalMemoryUsage() / MEGABYTES < 1000.0f) {
|
||||||
memoryScaleLabel = "MB";
|
memoryScaleLabel = "MB";
|
||||||
|
|
|
@ -604,7 +604,7 @@ void Application::initializeGL() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update before the first render
|
// update before the first render
|
||||||
update(1.f / _fps);
|
update(1.0f / _fps);
|
||||||
|
|
||||||
InfoView::showFirstTime(INFO_HELP_PATH);
|
InfoView::showFirstTime(INFO_HELP_PATH);
|
||||||
}
|
}
|
||||||
|
@ -668,7 +668,7 @@ void Application::paintGL() {
|
||||||
|
|
||||||
// Update camera position
|
// Update camera position
|
||||||
if (!OculusManager::isConnected()) {
|
if (!OculusManager::isConnected()) {
|
||||||
_myCamera.update(1.f / _fps);
|
_myCamera.update(1.0f / _fps);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: whichCamera is used to pick between the normal camera myCamera for our
|
// Note: whichCamera is used to pick between the normal camera myCamera for our
|
||||||
|
@ -693,7 +693,7 @@ void Application::paintGL() {
|
||||||
|
|
||||||
_viewFrustumOffsetCamera.setRotation(_myCamera.getRotation() * frustumRotation);
|
_viewFrustumOffsetCamera.setRotation(_myCamera.getRotation() * frustumRotation);
|
||||||
|
|
||||||
_viewFrustumOffsetCamera.update(1.f/_fps);
|
_viewFrustumOffsetCamera.update(1.0f/_fps);
|
||||||
whichCamera = &_viewFrustumOffsetCamera;
|
whichCamera = &_viewFrustumOffsetCamera;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,7 +712,7 @@ void Application::paintGL() {
|
||||||
} else {
|
} else {
|
||||||
OculusManager::display(_myAvatar->getWorldAlignedOrientation(), _myAvatar->getDefaultEyePosition(), *whichCamera);
|
OculusManager::display(_myAvatar->getWorldAlignedOrientation(), _myAvatar->getDefaultEyePosition(), *whichCamera);
|
||||||
}
|
}
|
||||||
_myCamera.update(1.f / _fps);
|
_myCamera.update(1.0f / _fps);
|
||||||
|
|
||||||
} else if (TV3DManager::isConnected()) {
|
} else if (TV3DManager::isConnected()) {
|
||||||
|
|
||||||
|
@ -918,7 +918,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
if (!_myAvatar->getDriveKeys(UP)) {
|
if (!_myAvatar->getDriveKeys(UP)) {
|
||||||
_myAvatar->jump();
|
_myAvatar->jump();
|
||||||
}
|
}
|
||||||
_myAvatar->setDriveKeys(UP, 1.f);
|
_myAvatar->setDriveKeys(UP, 1.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Asterisk:
|
case Qt::Key_Asterisk:
|
||||||
|
@ -927,14 +927,14 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
|
|
||||||
case Qt::Key_C:
|
case Qt::Key_C:
|
||||||
case Qt::Key_PageDown:
|
case Qt::Key_PageDown:
|
||||||
_myAvatar->setDriveKeys(DOWN, 1.f);
|
_myAvatar->setDriveKeys(DOWN, 1.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_W:
|
case Qt::Key_W:
|
||||||
if (isOption && !isShifted && !isMeta) {
|
if (isOption && !isShifted && !isMeta) {
|
||||||
Menu::getInstance()->triggerOption(MenuOption::Wireframe);
|
Menu::getInstance()->triggerOption(MenuOption::Wireframe);
|
||||||
} else {
|
} else {
|
||||||
_myAvatar->setDriveKeys(FWD, 1.f);
|
_myAvatar->setDriveKeys(FWD, 1.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -946,7 +946,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
} else if (!isOption && !isShifted && isMeta) {
|
} else if (!isOption && !isShifted && isMeta) {
|
||||||
takeSnapshot();
|
takeSnapshot();
|
||||||
} else {
|
} else {
|
||||||
_myAvatar->setDriveKeys(BACK, 1.f);
|
_myAvatar->setDriveKeys(BACK, 1.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -964,13 +964,13 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
if (isShifted) {
|
if (isShifted) {
|
||||||
Menu::getInstance()->triggerOption(MenuOption::Atmosphere);
|
Menu::getInstance()->triggerOption(MenuOption::Atmosphere);
|
||||||
} else {
|
} else {
|
||||||
_myAvatar->setDriveKeys(ROT_LEFT, 1.f);
|
_myAvatar->setDriveKeys(ROT_LEFT, 1.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_D:
|
case Qt::Key_D:
|
||||||
if (!isMeta) {
|
if (!isMeta) {
|
||||||
_myAvatar->setDriveKeys(ROT_RIGHT, 1.f);
|
_myAvatar->setDriveKeys(ROT_RIGHT, 1.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -998,7 +998,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
_raiseMirror += 0.05f;
|
_raiseMirror += 0.05f;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_myAvatar->setDriveKeys(isShifted ? UP : FWD, 1.f);
|
_myAvatar->setDriveKeys(isShifted ? UP : FWD, 1.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1010,23 +1010,23 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
_raiseMirror -= 0.05f;
|
_raiseMirror -= 0.05f;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_myAvatar->setDriveKeys(isShifted ? DOWN : BACK, 1.f);
|
_myAvatar->setDriveKeys(isShifted ? DOWN : BACK, 1.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Left:
|
case Qt::Key_Left:
|
||||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
_rotateMirror += PI / 20.f;
|
_rotateMirror += PI / 20.0f;
|
||||||
} else {
|
} else {
|
||||||
_myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1.f);
|
_myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Right:
|
case Qt::Key_Right:
|
||||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
_rotateMirror -= PI / 20.f;
|
_rotateMirror -= PI / 20.0f;
|
||||||
} else {
|
} else {
|
||||||
_myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1.f);
|
_myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1177,48 +1177,48 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
case Qt::Key_E:
|
case Qt::Key_E:
|
||||||
case Qt::Key_PageUp:
|
case Qt::Key_PageUp:
|
||||||
_myAvatar->setDriveKeys(UP, 0.f);
|
_myAvatar->setDriveKeys(UP, 0.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_C:
|
case Qt::Key_C:
|
||||||
case Qt::Key_PageDown:
|
case Qt::Key_PageDown:
|
||||||
_myAvatar->setDriveKeys(DOWN, 0.f);
|
_myAvatar->setDriveKeys(DOWN, 0.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_W:
|
case Qt::Key_W:
|
||||||
_myAvatar->setDriveKeys(FWD, 0.f);
|
_myAvatar->setDriveKeys(FWD, 0.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_S:
|
case Qt::Key_S:
|
||||||
_myAvatar->setDriveKeys(BACK, 0.f);
|
_myAvatar->setDriveKeys(BACK, 0.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_A:
|
case Qt::Key_A:
|
||||||
_myAvatar->setDriveKeys(ROT_LEFT, 0.f);
|
_myAvatar->setDriveKeys(ROT_LEFT, 0.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_D:
|
case Qt::Key_D:
|
||||||
_myAvatar->setDriveKeys(ROT_RIGHT, 0.f);
|
_myAvatar->setDriveKeys(ROT_RIGHT, 0.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
_myAvatar->setDriveKeys(FWD, 0.f);
|
_myAvatar->setDriveKeys(FWD, 0.0f);
|
||||||
_myAvatar->setDriveKeys(UP, 0.f);
|
_myAvatar->setDriveKeys(UP, 0.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down:
|
||||||
_myAvatar->setDriveKeys(BACK, 0.f);
|
_myAvatar->setDriveKeys(BACK, 0.0f);
|
||||||
_myAvatar->setDriveKeys(DOWN, 0.f);
|
_myAvatar->setDriveKeys(DOWN, 0.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Left:
|
case Qt::Key_Left:
|
||||||
_myAvatar->setDriveKeys(LEFT, 0.f);
|
_myAvatar->setDriveKeys(LEFT, 0.0f);
|
||||||
_myAvatar->setDriveKeys(ROT_LEFT, 0.f);
|
_myAvatar->setDriveKeys(ROT_LEFT, 0.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Right:
|
case Qt::Key_Right:
|
||||||
_myAvatar->setDriveKeys(RIGHT, 0.f);
|
_myAvatar->setDriveKeys(RIGHT, 0.0f);
|
||||||
_myAvatar->setDriveKeys(ROT_RIGHT, 0.f);
|
_myAvatar->setDriveKeys(ROT_RIGHT, 0.0f);
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Control:
|
case Qt::Key_Control:
|
||||||
case Qt::Key_Shift:
|
case Qt::Key_Shift:
|
||||||
|
@ -1522,7 +1522,7 @@ void Application::idle() {
|
||||||
PerformanceTimer perfTimer("update");
|
PerformanceTimer perfTimer("update");
|
||||||
PerformanceWarning warn(showWarnings, "Application::idle()... update()");
|
PerformanceWarning warn(showWarnings, "Application::idle()... update()");
|
||||||
const float BIGGEST_DELTA_TIME_SECS = 0.25f;
|
const float BIGGEST_DELTA_TIME_SECS = 0.25f;
|
||||||
update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS));
|
update(glm::clamp((float)timeSinceLastUpdate / 1000.0f, 0.0f, BIGGEST_DELTA_TIME_SECS));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("updateGL");
|
PerformanceTimer perfTimer("updateGL");
|
||||||
|
@ -1653,8 +1653,8 @@ void Application::makeVoxel(glm::vec3 position,
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel) {
|
glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel) {
|
||||||
return glm::vec3((mouseVoxel.x + mouseVoxel.s / 2.f) * TREE_SCALE, (mouseVoxel.y + mouseVoxel.s / 2.f) * TREE_SCALE,
|
return glm::vec3((mouseVoxel.x + mouseVoxel.s / 2.0f) * TREE_SCALE, (mouseVoxel.y + mouseVoxel.s / 2.0f) * TREE_SCALE,
|
||||||
(mouseVoxel.z + mouseVoxel.s / 2.f) * TREE_SCALE);
|
(mouseVoxel.z + mouseVoxel.s / 2.0f) * TREE_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
FaceTracker* Application::getActiveFaceTracker() {
|
FaceTracker* Application::getActiveFaceTracker() {
|
||||||
|
@ -1867,7 +1867,7 @@ void Application::init() {
|
||||||
3.0f * TREE_SCALE / 2.0f));
|
3.0f * TREE_SCALE / 2.0f));
|
||||||
_sharedVoxelSystemViewFrustum.setNearClip(TREE_SCALE / 2.0f);
|
_sharedVoxelSystemViewFrustum.setNearClip(TREE_SCALE / 2.0f);
|
||||||
_sharedVoxelSystemViewFrustum.setFarClip(3.0f * TREE_SCALE / 2.0f);
|
_sharedVoxelSystemViewFrustum.setFarClip(3.0f * TREE_SCALE / 2.0f);
|
||||||
_sharedVoxelSystemViewFrustum.setFieldOfView(90.f);
|
_sharedVoxelSystemViewFrustum.setFieldOfView(90.0f);
|
||||||
_sharedVoxelSystemViewFrustum.setOrientation(glm::quat());
|
_sharedVoxelSystemViewFrustum.setOrientation(glm::quat());
|
||||||
_sharedVoxelSystemViewFrustum.calculate();
|
_sharedVoxelSystemViewFrustum.calculate();
|
||||||
_sharedVoxelSystem.setViewFrustum(&_sharedVoxelSystemViewFrustum);
|
_sharedVoxelSystem.setViewFrustum(&_sharedVoxelSystemViewFrustum);
|
||||||
|
@ -2163,7 +2163,7 @@ void Application::updateMyAvatarLookAtPosition() {
|
||||||
} else {
|
} else {
|
||||||
// I am not looking at anyone else, so just look forward
|
// I am not looking at anyone else, so just look forward
|
||||||
lookAtSpot = _myAvatar->getHead()->getEyePosition() +
|
lookAtSpot = _myAvatar->getHead()->getEyePosition() +
|
||||||
(_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.f, 0.f, -TREE_SCALE));
|
(_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -3201,12 +3201,12 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) {
|
||||||
if (billboard) {
|
if (billboard) {
|
||||||
_mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees
|
_mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees
|
||||||
_mirrorCamera.setPosition(_myAvatar->getPosition() +
|
_mirrorCamera.setPosition(_myAvatar->getPosition() +
|
||||||
_myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale());
|
_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale());
|
||||||
|
|
||||||
} else if (_rearMirrorTools->getZoomLevel() == BODY) {
|
} else if (_rearMirrorTools->getZoomLevel() == BODY) {
|
||||||
_mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
|
_mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
|
||||||
_mirrorCamera.setPosition(_myAvatar->getChestPosition() +
|
_mirrorCamera.setPosition(_myAvatar->getChestPosition() +
|
||||||
_myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
|
_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
|
||||||
|
|
||||||
} else { // HEAD zoom level
|
} else { // HEAD zoom level
|
||||||
_mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
|
_mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
|
||||||
|
@ -3214,11 +3214,11 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) {
|
||||||
// as a hack until we have a better way of dealing with coordinate precision issues, reposition the
|
// as a hack until we have a better way of dealing with coordinate precision issues, reposition the
|
||||||
// face/body so that the average eye position lies at the origin
|
// face/body so that the average eye position lies at the origin
|
||||||
eyeRelativeCamera = true;
|
eyeRelativeCamera = true;
|
||||||
_mirrorCamera.setPosition(_myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());
|
_mirrorCamera.setPosition(_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_mirrorCamera.setPosition(_myAvatar->getHead()->getEyePosition() +
|
_mirrorCamera.setPosition(_myAvatar->getHead()->getEyePosition() +
|
||||||
_myAvatar->getOrientation() * glm::vec3(0.f, 0.f, -1.0f) * MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());
|
_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_mirrorCamera.setAspectRatio((float)region.width() / region.height());
|
_mirrorCamera.setAspectRatio((float)region.width() / region.height());
|
||||||
|
@ -4214,7 +4214,7 @@ void Application::toggleLogDialog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::initAvatarAndViewFrustum() {
|
void Application::initAvatarAndViewFrustum() {
|
||||||
updateMyAvatar(0.f);
|
updateMyAvatar(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::checkVersion() {
|
void Application::checkVersion() {
|
||||||
|
@ -4388,7 +4388,7 @@ unsigned int Application::getRenderTargetFramerate() const {
|
||||||
|
|
||||||
float Application::getRenderResolutionScale() const {
|
float Application::getRenderResolutionScale() const {
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionOne)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionOne)) {
|
||||||
return 1.f;
|
return 1.0f;
|
||||||
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionTwoThird)) {
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionTwoThird)) {
|
||||||
return 0.666f;
|
return 0.666f;
|
||||||
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionHalf)) {
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionHalf)) {
|
||||||
|
@ -4398,6 +4398,6 @@ float Application::getRenderResolutionScale() const {
|
||||||
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionQuarter)) {
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionQuarter)) {
|
||||||
return 0.25f;
|
return 0.25f;
|
||||||
} else {
|
} else {
|
||||||
return 1.f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public:
|
||||||
// setup for audio I/O
|
// setup for audio I/O
|
||||||
Audio(QObject* parent = 0);
|
Audio(QObject* parent = 0);
|
||||||
|
|
||||||
float getLastInputLoudness() const { return glm::max(_lastInputLoudness - _noiseGateMeasuredFloor, 0.f); }
|
float getLastInputLoudness() const { return glm::max(_lastInputLoudness - _noiseGateMeasuredFloor, 0.0f); }
|
||||||
float getTimeSinceLastClip() const { return _timeSinceLastClip; }
|
float getTimeSinceLastClip() const { return _timeSinceLastClip; }
|
||||||
float getAudioAverageInputLoudness() const { return _lastInputLoudness; }
|
float getAudioAverageInputLoudness() const { return _lastInputLoudness; }
|
||||||
|
|
||||||
|
|
|
@ -80,14 +80,14 @@ void Environment::renderAtmospheres(Camera& camera) {
|
||||||
glm::vec3 Environment::getGravity (const glm::vec3& position) {
|
glm::vec3 Environment::getGravity (const glm::vec3& position) {
|
||||||
//
|
//
|
||||||
// 'Default' gravity pulls you downward in Y when you are near the X/Z plane
|
// 'Default' gravity pulls you downward in Y when you are near the X/Z plane
|
||||||
const glm::vec3 DEFAULT_GRAVITY(0.f, -1.f, 0.f);
|
const glm::vec3 DEFAULT_GRAVITY(0.0f, -1.0f, 0.0f);
|
||||||
glm::vec3 gravity(DEFAULT_GRAVITY);
|
glm::vec3 gravity(DEFAULT_GRAVITY);
|
||||||
float DEFAULT_SURFACE_RADIUS = 30.f;
|
float DEFAULT_SURFACE_RADIUS = 30.0f;
|
||||||
float gravityStrength;
|
float gravityStrength;
|
||||||
|
|
||||||
// Weaken gravity with height
|
// Weaken gravity with height
|
||||||
if (position.y > 0.f) {
|
if (position.y > 0.0f) {
|
||||||
gravityStrength = 1.f / powf((DEFAULT_SURFACE_RADIUS + position.y) / DEFAULT_SURFACE_RADIUS, 2.f);
|
gravityStrength = 1.0f / powf((DEFAULT_SURFACE_RADIUS + position.y) / DEFAULT_SURFACE_RADIUS, 2.0f);
|
||||||
gravity *= gravityStrength;
|
gravity *= gravityStrength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ glm::vec3 Environment::getGravity (const glm::vec3& position) {
|
||||||
gravity += glm::normalize(vector) * environmentData.getGravity();
|
gravity += glm::normalize(vector) * environmentData.getGravity();
|
||||||
} else {
|
} else {
|
||||||
// Outside a planet, the gravity falls off with distance
|
// Outside a planet, the gravity falls off with distance
|
||||||
gravityStrength = 1.f / powf(glm::length(vector) / surfaceRadius, 2.f);
|
gravityStrength = 1.0f / powf(glm::length(vector) / surfaceRadius, 2.0f);
|
||||||
gravity += glm::normalize(vector) * environmentData.getGravity() * gravityStrength;
|
gravity += glm::normalize(vector) * environmentData.getGravity() * gravityStrength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ void Environment::renderAtmosphere(Camera& camera, const EnvironmentData& data)
|
||||||
|
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(1.f, 100, 50); //Draw a unit sphere
|
Application::getInstance()->getGeometryCache()->renderSphere(1.0f, 100, 50); //Draw a unit sphere
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
|
|
||||||
program->release();
|
program->release();
|
||||||
|
|
|
@ -78,7 +78,7 @@ Hair::Hair(int strands,
|
||||||
}
|
}
|
||||||
_hairOriginalPosition[vertexIndex] = _hairLastPosition[vertexIndex] = _hairPosition[vertexIndex] = thisVertex;
|
_hairOriginalPosition[vertexIndex] = _hairLastPosition[vertexIndex] = _hairPosition[vertexIndex] = thisVertex;
|
||||||
|
|
||||||
_hairQuadDelta[vertexIndex] = glm::vec3(cos(strandAngle) * _hairThickness, 0.f, sin(strandAngle) * _hairThickness);
|
_hairQuadDelta[vertexIndex] = glm::vec3(cos(strandAngle) * _hairThickness, 0.0f, sin(strandAngle) * _hairThickness);
|
||||||
_hairQuadDelta[vertexIndex] *= ((float)link / _links);
|
_hairQuadDelta[vertexIndex] *= ((float)link / _links);
|
||||||
_hairNormals[vertexIndex] = glm::normalize(randVector());
|
_hairNormals[vertexIndex] = glm::normalize(randVector());
|
||||||
if (randFloat() < elevation / PI_OVER_TWO) {
|
if (randFloat() < elevation / PI_OVER_TWO) {
|
||||||
|
@ -155,7 +155,7 @@ void Hair::simulate(float deltaTime) {
|
||||||
|
|
||||||
// Add stiffness to return to original position
|
// Add stiffness to return to original position
|
||||||
_hairPosition[vertexIndex] += (_hairOriginalPosition[vertexIndex] - _hairPosition[vertexIndex])
|
_hairPosition[vertexIndex] += (_hairOriginalPosition[vertexIndex] - _hairPosition[vertexIndex])
|
||||||
* powf(1.f - (float)link / _links, 2.f) * HAIR_STIFFNESS;
|
* powf(1.0f - (float)link / _links, 2.0f) * HAIR_STIFFNESS;
|
||||||
|
|
||||||
// Add angular acceleration
|
// Add angular acceleration
|
||||||
const float ANGULAR_VELOCITY_MIN = 0.001f;
|
const float ANGULAR_VELOCITY_MIN = 0.001f;
|
||||||
|
@ -163,30 +163,30 @@ void Hair::simulate(float deltaTime) {
|
||||||
glm::vec3 yawVector = _hairPosition[vertexIndex];
|
glm::vec3 yawVector = _hairPosition[vertexIndex];
|
||||||
glm::vec3 angularVelocity = _angularVelocity * HAIR_ANGULAR_VELOCITY_COUPLING;
|
glm::vec3 angularVelocity = _angularVelocity * HAIR_ANGULAR_VELOCITY_COUPLING;
|
||||||
glm::vec3 angularAcceleration = _angularAcceleration * HAIR_ANGULAR_ACCELERATION_COUPLING;
|
glm::vec3 angularAcceleration = _angularAcceleration * HAIR_ANGULAR_ACCELERATION_COUPLING;
|
||||||
yawVector.y = 0.f;
|
yawVector.y = 0.0f;
|
||||||
if (glm::length(yawVector) > EPSILON) {
|
if (glm::length(yawVector) > EPSILON) {
|
||||||
float radius = glm::length(yawVector);
|
float radius = glm::length(yawVector);
|
||||||
yawVector = glm::normalize(yawVector);
|
yawVector = glm::normalize(yawVector);
|
||||||
float angle = atan2f(yawVector.x, -yawVector.z) + PI;
|
float angle = atan2f(yawVector.x, -yawVector.z) + PI;
|
||||||
glm::vec3 delta = glm::vec3(-1.f, 0.f, 0.f) * glm::angleAxis(angle, glm::vec3(0, 1, 0));
|
glm::vec3 delta = glm::vec3(-1.0f, 0.0f, 0.0f) * glm::angleAxis(angle, glm::vec3(0, 1, 0));
|
||||||
_hairPosition[vertexIndex] -= delta * radius * (angularVelocity.y - angularAcceleration.y) * deltaTime;
|
_hairPosition[vertexIndex] -= delta * radius * (angularVelocity.y - angularAcceleration.y) * deltaTime;
|
||||||
}
|
}
|
||||||
glm::vec3 pitchVector = _hairPosition[vertexIndex];
|
glm::vec3 pitchVector = _hairPosition[vertexIndex];
|
||||||
pitchVector.x = 0.f;
|
pitchVector.x = 0.0f;
|
||||||
if (glm::length(pitchVector) > EPSILON) {
|
if (glm::length(pitchVector) > EPSILON) {
|
||||||
float radius = glm::length(pitchVector);
|
float radius = glm::length(pitchVector);
|
||||||
pitchVector = glm::normalize(pitchVector);
|
pitchVector = glm::normalize(pitchVector);
|
||||||
float angle = atan2f(pitchVector.y, -pitchVector.z) + PI;
|
float angle = atan2f(pitchVector.y, -pitchVector.z) + PI;
|
||||||
glm::vec3 delta = glm::vec3(0.0f, 1.0f, 0.f) * glm::angleAxis(angle, glm::vec3(1, 0, 0));
|
glm::vec3 delta = glm::vec3(0.0f, 1.0f, 0.0f) * glm::angleAxis(angle, glm::vec3(1, 0, 0));
|
||||||
_hairPosition[vertexIndex] -= delta * radius * (angularVelocity.x - angularAcceleration.x) * deltaTime;
|
_hairPosition[vertexIndex] -= delta * radius * (angularVelocity.x - angularAcceleration.x) * deltaTime;
|
||||||
}
|
}
|
||||||
glm::vec3 rollVector = _hairPosition[vertexIndex];
|
glm::vec3 rollVector = _hairPosition[vertexIndex];
|
||||||
rollVector.z = 0.f;
|
rollVector.z = 0.0f;
|
||||||
if (glm::length(rollVector) > EPSILON) {
|
if (glm::length(rollVector) > EPSILON) {
|
||||||
float radius = glm::length(rollVector);
|
float radius = glm::length(rollVector);
|
||||||
pitchVector = glm::normalize(rollVector);
|
pitchVector = glm::normalize(rollVector);
|
||||||
float angle = atan2f(rollVector.x, rollVector.y) + PI;
|
float angle = atan2f(rollVector.x, rollVector.y) + PI;
|
||||||
glm::vec3 delta = glm::vec3(-1.0f, 0.0f, 0.f) * glm::angleAxis(angle, glm::vec3(0, 0, 1));
|
glm::vec3 delta = glm::vec3(-1.0f, 0.0f, 0.0f) * glm::angleAxis(angle, glm::vec3(0, 0, 1));
|
||||||
_hairPosition[vertexIndex] -= delta * radius * (angularVelocity.z - angularAcceleration.z) * deltaTime;
|
_hairPosition[vertexIndex] -= delta * radius * (angularVelocity.z - angularAcceleration.z) * deltaTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,16 +216,16 @@ void Hair::render() {
|
||||||
const float HAIR_SETBACK = 0.0f;
|
const float HAIR_SETBACK = 0.0f;
|
||||||
int sparkleIndex = (int) (randFloat() * SPARKLE_EVERY);
|
int sparkleIndex = (int) (randFloat() * SPARKLE_EVERY);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(0.f, 0.f, HAIR_SETBACK);
|
glTranslatef(0.0f, 0.0f, HAIR_SETBACK);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
for (int strand = 0; strand < _strands; strand++) {
|
for (int strand = 0; strand < _strands; strand++) {
|
||||||
for (int link = 0; link < _links - 1; link++) {
|
for (int link = 0; link < _links - 1; link++) {
|
||||||
int vertexIndex = strand * _links + link;
|
int vertexIndex = strand * _links + link;
|
||||||
glm::vec3 thisColor = _hairColors[vertexIndex];
|
glm::vec3 thisColor = _hairColors[vertexIndex];
|
||||||
if (sparkleIndex % SPARKLE_EVERY == 0) {
|
if (sparkleIndex % SPARKLE_EVERY == 0) {
|
||||||
thisColor.x += (1.f - thisColor.x) * loudnessFactor;
|
thisColor.x += (1.0f - thisColor.x) * loudnessFactor;
|
||||||
thisColor.y += (1.f - thisColor.y) * loudnessFactor;
|
thisColor.y += (1.0f - thisColor.y) * loudnessFactor;
|
||||||
thisColor.z += (1.f - thisColor.z) * loudnessFactor;
|
thisColor.z += (1.0f - thisColor.z) * loudnessFactor;
|
||||||
}
|
}
|
||||||
glColor3fv(&thisColor.x);
|
glColor3fv(&thisColor.x);
|
||||||
glNormal3fv(&_hairNormals[vertexIndex].x);
|
glNormal3fv(&_hairNormals[vertexIndex].x);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
void applyStaticFriction(float deltaTime, glm::vec3& velocity, float maxVelocity, float strength) {
|
void applyStaticFriction(float deltaTime, glm::vec3& velocity, float maxVelocity, float strength) {
|
||||||
float v = glm::length(velocity);
|
float v = glm::length(velocity);
|
||||||
if (v < maxVelocity) {
|
if (v < maxVelocity) {
|
||||||
velocity *= glm::clamp((1.0f - deltaTime * strength * (1.f - v / maxVelocity)), 0.0f, 1.0f);
|
velocity *= glm::clamp((1.0f - deltaTime * strength * (1.0f - v / maxVelocity)), 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@ void applyStaticFriction(float deltaTime, glm::vec3& velocity, float maxVelocity
|
||||||
//
|
//
|
||||||
|
|
||||||
void applyDamping(float deltaTime, glm::vec3& velocity, float linearStrength, float squaredStrength) {
|
void applyDamping(float deltaTime, glm::vec3& velocity, float linearStrength, float squaredStrength) {
|
||||||
if (squaredStrength == 0.f) {
|
if (squaredStrength == 0.0f) {
|
||||||
velocity *= glm::clamp(1.f - deltaTime * linearStrength, 0.f, 1.f);
|
velocity *= glm::clamp(1.0f - deltaTime * linearStrength, 0.0f, 1.0f);
|
||||||
} else {
|
} else {
|
||||||
velocity *= glm::clamp(1.f - deltaTime * (linearStrength + glm::length(velocity) * squaredStrength), 0.f, 1.f);
|
velocity *= glm::clamp(1.0f - deltaTime * (linearStrength + glm::length(velocity) * squaredStrength), 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ void renderWorldBox() {
|
||||||
glVertex3f(TREE_SCALE, 0, 0);
|
glVertex3f(TREE_SCALE, 0, 0);
|
||||||
glEnd();
|
glEnd();
|
||||||
// Draw meter markers along the 3 axis to help with measuring things
|
// Draw meter markers along the 3 axis to help with measuring things
|
||||||
const float MARKER_DISTANCE = 1.f;
|
const float MARKER_DISTANCE = 1.0f;
|
||||||
const float MARKER_RADIUS = 0.05f;
|
const float MARKER_RADIUS = 0.05f;
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -93,7 +93,7 @@ void renderWorldBox() {
|
||||||
|
|
||||||
// Return a random vector of average length 1
|
// Return a random vector of average length 1
|
||||||
const glm::vec3 randVector() {
|
const glm::vec3 randVector() {
|
||||||
return glm::vec3(randFloat() - 0.5f, randFloat() - 0.5f, randFloat() - 0.5f) * 2.f;
|
return glm::vec3(randFloat() - 0.5f, randFloat() - 0.5f, randFloat() - 0.5f) * 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TextRenderer* textRenderer(int mono) {
|
static TextRenderer* textRenderer(int mono) {
|
||||||
|
@ -125,7 +125,7 @@ void drawText(int x, int y, float scale, float radians, int mono,
|
||||||
glTranslatef(static_cast<float>(x), static_cast<float>(y), 0.0f);
|
glTranslatef(static_cast<float>(x), static_cast<float>(y), 0.0f);
|
||||||
glColor3fv(color);
|
glColor3fv(color);
|
||||||
glRotated(double(radians * DEGREES_PER_RADIAN), 0.0, 0.0, 1.0);
|
glRotated(double(radians * DEGREES_PER_RADIAN), 0.0, 0.0, 1.0);
|
||||||
glScalef(scale / 0.1f, scale / 0.1f, 1.f);
|
glScalef(scale / 0.1f, scale / 0.1f, 1.0f);
|
||||||
textRenderer(mono)->draw(0, 0, string);
|
textRenderer(mono)->draw(0, 0, string);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -666,16 +666,16 @@ void Avatar::renderDisplayName() {
|
||||||
// we need "always facing camera": we must remove the camera rotation from the stack
|
// we need "always facing camera": we must remove the camera rotation from the stack
|
||||||
glm::quat rotation = Application::getInstance()->getCamera()->getRotation();
|
glm::quat rotation = Application::getInstance()->getCamera()->getRotation();
|
||||||
|
|
||||||
glm::vec3 frontAxis(1.f, 0.f, 0.f);
|
glm::vec3 frontAxis(1.0f, 0.0f, 0.0f);
|
||||||
frontAxis = glm::rotate(rotation, frontAxis);
|
frontAxis = glm::rotate(rotation, frontAxis);
|
||||||
frontAxis = glm::normalize(glm::vec3(frontAxis.x, 0.f, frontAxis.z));
|
frontAxis = glm::normalize(glm::vec3(frontAxis.x, 0.0f, frontAxis.z));
|
||||||
|
|
||||||
// TODO : test this secodn solution which should be better wfor occulus
|
// TODO : test this secodn solution which should be better wfor occulus
|
||||||
//glm::vec3 camPosition = Application::getInstance()->getCamera()->getPosition();
|
//glm::vec3 camPosition = Application::getInstance()->getCamera()->getPosition();
|
||||||
//glm::vec3 frontAxis = camPosition - textPosition;
|
//glm::vec3 frontAxis = camPosition - textPosition;
|
||||||
//frontAxis = glm::normalize(glm::vec3(frontAxis.z, 0.f, -frontAxis.x));
|
//frontAxis = glm::normalize(glm::vec3(frontAxis.z, 0.0f, -frontAxis.x));
|
||||||
|
|
||||||
float angle = acos(frontAxis.x) * ((frontAxis.z < 0) ? 1.f : -1.f);
|
float angle = acos(frontAxis.x) * ((frontAxis.z < 0) ? 1.0f : -1.0f);
|
||||||
glRotatef(glm::degrees(angle), 0.0f, 1.0f, 0.0f);
|
glRotatef(glm::degrees(angle), 0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
// We need to compute the scale factor such as the text remains with fixed size respect to window coordinates
|
// We need to compute the scale factor such as the text remains with fixed size respect to window coordinates
|
||||||
|
|
|
@ -68,7 +68,7 @@ void Hand::collideAgainstAvatar(Avatar* avatar, bool isMyHand) {
|
||||||
skeletonModel.getHandShapes(jointIndex, shapes);
|
skeletonModel.getHandShapes(jointIndex, shapes);
|
||||||
|
|
||||||
if (avatar->findCollisions(shapes, handCollisions)) {
|
if (avatar->findCollisions(shapes, handCollisions)) {
|
||||||
glm::vec3 totalPenetration(0.f);
|
glm::vec3 totalPenetration(0.0f);
|
||||||
glm::vec3 averageContactPoint;
|
glm::vec3 averageContactPoint;
|
||||||
for (int j = 0; j < handCollisions.size(); ++j) {
|
for (int j = 0; j < handCollisions.size(); ++j) {
|
||||||
CollisionInfo* collision = handCollisions.getCollision(j);
|
CollisionInfo* collision = handCollisions.getCollision(j);
|
||||||
|
@ -151,7 +151,7 @@ void Hand::renderHandTargets(bool isMine) {
|
||||||
|
|
||||||
const float collisionRadius = 0.05f;
|
const float collisionRadius = 0.05f;
|
||||||
glColor4f(0.5f,0.5f,0.5f, alpha);
|
glColor4f(0.5f,0.5f,0.5f, alpha);
|
||||||
glutWireSphere(collisionRadius, 10.f, 10.f);
|
glutWireSphere(collisionRadius, 10.0f, 10.0f);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,11 +45,11 @@ Head::Head(Avatar* owningAvatar) :
|
||||||
_leftEyeBlinkVelocity(0.0f),
|
_leftEyeBlinkVelocity(0.0f),
|
||||||
_rightEyeBlinkVelocity(0.0f),
|
_rightEyeBlinkVelocity(0.0f),
|
||||||
_timeWithoutTalking(0.0f),
|
_timeWithoutTalking(0.0f),
|
||||||
_deltaPitch(0.f),
|
_deltaPitch(0.0f),
|
||||||
_deltaYaw(0.f),
|
_deltaYaw(0.0f),
|
||||||
_deltaRoll(0.f),
|
_deltaRoll(0.0f),
|
||||||
_deltaLeanSideways(0.f),
|
_deltaLeanSideways(0.0f),
|
||||||
_deltaLeanForward(0.f),
|
_deltaLeanForward(0.0f),
|
||||||
_isCameraMoving(false),
|
_isCameraMoving(false),
|
||||||
_isLookingAtMe(false),
|
_isLookingAtMe(false),
|
||||||
_faceModel(this)
|
_faceModel(this)
|
||||||
|
@ -86,7 +86,7 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
||||||
}
|
}
|
||||||
// Update audio trailing average for rendering facial animations
|
// Update audio trailing average for rendering facial animations
|
||||||
const float AUDIO_AVERAGING_SECS = 0.05f;
|
const float AUDIO_AVERAGING_SECS = 0.05f;
|
||||||
const float AUDIO_LONG_TERM_AVERAGING_SECS = 30.f;
|
const float AUDIO_LONG_TERM_AVERAGING_SECS = 30.0f;
|
||||||
_averageLoudness = glm::mix(_averageLoudness, _audioLoudness, glm::min(deltaTime / AUDIO_AVERAGING_SECS, 1.0f));
|
_averageLoudness = glm::mix(_averageLoudness, _audioLoudness, glm::min(deltaTime / AUDIO_AVERAGING_SECS, 1.0f));
|
||||||
|
|
||||||
if (_longTermAverageLoudness == -1.0) {
|
if (_longTermAverageLoudness == -1.0) {
|
||||||
|
@ -223,7 +223,7 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
||||||
void Head::relaxLean(float deltaTime) {
|
void Head::relaxLean(float deltaTime) {
|
||||||
// restore rotation, lean to neutral positions
|
// restore rotation, lean to neutral positions
|
||||||
const float LEAN_RELAXATION_PERIOD = 0.25f; // seconds
|
const float LEAN_RELAXATION_PERIOD = 0.25f; // seconds
|
||||||
float relaxationFactor = 1.f - glm::min(deltaTime / LEAN_RELAXATION_PERIOD, 1.f);
|
float relaxationFactor = 1.0f - glm::min(deltaTime / LEAN_RELAXATION_PERIOD, 1.0f);
|
||||||
_deltaYaw *= relaxationFactor;
|
_deltaYaw *= relaxationFactor;
|
||||||
_deltaPitch *= relaxationFactor;
|
_deltaPitch *= relaxationFactor;
|
||||||
_deltaRoll *= relaxationFactor;
|
_deltaRoll *= relaxationFactor;
|
||||||
|
@ -276,7 +276,7 @@ glm::quat Head::getCameraOrientation () const {
|
||||||
return getOrientation();
|
return getOrientation();
|
||||||
}
|
}
|
||||||
Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
|
Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
|
||||||
return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(glm::vec3(_basePitch, 0.f, 0.0f)));
|
return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(glm::vec3(_basePitch, 0.0f, 0.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat Head::getEyeRotation(const glm::vec3& eyePosition) const {
|
glm::quat Head::getEyeRotation(const glm::vec3& eyePosition) const {
|
||||||
|
@ -323,13 +323,13 @@ void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosi
|
||||||
|
|
||||||
glLineWidth(2.0);
|
glLineWidth(2.0);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glColor4f(0.2f, 0.2f, 0.2f, 1.f);
|
glColor4f(0.2f, 0.2f, 0.2f, 1.0f);
|
||||||
glVertex3f(leftEyePosition.x, leftEyePosition.y, leftEyePosition.z);
|
glVertex3f(leftEyePosition.x, leftEyePosition.y, leftEyePosition.z);
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 0.f);
|
glColor4f(1.0f, 1.0f, 1.0f, 0.0f);
|
||||||
glVertex3f(lookatPosition.x, lookatPosition.y, lookatPosition.z);
|
glVertex3f(lookatPosition.x, lookatPosition.y, lookatPosition.z);
|
||||||
glColor4f(0.2f, 0.2f, 0.2f, 1.f);
|
glColor4f(0.2f, 0.2f, 0.2f, 1.0f);
|
||||||
glVertex3f(rightEyePosition.x, rightEyePosition.y, rightEyePosition.z);
|
glVertex3f(rightEyePosition.x, rightEyePosition.y, rightEyePosition.z);
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 0.f);
|
glColor4f(1.0f, 1.0f, 1.0f, 0.0f);
|
||||||
glVertex3f(lookatPosition.x, lookatPosition.y, lookatPosition.z);
|
glVertex3f(lookatPosition.x, lookatPosition.y, lookatPosition.z);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
|
|
@ -132,8 +132,8 @@ void MyAvatar::reset() {
|
||||||
setThrust(glm::vec3(0.0f));
|
setThrust(glm::vec3(0.0f));
|
||||||
// Reset the pitch and roll components of the avatar's orientation, preserve yaw direction
|
// Reset the pitch and roll components of the avatar's orientation, preserve yaw direction
|
||||||
glm::vec3 eulers = safeEulerAngles(getOrientation());
|
glm::vec3 eulers = safeEulerAngles(getOrientation());
|
||||||
eulers.x = 0.f;
|
eulers.x = 0.0f;
|
||||||
eulers.z = 0.f;
|
eulers.z = 0.0f;
|
||||||
setOrientation(glm::quat(eulers));
|
setOrientation(glm::quat(eulers));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -925,7 +925,7 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
||||||
}
|
}
|
||||||
glm::vec3 lookForward = faceRotation * IDENTITY_FRONT;
|
glm::vec3 lookForward = faceRotation * IDENTITY_FRONT;
|
||||||
glm::vec3 cameraPosition = Application::getInstance()->getCamera()->getPosition();
|
glm::vec3 cameraPosition = Application::getInstance()->getCamera()->getPosition();
|
||||||
float smallestAngleTo = glm::radians(Application::getInstance()->getCamera()->getFieldOfView()) / 2.f;
|
float smallestAngleTo = glm::radians(Application::getInstance()->getCamera()->getFieldOfView()) / 2.0f;
|
||||||
|
|
||||||
int howManyLookingAtMe = 0;
|
int howManyLookingAtMe = 0;
|
||||||
foreach (const AvatarSharedPointer& avatarPointer, Application::getInstance()->getAvatarManager().getAvatarHash()) {
|
foreach (const AvatarSharedPointer& avatarPointer, Application::getInstance()->getAvatarManager().getAvatarHash()) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ public:
|
||||||
// Set what driving keys are being pressed to control thrust levels
|
// Set what driving keys are being pressed to control thrust levels
|
||||||
void clearDriveKeys();
|
void clearDriveKeys();
|
||||||
void setDriveKeys(int key, float val) { _driveKeys[key] = val; };
|
void setDriveKeys(int key, float val) { _driveKeys[key] = val; };
|
||||||
bool getDriveKeys(int key) { return _driveKeys[key] != 0.f; };
|
bool getDriveKeys(int key) { return _driveKeys[key] != 0.0f; };
|
||||||
void jump() { _shouldJump = true; };
|
void jump() { _shouldJump = true; };
|
||||||
|
|
||||||
bool isMyAvatar() { return true; }
|
bool isMyAvatar() { return true; }
|
||||||
|
|
|
@ -28,7 +28,7 @@ SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent) :
|
||||||
_boundingShape(),
|
_boundingShape(),
|
||||||
_boundingShapeLocalOffset(0.0f),
|
_boundingShapeLocalOffset(0.0f),
|
||||||
_ragdoll(NULL),
|
_ragdoll(NULL),
|
||||||
_defaultEyeModelPosition(glm::vec3(0.f, 0.f, 0.f)) {
|
_defaultEyeModelPosition(glm::vec3(0.0f, 0.0f, 0.0f)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonModel::~SkeletonModel() {
|
SkeletonModel::~SkeletonModel() {
|
||||||
|
@ -45,7 +45,7 @@ void SkeletonModel::setJointStates(QVector<JointState> states) {
|
||||||
|
|
||||||
glm::vec3 leftEyePosition, rightEyePosition;
|
glm::vec3 leftEyePosition, rightEyePosition;
|
||||||
getEyeModelPositions(leftEyePosition, rightEyePosition);
|
getEyeModelPositions(leftEyePosition, rightEyePosition);
|
||||||
glm::vec3 midEyePosition = (leftEyePosition + rightEyePosition) / 2.f;
|
glm::vec3 midEyePosition = (leftEyePosition + rightEyePosition) / 2.0f;
|
||||||
|
|
||||||
int rootJointIndex = _geometry->getFBXGeometry().rootJointIndex;
|
int rootJointIndex = _geometry->getFBXGeometry().rootJointIndex;
|
||||||
glm::vec3 rootModelPosition;
|
glm::vec3 rootModelPosition;
|
||||||
|
|
|
@ -191,7 +191,7 @@ void resetCoefficient(float * coefficient, float currentValue) {
|
||||||
float updateAndGetCoefficient(float * coefficient, float currentValue, bool scaleToRange = false) {
|
float updateAndGetCoefficient(float * coefficient, float currentValue, bool scaleToRange = false) {
|
||||||
coefficient[MIN] = (currentValue < coefficient[MIN]) ? currentValue : coefficient[MIN];
|
coefficient[MIN] = (currentValue < coefficient[MIN]) ? currentValue : coefficient[MIN];
|
||||||
coefficient[MAX] = (currentValue > coefficient[MAX]) ? currentValue : coefficient[MAX];
|
coefficient[MAX] = (currentValue > coefficient[MAX]) ? currentValue : coefficient[MAX];
|
||||||
coefficient[AVG] = LONG_TERM_AVERAGE * coefficient[AVG] + (1.f - LONG_TERM_AVERAGE) * currentValue;
|
coefficient[AVG] = LONG_TERM_AVERAGE * coefficient[AVG] + (1.0f - LONG_TERM_AVERAGE) * currentValue;
|
||||||
if (coefficient[MAX] > coefficient[MIN]) {
|
if (coefficient[MAX] > coefficient[MIN]) {
|
||||||
if (scaleToRange) {
|
if (scaleToRange) {
|
||||||
return glm::clamp((currentValue - coefficient[AVG]) / (coefficient[MAX] - coefficient[MIN]), 0.0f, 1.0f);
|
return glm::clamp((currentValue - coefficient[AVG]) / (coefficient[MAX] - coefficient[MIN]), 0.0f, 1.0f);
|
||||||
|
|
|
@ -156,7 +156,7 @@ void Leapmotion::update() {
|
||||||
if (lastFrameID >= newFrameID)
|
if (lastFrameID >= newFrameID)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::vec3 delta(0.f);
|
glm::vec3 delta(0.0f);
|
||||||
glm::quat handOri;
|
glm::quat handOri;
|
||||||
if (!frame.hands().isEmpty()) {
|
if (!frame.hands().isEmpty()) {
|
||||||
for (int handNum = 0; handNum < frame.hands().count(); handNum++) {
|
for (int handNum = 0; handNum < frame.hands().count(); handNum++) {
|
||||||
|
|
|
@ -167,9 +167,9 @@ MotionTracker::Frame::Frame() :
|
||||||
|
|
||||||
void MotionTracker::Frame::setRotation(const glm::quat& rotation) {
|
void MotionTracker::Frame::setRotation(const glm::quat& rotation) {
|
||||||
glm::mat3x3 rot = glm::mat3_cast(rotation);
|
glm::mat3x3 rot = glm::mat3_cast(rotation);
|
||||||
_transform[0] = glm::vec4(rot[0], 0.f);
|
_transform[0] = glm::vec4(rot[0], 0.0f);
|
||||||
_transform[1] = glm::vec4(rot[1], 0.f);
|
_transform[1] = glm::vec4(rot[1], 0.0f);
|
||||||
_transform[2] = glm::vec4(rot[2], 0.f);
|
_transform[2] = glm::vec4(rot[2], 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MotionTracker::Frame::getRotation(glm::quat& rotation) const {
|
void MotionTracker::Frame::getRotation(glm::quat& rotation) const {
|
||||||
|
@ -177,7 +177,7 @@ void MotionTracker::Frame::getRotation(glm::quat& rotation) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MotionTracker::Frame::setTranslation(const glm::vec3& translation) {
|
void MotionTracker::Frame::setTranslation(const glm::vec3& translation) {
|
||||||
_transform[3] = glm::vec4(translation, 1.f);
|
_transform[3] = glm::vec4(translation, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MotionTracker::Frame::getTranslation(glm::vec3& translation) const {
|
void MotionTracker::Frame::getTranslation(glm::vec3& translation) const {
|
||||||
|
|
|
@ -56,7 +56,7 @@ Camera* OculusManager::_camera = NULL;
|
||||||
int OculusManager::_activeEyeIndex = -1;
|
int OculusManager::_activeEyeIndex = -1;
|
||||||
|
|
||||||
float OculusManager::CALIBRATION_DELTA_MINIMUM_LENGTH = 0.02f;
|
float OculusManager::CALIBRATION_DELTA_MINIMUM_LENGTH = 0.02f;
|
||||||
float OculusManager::CALIBRATION_DELTA_MINIMUM_ANGLE = 5.f * RADIANS_PER_DEGREE;
|
float OculusManager::CALIBRATION_DELTA_MINIMUM_ANGLE = 5.0f * RADIANS_PER_DEGREE;
|
||||||
float OculusManager::CALIBRATION_ZERO_MAXIMUM_LENGTH = 0.01f;
|
float OculusManager::CALIBRATION_ZERO_MAXIMUM_LENGTH = 0.01f;
|
||||||
float OculusManager::CALIBRATION_ZERO_MAXIMUM_ANGLE = 2.0f * RADIANS_PER_DEGREE;
|
float OculusManager::CALIBRATION_ZERO_MAXIMUM_ANGLE = 2.0f * RADIANS_PER_DEGREE;
|
||||||
quint64 OculusManager::CALIBRATION_ZERO_HOLD_TIME = 3000000; // usec
|
quint64 OculusManager::CALIBRATION_ZERO_HOLD_TIME = 3000000; // usec
|
||||||
|
@ -196,7 +196,7 @@ void OculusManager::positionCalibrationBillboard(Text3DOverlay* billboard) {
|
||||||
headOrientation.z = 0;
|
headOrientation.z = 0;
|
||||||
glm::normalize(headOrientation);
|
glm::normalize(headOrientation);
|
||||||
billboard->setPosition(Application::getInstance()->getAvatar()->getHeadPosition()
|
billboard->setPosition(Application::getInstance()->getAvatar()->getHeadPosition()
|
||||||
+ headOrientation * glm::vec3(0.f, 0.f, -CALIBRATION_MESSAGE_DISTANCE));
|
+ headOrientation * glm::vec3(0.0f, 0.0f, -CALIBRATION_MESSAGE_DISTANCE));
|
||||||
billboard->setRotation(headOrientation);
|
billboard->setRotation(headOrientation);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -106,7 +106,7 @@ static void setPalm(float deltaTime, int index) {
|
||||||
|
|
||||||
// Compute current velocity from position change
|
// Compute current velocity from position change
|
||||||
glm::vec3 rawVelocity;
|
glm::vec3 rawVelocity;
|
||||||
if (deltaTime > 0.f) {
|
if (deltaTime > 0.0f) {
|
||||||
rawVelocity = (position - palm->getRawPosition()) / deltaTime;
|
rawVelocity = (position - palm->getRawPosition()) / deltaTime;
|
||||||
} else {
|
} else {
|
||||||
rawVelocity = glm::vec3(0.0f);
|
rawVelocity = glm::vec3(0.0f);
|
||||||
|
@ -119,10 +119,10 @@ static void setPalm(float deltaTime, int index) {
|
||||||
const glm::vec3 FINGER_VECTOR(0.0f, 0.0f, FINGER_LENGTH);
|
const glm::vec3 FINGER_VECTOR(0.0f, 0.0f, FINGER_LENGTH);
|
||||||
const glm::vec3 newTipPosition = position + rotation * FINGER_VECTOR;
|
const glm::vec3 newTipPosition = position + rotation * FINGER_VECTOR;
|
||||||
glm::vec3 oldTipPosition = palm->getTipRawPosition();
|
glm::vec3 oldTipPosition = palm->getTipRawPosition();
|
||||||
if (deltaTime > 0.f) {
|
if (deltaTime > 0.0f) {
|
||||||
palm->setTipVelocity((newTipPosition - oldTipPosition) / deltaTime);
|
palm->setTipVelocity((newTipPosition - oldTipPosition) / deltaTime);
|
||||||
} else {
|
} else {
|
||||||
palm->setTipVelocity(glm::vec3(0.f));
|
palm->setTipVelocity(glm::vec3(0.0f));
|
||||||
}
|
}
|
||||||
palm->setTipPosition(newTipPosition);
|
palm->setTipPosition(newTipPosition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,16 +241,16 @@ void SixenseManager::update(float deltaTime) {
|
||||||
// Transform the measured position into body frame.
|
// Transform the measured position into body frame.
|
||||||
glm::vec3 neck = _neckBase;
|
glm::vec3 neck = _neckBase;
|
||||||
// Zeroing y component of the "neck" effectively raises the measured position a little bit.
|
// Zeroing y component of the "neck" effectively raises the measured position a little bit.
|
||||||
neck.y = 0.f;
|
neck.y = 0.0f;
|
||||||
position = _orbRotation * (position - neck);
|
position = _orbRotation * (position - neck);
|
||||||
|
|
||||||
// Rotation of Palm
|
// Rotation of Palm
|
||||||
glm::quat rotation(data->rot_quat[3], -data->rot_quat[0], data->rot_quat[1], -data->rot_quat[2]);
|
glm::quat rotation(data->rot_quat[3], -data->rot_quat[0], data->rot_quat[1], -data->rot_quat[2]);
|
||||||
rotation = glm::angleAxis(PI, glm::vec3(0.f, 1.f, 0.f)) * _orbRotation * rotation;
|
rotation = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f)) * _orbRotation * rotation;
|
||||||
|
|
||||||
// Compute current velocity from position change
|
// Compute current velocity from position change
|
||||||
glm::vec3 rawVelocity;
|
glm::vec3 rawVelocity;
|
||||||
if (deltaTime > 0.f) {
|
if (deltaTime > 0.0f) {
|
||||||
rawVelocity = (position - palm->getRawPosition()) / deltaTime;
|
rawVelocity = (position - palm->getRawPosition()) / deltaTime;
|
||||||
} else {
|
} else {
|
||||||
rawVelocity = glm::vec3(0.0f);
|
rawVelocity = glm::vec3(0.0f);
|
||||||
|
@ -287,10 +287,10 @@ void SixenseManager::update(float deltaTime) {
|
||||||
const glm::vec3 FINGER_VECTOR(0.0f, 0.0f, FINGER_LENGTH);
|
const glm::vec3 FINGER_VECTOR(0.0f, 0.0f, FINGER_LENGTH);
|
||||||
const glm::vec3 newTipPosition = position + rotation * FINGER_VECTOR;
|
const glm::vec3 newTipPosition = position + rotation * FINGER_VECTOR;
|
||||||
glm::vec3 oldTipPosition = palm->getTipRawPosition();
|
glm::vec3 oldTipPosition = palm->getTipRawPosition();
|
||||||
if (deltaTime > 0.f) {
|
if (deltaTime > 0.0f) {
|
||||||
palm->setTipVelocity((newTipPosition - oldTipPosition) / deltaTime);
|
palm->setTipVelocity((newTipPosition - oldTipPosition) / deltaTime);
|
||||||
} else {
|
} else {
|
||||||
palm->setTipVelocity(glm::vec3(0.f));
|
palm->setTipVelocity(glm::vec3(0.0f));
|
||||||
}
|
}
|
||||||
palm->setTipPosition(newTipPosition);
|
palm->setTipPosition(newTipPosition);
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers)
|
||||||
// to also handle the case where left and right controllers have been reversed.
|
// to also handle the case where left and right controllers have been reversed.
|
||||||
_neckBase = 0.5f * (_reachLeft + _reachRight); // neck is midway between right and left reaches
|
_neckBase = 0.5f * (_reachLeft + _reachRight); // neck is midway between right and left reaches
|
||||||
glm::vec3 xAxis = glm::normalize(_reachRight - _reachLeft);
|
glm::vec3 xAxis = glm::normalize(_reachRight - _reachLeft);
|
||||||
glm::vec3 yAxis(0.f, 1.f, 0.f);
|
glm::vec3 yAxis(0.0f, 1.0f, 0.0f);
|
||||||
glm::vec3 zAxis = glm::normalize(glm::cross(xAxis, yAxis));
|
glm::vec3 zAxis = glm::normalize(glm::cross(xAxis, yAxis));
|
||||||
xAxis = glm::normalize(glm::cross(yAxis, zAxis));
|
xAxis = glm::normalize(glm::cross(yAxis, zAxis));
|
||||||
_orbRotation = glm::inverse(glm::quat_cast(glm::mat3(xAxis, yAxis, zAxis)));
|
_orbRotation = glm::inverse(glm::quat_cast(glm::mat3(xAxis, yAxis, zAxis)));
|
||||||
|
@ -405,7 +405,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers)
|
||||||
} else if (now > _lockExpiry) {
|
} else if (now > _lockExpiry) {
|
||||||
// lock has expired so clamp the data and move on
|
// lock has expired so clamp the data and move on
|
||||||
_lockExpiry = now + LOCK_DURATION;
|
_lockExpiry = now + LOCK_DURATION;
|
||||||
_lastDistance = 0.f;
|
_lastDistance = 0.0f;
|
||||||
_reachUp = 0.5f * (_reachLeft + _reachRight);
|
_reachUp = 0.5f * (_reachLeft + _reachRight);
|
||||||
_calibrationState = CALIBRATION_STATE_Y;
|
_calibrationState = CALIBRATION_STATE_Y;
|
||||||
qDebug("success: sixense calibration: left");
|
qDebug("success: sixense calibration: left");
|
||||||
|
@ -424,7 +424,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers)
|
||||||
if (_lastDistance > MINIMUM_ARM_REACH) {
|
if (_lastDistance > MINIMUM_ARM_REACH) {
|
||||||
// lock has expired so clamp the data and move on
|
// lock has expired so clamp the data and move on
|
||||||
_reachForward = _reachUp;
|
_reachForward = _reachUp;
|
||||||
_lastDistance = 0.f;
|
_lastDistance = 0.0f;
|
||||||
_lockExpiry = now + LOCK_DURATION;
|
_lockExpiry = now + LOCK_DURATION;
|
||||||
_calibrationState = CALIBRATION_STATE_Z;
|
_calibrationState = CALIBRATION_STATE_Z;
|
||||||
qDebug("success: sixense calibration: up");
|
qDebug("success: sixense calibration: up");
|
||||||
|
@ -435,7 +435,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers)
|
||||||
glm::vec3 xAxis = glm::normalize(_reachRight - _reachLeft);
|
glm::vec3 xAxis = glm::normalize(_reachRight - _reachLeft);
|
||||||
glm::vec3 torso = 0.5f * (_reachLeft + _reachRight);
|
glm::vec3 torso = 0.5f * (_reachLeft + _reachRight);
|
||||||
//glm::vec3 yAxis = glm::normalize(_reachUp - torso);
|
//glm::vec3 yAxis = glm::normalize(_reachUp - torso);
|
||||||
glm::vec3 yAxis(0.f, 1.f, 0.f);
|
glm::vec3 yAxis(0.0f, 1.0f, 0.0f);
|
||||||
glm::vec3 zAxis = glm::normalize(glm::cross(xAxis, yAxis));
|
glm::vec3 zAxis = glm::normalize(glm::cross(xAxis, yAxis));
|
||||||
|
|
||||||
glm::vec3 averagePosition = 0.5f * (_averageLeft + _averageRight);
|
glm::vec3 averagePosition = 0.5f * (_averageLeft + _averageRight);
|
||||||
|
|
|
@ -82,7 +82,7 @@ void EntityTreeRenderer::init() {
|
||||||
// make sure our "last avatar position" is something other than our current position, so that on our
|
// make sure our "last avatar position" is something other than our current position, so that on our
|
||||||
// first chance, we'll check for enter/leave entity events.
|
// first chance, we'll check for enter/leave entity events.
|
||||||
glm::vec3 avatarPosition = Application::getInstance()->getAvatar()->getPosition();
|
glm::vec3 avatarPosition = Application::getInstance()->getAvatar()->getPosition();
|
||||||
_lastAvatarPosition = avatarPosition + glm::vec3(1.f, 1.f, 1.f);
|
_lastAvatarPosition = avatarPosition + glm::vec3(1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
connect(entityTree, &EntityTree::deletingEntity, this, &EntityTreeRenderer::deletingEntity);
|
connect(entityTree, &EntityTree::deletingEntity, this, &EntityTreeRenderer::deletingEntity);
|
||||||
connect(entityTree, &EntityTree::addingEntity, this, &EntityTreeRenderer::checkAndCallPreload);
|
connect(entityTree, &EntityTree::addingEntity, this, &EntityTreeRenderer::checkAndCallPreload);
|
||||||
|
|
|
@ -248,9 +248,9 @@ void DeferredLightingEffect::render() {
|
||||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, (const GLfloat*)&light.diffuse);
|
glLightfv(GL_LIGHT1, GL_DIFFUSE, (const GLfloat*)&light.diffuse);
|
||||||
glLightfv(GL_LIGHT1, GL_SPECULAR, (const GLfloat*)&light.specular);
|
glLightfv(GL_LIGHT1, GL_SPECULAR, (const GLfloat*)&light.specular);
|
||||||
glLightfv(GL_LIGHT1, GL_POSITION, (const GLfloat*)&light.position);
|
glLightfv(GL_LIGHT1, GL_POSITION, (const GLfloat*)&light.position);
|
||||||
glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, (light.constantAttenuation > 0.f ? light.constantAttenuation : 0.f));
|
glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, (light.constantAttenuation > 0.0f ? light.constantAttenuation : 0.0f));
|
||||||
glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, (light.linearAttenuation > 0.f ? light.linearAttenuation : 0.f));
|
glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, (light.linearAttenuation > 0.0f ? light.linearAttenuation : 0.0f));
|
||||||
glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, (light.quadraticAttenuation > 0.f ? light.quadraticAttenuation : 0.f));
|
glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, (light.quadraticAttenuation > 0.0f ? light.quadraticAttenuation : 0.0f));
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
|
@ -293,9 +293,9 @@ void DeferredLightingEffect::render() {
|
||||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, (const GLfloat*)&light.diffuse);
|
glLightfv(GL_LIGHT1, GL_DIFFUSE, (const GLfloat*)&light.diffuse);
|
||||||
glLightfv(GL_LIGHT1, GL_SPECULAR, (const GLfloat*)&light.specular);
|
glLightfv(GL_LIGHT1, GL_SPECULAR, (const GLfloat*)&light.specular);
|
||||||
glLightfv(GL_LIGHT1, GL_POSITION, (const GLfloat*)&light.position);
|
glLightfv(GL_LIGHT1, GL_POSITION, (const GLfloat*)&light.position);
|
||||||
glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, (light.constantAttenuation > 0.f ? light.constantAttenuation : 0.f));
|
glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, (light.constantAttenuation > 0.0f ? light.constantAttenuation : 0.0f));
|
||||||
glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, (light.linearAttenuation > 0.f ? light.linearAttenuation : 0.f));
|
glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, (light.linearAttenuation > 0.0f ? light.linearAttenuation : 0.0f));
|
||||||
glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, (light.quadraticAttenuation > 0.f ? light.quadraticAttenuation : 0.f));
|
glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, (light.quadraticAttenuation > 0.0f ? light.quadraticAttenuation : 0.0f));
|
||||||
glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, (const GLfloat*)&light.direction);
|
glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, (const GLfloat*)&light.direction);
|
||||||
glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, light.exponent);
|
glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, light.exponent);
|
||||||
glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, glm::degrees(light.cutoff));
|
glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, glm::degrees(light.cutoff));
|
||||||
|
|
|
@ -296,7 +296,7 @@ void GeometryCache::renderHalfCylinder(int slices, int stacks) {
|
||||||
float y = (float)i / (stacks - 1);
|
float y = (float)i / (stacks - 1);
|
||||||
|
|
||||||
for (int j = 0; j <= slices; j++) {
|
for (int j = 0; j <= slices; j++) {
|
||||||
float theta = 3.f * PI_OVER_TWO + PI * (float)j / (float)slices;
|
float theta = 3.0f * PI_OVER_TWO + PI * (float)j / (float)slices;
|
||||||
|
|
||||||
//normals
|
//normals
|
||||||
*(vertex++) = sinf(theta);
|
*(vertex++) = sinf(theta);
|
||||||
|
|
|
@ -1330,7 +1330,7 @@ void Model::inverseKinematics(int endIndex, glm::vec3 targetPosition, const glm:
|
||||||
centerOfMass += _jointStates[massIndex].getPosition() - pivot;
|
centerOfMass += _jointStates[massIndex].getPosition() - pivot;
|
||||||
}
|
}
|
||||||
// the gravitational effect is a rotation that tends to align the two cross products
|
// the gravitational effect is a rotation that tends to align the two cross products
|
||||||
const glm::vec3 worldAlignment = glm::vec3(0.0f, -1.f, 0.0f);
|
const glm::vec3 worldAlignment = glm::vec3(0.0f, -1.0f, 0.0f);
|
||||||
glm::quat gravityDelta = rotationBetween(glm::cross(centerOfMass, leverArm),
|
glm::quat gravityDelta = rotationBetween(glm::cross(centerOfMass, leverArm),
|
||||||
glm::cross(worldAlignment, leverArm));
|
glm::cross(worldAlignment, leverArm));
|
||||||
|
|
||||||
|
@ -2173,7 +2173,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
|
||||||
GLBATCH(glMaterialfv)(GL_FRONT, GL_AMBIENT, (const float*)&diffuse);
|
GLBATCH(glMaterialfv)(GL_FRONT, GL_AMBIENT, (const float*)&diffuse);
|
||||||
GLBATCH(glMaterialfv)(GL_FRONT, GL_DIFFUSE, (const float*)&diffuse);
|
GLBATCH(glMaterialfv)(GL_FRONT, GL_DIFFUSE, (const float*)&diffuse);
|
||||||
GLBATCH(glMaterialfv)(GL_FRONT, GL_SPECULAR, (const float*)&specular);
|
GLBATCH(glMaterialfv)(GL_FRONT, GL_SPECULAR, (const float*)&specular);
|
||||||
GLBATCH(glMaterialf)(GL_FRONT, GL_SHININESS, (part.shininess > 128.f ? 128.f: part.shininess));
|
GLBATCH(glMaterialf)(GL_FRONT, GL_SHININESS, (part.shininess > 128.0f ? 128.0f: part.shininess));
|
||||||
|
|
||||||
Texture* diffuseMap = networkPart.diffuseTexture.data();
|
Texture* diffuseMap = networkPart.diffuseTexture.data();
|
||||||
if (mesh.isEye && diffuseMap) {
|
if (mesh.isEye && diffuseMap) {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
using namespace starfield;
|
using namespace starfield;
|
||||||
|
|
||||||
const float Generator::STAR_COLORIZATION = 0.1f;
|
const float Generator::STAR_COLORIZATION = 0.1f;
|
||||||
const float PI_OVER_180 = 3.14159265358979f / 180.f;
|
const float PI_OVER_180 = 3.14159265358979f / 180.0f;
|
||||||
|
|
||||||
void Generator::computeStarPositions(InputVertices& destination, unsigned limit, unsigned seed) {
|
void Generator::computeStarPositions(InputVertices& destination, unsigned limit, unsigned seed) {
|
||||||
InputVertices* vertices = & destination;
|
InputVertices* vertices = & destination;
|
||||||
|
@ -44,9 +44,9 @@ void Generator::computeStarPositions(InputVertices& destination, unsigned limit,
|
||||||
|
|
||||||
for(int star = 0; star < ceil(limit * MILKY_WAY_RATIO); ++star) {
|
for(int star = 0; star < ceil(limit * MILKY_WAY_RATIO); ++star) {
|
||||||
float azimuth = ((float)rand() / (float) RAND_MAX) * NUM_DEGREES;
|
float azimuth = ((float)rand() / (float) RAND_MAX) * NUM_DEGREES;
|
||||||
float altitude = powf(randFloat()*0.5f, 2.f)/0.25f * MILKY_WAY_WIDTH;
|
float altitude = powf(randFloat()*0.5f, 2.0f)/0.25f * MILKY_WAY_WIDTH;
|
||||||
if (randFloat() > 0.5f) {
|
if (randFloat() > 0.5f) {
|
||||||
altitude *= -1.f;
|
altitude *= -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to rotate the Milky Way band to the correct orientation in the sky
|
// we need to rotate the Milky Way band to the correct orientation in the sky
|
||||||
|
|
|
@ -999,26 +999,26 @@ void ApplicationOverlay::renderAudioMeter() {
|
||||||
const float AUDIO_RED_START = 0.80 * AUDIO_METER_SCALE_WIDTH;
|
const float AUDIO_RED_START = 0.80 * AUDIO_METER_SCALE_WIDTH;
|
||||||
const float CLIPPING_INDICATOR_TIME = 1.0f;
|
const float CLIPPING_INDICATOR_TIME = 1.0f;
|
||||||
const float AUDIO_METER_AVERAGING = 0.5;
|
const float AUDIO_METER_AVERAGING = 0.5;
|
||||||
const float LOG2 = log(2.f);
|
const float LOG2 = log(2.0f);
|
||||||
const float METER_LOUDNESS_SCALE = 2.8f / 5.f;
|
const float METER_LOUDNESS_SCALE = 2.8f / 5.0f;
|
||||||
const float LOG2_LOUDNESS_FLOOR = 11.f;
|
const float LOG2_LOUDNESS_FLOOR = 11.0f;
|
||||||
float audioLevel = 0.f;
|
float audioLevel = 0.0f;
|
||||||
float loudness = audio->getLastInputLoudness() + 1.f;
|
float loudness = audio->getLastInputLoudness() + 1.0f;
|
||||||
|
|
||||||
_trailingAudioLoudness = AUDIO_METER_AVERAGING * _trailingAudioLoudness + (1.f - AUDIO_METER_AVERAGING) * loudness;
|
_trailingAudioLoudness = AUDIO_METER_AVERAGING * _trailingAudioLoudness + (1.0f - AUDIO_METER_AVERAGING) * loudness;
|
||||||
float log2loudness = log(_trailingAudioLoudness) / LOG2;
|
float log2loudness = log(_trailingAudioLoudness) / LOG2;
|
||||||
|
|
||||||
if (log2loudness <= LOG2_LOUDNESS_FLOOR) {
|
if (log2loudness <= LOG2_LOUDNESS_FLOOR) {
|
||||||
audioLevel = (log2loudness / LOG2_LOUDNESS_FLOOR) * METER_LOUDNESS_SCALE * AUDIO_METER_SCALE_WIDTH;
|
audioLevel = (log2loudness / LOG2_LOUDNESS_FLOOR) * METER_LOUDNESS_SCALE * AUDIO_METER_SCALE_WIDTH;
|
||||||
} else {
|
} else {
|
||||||
audioLevel = (log2loudness - (LOG2_LOUDNESS_FLOOR - 1.f)) * METER_LOUDNESS_SCALE * AUDIO_METER_SCALE_WIDTH;
|
audioLevel = (log2loudness - (LOG2_LOUDNESS_FLOOR - 1.0f)) * METER_LOUDNESS_SCALE * AUDIO_METER_SCALE_WIDTH;
|
||||||
}
|
}
|
||||||
if (audioLevel > AUDIO_METER_SCALE_WIDTH) {
|
if (audioLevel > AUDIO_METER_SCALE_WIDTH) {
|
||||||
audioLevel = AUDIO_METER_SCALE_WIDTH;
|
audioLevel = AUDIO_METER_SCALE_WIDTH;
|
||||||
}
|
}
|
||||||
bool isClipping = ((audio->getTimeSinceLastClip() > 0.f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME));
|
bool isClipping = ((audio->getTimeSinceLastClip() > 0.0f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME));
|
||||||
|
|
||||||
if ((audio->getTimeSinceLastClip() > 0.f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) {
|
if ((audio->getTimeSinceLastClip() > 0.0f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) {
|
||||||
const float MAX_MAGNITUDE = 0.7f;
|
const float MAX_MAGNITUDE = 0.7f;
|
||||||
float magnitude = MAX_MAGNITUDE * (1 - audio->getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME);
|
float magnitude = MAX_MAGNITUDE * (1 - audio->getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME);
|
||||||
renderCollisionOverlay(glWidget->width(), glWidget->height(), magnitude, 1.0f);
|
renderCollisionOverlay(glWidget->width(), glWidget->height(), magnitude, 1.0f);
|
||||||
|
|
|
@ -130,22 +130,22 @@ void OctreeStatsDialog::paintEvent(QPaintEvent* event) {
|
||||||
|
|
||||||
// Voxels Rendered
|
// Voxels Rendered
|
||||||
label = _labels[_voxelsRendered];
|
label = _labels[_voxelsRendered];
|
||||||
statsValue << "Max: " << voxels->getMaxVoxels() / 1000.f << "K " <<
|
statsValue << "Max: " << voxels->getMaxVoxels() / 1000.0f << "K " <<
|
||||||
"Drawn: " << voxels->getVoxelsWritten() / 1000.f << "K " <<
|
"Drawn: " << voxels->getVoxelsWritten() / 1000.0f << "K " <<
|
||||||
"Abandoned: " << voxels->getAbandonedVoxels() / 1000.f << "K " <<
|
"Abandoned: " << voxels->getAbandonedVoxels() / 1000.0f << "K " <<
|
||||||
"ReadBuffer: " << voxels->getVoxelsRendered() / 1000.f << "K " <<
|
"ReadBuffer: " << voxels->getVoxelsRendered() / 1000.0f << "K " <<
|
||||||
"Changed: " << voxels->getVoxelsUpdated() / 1000.f << "K ";
|
"Changed: " << voxels->getVoxelsUpdated() / 1000.0f << "K ";
|
||||||
label->setText(statsValue.str().c_str());
|
label->setText(statsValue.str().c_str());
|
||||||
|
|
||||||
// Voxels Memory Usage
|
// Voxels Memory Usage
|
||||||
label = _labels[_localVoxelsMemory];
|
label = _labels[_localVoxelsMemory];
|
||||||
statsValue.str("");
|
statsValue.str("");
|
||||||
statsValue <<
|
statsValue <<
|
||||||
"Elements RAM: " << OctreeElement::getTotalMemoryUsage() / 1000000.f << "MB "
|
"Elements RAM: " << OctreeElement::getTotalMemoryUsage() / 1000000.0f << "MB "
|
||||||
"Geometry RAM: " << voxels->getVoxelMemoryUsageRAM() / 1000000.f << "MB " <<
|
"Geometry RAM: " << voxels->getVoxelMemoryUsageRAM() / 1000000.0f << "MB " <<
|
||||||
"VBO: " << voxels->getVoxelMemoryUsageVBO() / 1000000.f << "MB ";
|
"VBO: " << voxels->getVoxelMemoryUsageVBO() / 1000000.0f << "MB ";
|
||||||
if (voxels->hasVoxelMemoryUsageGPU()) {
|
if (voxels->hasVoxelMemoryUsageGPU()) {
|
||||||
statsValue << "GPU: " << voxels->getVoxelMemoryUsageGPU() / 1000000.f << "MB ";
|
statsValue << "GPU: " << voxels->getVoxelMemoryUsageGPU() / 1000000.0f << "MB ";
|
||||||
}
|
}
|
||||||
label->setText(statsValue.str().c_str());
|
label->setText(statsValue.str().c_str());
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ void Stats::display(
|
||||||
char packetsPerSecondString[30];
|
char packetsPerSecondString[30];
|
||||||
sprintf(packetsPerSecondString, "Pkts/sec: %d", packetsPerSecond);
|
sprintf(packetsPerSecondString, "Pkts/sec: %d", packetsPerSecond);
|
||||||
char averageMegabitsPerSecond[30];
|
char averageMegabitsPerSecond[30];
|
||||||
sprintf(averageMegabitsPerSecond, "Mbps: %3.2f", (float)bytesPerSecond * 8.f / 1000000.f);
|
sprintf(averageMegabitsPerSecond, "Mbps: %3.2f", (float)bytesPerSecond * 8.0f / 1000000.0f);
|
||||||
|
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, packetsPerSecondString, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, packetsPerSecondString, color);
|
||||||
|
@ -501,24 +501,24 @@ void Stats::display(
|
||||||
|
|
||||||
voxelStats.str("");
|
voxelStats.str("");
|
||||||
voxelStats.precision(4);
|
voxelStats.precision(4);
|
||||||
voxelStats << "Voxels Drawn: " << voxels->getVoxelsWritten() / 1000.f << "K " <<
|
voxelStats << "Voxels Drawn: " << voxels->getVoxelsWritten() / 1000.0f << "K " <<
|
||||||
"Abandoned: " << voxels->getAbandonedVoxels() / 1000.f << "K ";
|
"Abandoned: " << voxels->getAbandonedVoxels() / 1000.0f << "K ";
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color);
|
||||||
|
|
||||||
if (_expanded) {
|
if (_expanded) {
|
||||||
// Local Voxel Memory Usage
|
// Local Voxel Memory Usage
|
||||||
voxelStats.str("");
|
voxelStats.str("");
|
||||||
voxelStats << " Voxels Memory Nodes: " << VoxelTreeElement::getTotalMemoryUsage() / 1000000.f << "MB";
|
voxelStats << " Voxels Memory Nodes: " << VoxelTreeElement::getTotalMemoryUsage() / 1000000.0f << "MB";
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color);
|
||||||
|
|
||||||
voxelStats.str("");
|
voxelStats.str("");
|
||||||
voxelStats <<
|
voxelStats <<
|
||||||
" Geometry RAM: " << voxels->getVoxelMemoryUsageRAM() / 1000000.f << "MB / " <<
|
" Geometry RAM: " << voxels->getVoxelMemoryUsageRAM() / 1000000.0f << "MB / " <<
|
||||||
"VBO: " << voxels->getVoxelMemoryUsageVBO() / 1000000.f << "MB";
|
"VBO: " << voxels->getVoxelMemoryUsageVBO() / 1000000.0f << "MB";
|
||||||
if (voxels->hasVoxelMemoryUsageGPU()) {
|
if (voxels->hasVoxelMemoryUsageGPU()) {
|
||||||
voxelStats << " / GPU: " << voxels->getVoxelMemoryUsageGPU() / 1000000.f << "MB";
|
voxelStats << " / GPU: " << voxels->getVoxelMemoryUsageGPU() / 1000000.0f << "MB";
|
||||||
}
|
}
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color);
|
||||||
|
@ -526,7 +526,7 @@ void Stats::display(
|
||||||
// Voxel Rendering
|
// Voxel Rendering
|
||||||
voxelStats.str("");
|
voxelStats.str("");
|
||||||
voxelStats.precision(4);
|
voxelStats.precision(4);
|
||||||
voxelStats << " Voxel Rendering Slots Max: " << voxels->getMaxVoxels() / 1000.f << "K";
|
voxelStats << " Voxel Rendering Slots Max: " << voxels->getMaxVoxels() / 1000.0f << "K";
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color);
|
||||||
}
|
}
|
||||||
|
@ -746,7 +746,7 @@ void Stats::display(
|
||||||
audioReflector->getEchoesAttenuation());
|
audioReflector->getEchoesAttenuation());
|
||||||
|
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, color);
|
drawText(horizontalOffset, verticalOffset, 0.10f, 0.0f, 2.0f, reflectionsStatus, color);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,12 +73,12 @@ int TextRenderer::draw(int x, int y, const char* str, float alpha) {
|
||||||
// Grab the current color
|
// Grab the current color
|
||||||
float currentColor[4];
|
float currentColor[4];
|
||||||
glGetFloatv(GL_CURRENT_COLOR, currentColor);
|
glGetFloatv(GL_CURRENT_COLOR, currentColor);
|
||||||
alpha = std::max(0.f, std::min(alpha, 1.f));
|
alpha = std::max(0.0f, std::min(alpha, 1.0f));
|
||||||
currentColor[3] *= alpha;
|
currentColor[3] *= alpha;
|
||||||
int compactColor = ((int(currentColor[0] * 255.f) & 0xFF)) |
|
int compactColor = ((int(currentColor[0] * 255.0f) & 0xFF)) |
|
||||||
((int(currentColor[1] * 255.f) & 0xFF) << 8) |
|
((int(currentColor[1] * 255.0f) & 0xFF) << 8) |
|
||||||
((int(currentColor[2] * 255.f) & 0xFF) << 16) |
|
((int(currentColor[2] * 255.0f) & 0xFF) << 16) |
|
||||||
((int(currentColor[3] * 255.f) & 0xFF) << 24);
|
((int(currentColor[3] * 255.0f) & 0xFF) << 24);
|
||||||
|
|
||||||
// TODO: Remove that code once we test for performance improvments
|
// TODO: Remove that code once we test for performance improvments
|
||||||
//glEnable(GL_TEXTURE_2D);
|
//glEnable(GL_TEXTURE_2D);
|
||||||
|
|
|
@ -63,7 +63,7 @@ public:
|
||||||
int calculateHeight(const char* str);
|
int calculateHeight(const char* str);
|
||||||
|
|
||||||
// also returns the height of the tallest character
|
// also returns the height of the tallest character
|
||||||
int draw(int x, int y, const char* str, float alpha = 1.f);
|
int draw(int x, int y, const char* str, float alpha = 1.0f);
|
||||||
|
|
||||||
int computeWidth(char ch);
|
int computeWidth(char ch);
|
||||||
int computeWidth(const char* str);
|
int computeWidth(const char* str);
|
||||||
|
|
|
@ -38,7 +38,7 @@ AvatarData::AvatarData() :
|
||||||
_position(0.0f),
|
_position(0.0f),
|
||||||
_handPosition(0.0f),
|
_handPosition(0.0f),
|
||||||
_referential(NULL),
|
_referential(NULL),
|
||||||
_bodyYaw(-90.f),
|
_bodyYaw(-90.0f),
|
||||||
_bodyPitch(0.0f),
|
_bodyPitch(0.0f),
|
||||||
_bodyRoll(0.0f),
|
_bodyRoll(0.0f),
|
||||||
_targetScale(1.0f),
|
_targetScale(1.0f),
|
||||||
|
|
|
@ -83,7 +83,7 @@ const int IS_FACESHIFT_CONNECTED = 4; // 5th bit
|
||||||
const int IS_CHAT_CIRCLING_ENABLED = 5; // 6th bit
|
const int IS_CHAT_CIRCLING_ENABLED = 5; // 6th bit
|
||||||
const int HAS_REFERENTIAL = 6; // 7th bit
|
const int HAS_REFERENTIAL = 6; // 7th bit
|
||||||
|
|
||||||
static const float MAX_AVATAR_SCALE = 1000.f;
|
static const float MAX_AVATAR_SCALE = 1000.0f;
|
||||||
static const float MIN_AVATAR_SCALE = .005f;
|
static const float MIN_AVATAR_SCALE = .005f;
|
||||||
|
|
||||||
const float MAX_AUDIO_LOUDNESS = 1000.0; // close enough for mouth animation
|
const float MAX_AUDIO_LOUDNESS = 1000.0; // close enough for mouth animation
|
||||||
|
@ -281,7 +281,7 @@ public:
|
||||||
|
|
||||||
QElapsedTimer& getLastUpdateTimer() { return _lastUpdateTimer; }
|
QElapsedTimer& getLastUpdateTimer() { return _lastUpdateTimer; }
|
||||||
|
|
||||||
virtual float getBoundingRadius() const { return 1.f; }
|
virtual float getBoundingRadius() const { return 1.0f; }
|
||||||
|
|
||||||
const Referential* getReferential() const { return _referential; }
|
const Referential* getReferential() const { return _referential; }
|
||||||
|
|
||||||
|
|
|
@ -64,11 +64,11 @@ void HandData::getLeftRightPalmIndices(int& leftPalmIndex, int& rightPalmIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
PalmData::PalmData(HandData* owningHandData) :
|
PalmData::PalmData(HandData* owningHandData) :
|
||||||
_rawRotation(0.f, 0.f, 0.f, 1.f),
|
_rawRotation(0.0f, 0.0f, 0.0f, 1.0f),
|
||||||
_rawPosition(0.f),
|
_rawPosition(0.0f),
|
||||||
_rawVelocity(0.f),
|
_rawVelocity(0.0f),
|
||||||
_rotationalVelocity(0.f),
|
_rotationalVelocity(0.0f),
|
||||||
_totalPenetration(0.f),
|
_totalPenetration(0.0f),
|
||||||
_controllerButtons(0),
|
_controllerButtons(0),
|
||||||
_isActive(false),
|
_isActive(false),
|
||||||
_sixenseID(SIXENSEID_INVALID),
|
_sixenseID(SIXENSEID_INVALID),
|
||||||
|
|
|
@ -100,7 +100,7 @@ public:
|
||||||
void addToPosition(const glm::vec3& delta);
|
void addToPosition(const glm::vec3& delta);
|
||||||
|
|
||||||
void addToPenetration(const glm::vec3& penetration) { _totalPenetration += penetration; }
|
void addToPenetration(const glm::vec3& penetration) { _totalPenetration += penetration; }
|
||||||
void resolvePenetrations() { addToPosition(-_totalPenetration); _totalPenetration = glm::vec3(0.f); }
|
void resolvePenetrations() { addToPosition(-_totalPenetration); _totalPenetration = glm::vec3(0.0f); }
|
||||||
|
|
||||||
void setTipPosition(const glm::vec3& position) { _tipPosition = position; }
|
void setTipPosition(const glm::vec3& position) { _tipPosition = position; }
|
||||||
const glm::vec3 getTipPosition() const { return _owningHandData->localToWorldPosition(_tipPosition); }
|
const glm::vec3 getTipPosition() const { return _owningHandData->localToWorldPosition(_tipPosition); }
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
|
||||||
// degrees
|
// degrees
|
||||||
const float MIN_HEAD_YAW = -180.f;
|
const float MIN_HEAD_YAW = -180.0f;
|
||||||
const float MAX_HEAD_YAW = 180.f;
|
const float MAX_HEAD_YAW = 180.0f;
|
||||||
const float MIN_HEAD_PITCH = -60.f;
|
const float MIN_HEAD_PITCH = -60.0f;
|
||||||
const float MAX_HEAD_PITCH = 60.f;
|
const float MAX_HEAD_PITCH = 60.0f;
|
||||||
const float MIN_HEAD_ROLL = -50.f;
|
const float MIN_HEAD_ROLL = -50.0f;
|
||||||
const float MAX_HEAD_ROLL = 50.f;
|
const float MAX_HEAD_ROLL = 50.0f;
|
||||||
|
|
||||||
class AvatarData;
|
class AvatarData;
|
||||||
|
|
||||||
|
|
|
@ -265,7 +265,7 @@ void EntityCollisionSystem::updateCollisionWithAvatars(EntityItem* entity) {
|
||||||
collision->_addedVelocity /= (float)(TREE_SCALE);
|
collision->_addedVelocity /= (float)(TREE_SCALE);
|
||||||
glm::vec3 relativeVelocity = collision->_addedVelocity - entity->getVelocity();
|
glm::vec3 relativeVelocity = collision->_addedVelocity - entity->getVelocity();
|
||||||
|
|
||||||
if (glm::dot(relativeVelocity, collision->_penetration) <= 0.f) {
|
if (glm::dot(relativeVelocity, collision->_penetration) <= 0.0f) {
|
||||||
// only collide when Entity and collision point are moving toward each other
|
// only collide when Entity and collision point are moving toward each other
|
||||||
// (doing this prevents some "collision snagging" when Entity penetrates the object)
|
// (doing this prevents some "collision snagging" when Entity penetrates the object)
|
||||||
collision->_penetration /= (float)(TREE_SCALE);
|
collision->_penetration /= (float)(TREE_SCALE);
|
||||||
|
|
|
@ -621,7 +621,7 @@ void EntityTreeElement::getEntities(const AACube& box, QVector<EntityItem*>& fou
|
||||||
// NOTE: we actually do cube-cube collision queries here, which is sloppy but good enough for now
|
// NOTE: we actually do cube-cube collision queries here, which is sloppy but good enough for now
|
||||||
// TODO: decide whether to replace entityCube-cube query with sphere-cube (requires a square root
|
// TODO: decide whether to replace entityCube-cube query with sphere-cube (requires a square root
|
||||||
// but will be slightly more accurate).
|
// but will be slightly more accurate).
|
||||||
entityCube.setBox(entity->getPosition() - glm::vec3(radius), 2.f * radius);
|
entityCube.setBox(entity->getPosition() - glm::vec3(radius), 2.0f * radius);
|
||||||
if (entityCube.touches(box)) {
|
if (entityCube.touches(box)) {
|
||||||
foundEntities.push_back(entity);
|
foundEntities.push_back(entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -984,7 +984,7 @@ class JointShapeInfo {
|
||||||
public:
|
public:
|
||||||
JointShapeInfo() : numVertices(0),
|
JointShapeInfo() : numVertices(0),
|
||||||
sumVertexWeights(0.0f), sumWeightedRadii(0.0f), numVertexWeights(0),
|
sumVertexWeights(0.0f), sumWeightedRadii(0.0f), numVertexWeights(0),
|
||||||
averageVertex(0.f), boneBegin(0.f), averageRadius(0.f) {
|
averageVertex(0.0f), boneBegin(0.0f), averageRadius(0.0f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: the points here are in the "joint frame" which has the "jointEnd" at the origin
|
// NOTE: the points here are in the "joint frame" which has the "jointEnd" at the origin
|
||||||
|
@ -1556,7 +1556,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
joint.boneRadius = 0.0f;
|
joint.boneRadius = 0.0f;
|
||||||
joint.inverseBindRotation = joint.inverseDefaultRotation;
|
joint.inverseBindRotation = joint.inverseDefaultRotation;
|
||||||
joint.name = model.name;
|
joint.name = model.name;
|
||||||
joint.shapePosition = glm::vec3(0.f);
|
joint.shapePosition = glm::vec3(0.0f);
|
||||||
joint.shapeType = SHAPE_TYPE_UNKNOWN;
|
joint.shapeType = SHAPE_TYPE_UNKNOWN;
|
||||||
|
|
||||||
foreach (const QString& childID, childMap.values(modelID)) {
|
foreach (const QString& childID, childMap.values(modelID)) {
|
||||||
|
@ -1880,7 +1880,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
}
|
}
|
||||||
float radiusScale = extractUniformScale(joint.transform * firstFBXCluster.inverseBindMatrix);
|
float radiusScale = extractUniformScale(joint.transform * firstFBXCluster.inverseBindMatrix);
|
||||||
|
|
||||||
glm::vec3 averageVertex(0.f);
|
glm::vec3 averageVertex(0.0f);
|
||||||
foreach (const glm::vec3& vertex, extracted.mesh.vertices) {
|
foreach (const glm::vec3& vertex, extracted.mesh.vertices) {
|
||||||
float proj = glm::dot(boneDirection, boneEnd - vertex);
|
float proj = glm::dot(boneDirection, boneEnd - vertex);
|
||||||
float radiusWeight = (proj < 0.0f || proj > boneLength) ? 0.5f : 1.0f;
|
float radiusWeight = (proj < 0.0f || proj > boneLength) ? 0.5f : 1.0f;
|
||||||
|
@ -1896,7 +1896,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
jointShapeInfo.numVertices = numVertices;
|
jointShapeInfo.numVertices = numVertices;
|
||||||
if (numVertices > 0) {
|
if (numVertices > 0) {
|
||||||
averageVertex /= (float)jointShapeInfo.numVertices;
|
averageVertex /= (float)jointShapeInfo.numVertices;
|
||||||
float averageRadius = 0.f;
|
float averageRadius = 0.0f;
|
||||||
foreach (const glm::vec3& vertex, extracted.mesh.vertices) {
|
foreach (const glm::vec3& vertex, extracted.mesh.vertices) {
|
||||||
averageRadius += glm::distance(vertex, averageVertex);
|
averageRadius += glm::distance(vertex, averageVertex);
|
||||||
}
|
}
|
||||||
|
@ -1912,7 +1912,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
}
|
}
|
||||||
|
|
||||||
// now that all joints have been scanned, compute a collision shape for each joint
|
// now that all joints have been scanned, compute a collision shape for each joint
|
||||||
glm::vec3 defaultCapsuleAxis(0.f, 1.f, 0.f);
|
glm::vec3 defaultCapsuleAxis(0.0f, 1.0f, 0.0f);
|
||||||
for (int i = 0; i < geometry.joints.size(); ++i) {
|
for (int i = 0; i < geometry.joints.size(); ++i) {
|
||||||
FBXJoint& joint = geometry.joints[i];
|
FBXJoint& joint = geometry.joints[i];
|
||||||
JointShapeInfo& jointShapeInfo = jointShapeInfos[i];
|
JointShapeInfo& jointShapeInfo = jointShapeInfos[i];
|
||||||
|
@ -1945,7 +1945,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
jointShapeInfo.averageVertex /= (float)jointShapeInfo.numVertices;
|
jointShapeInfo.averageVertex /= (float)jointShapeInfo.numVertices;
|
||||||
joint.shapePosition = jointShapeInfo.averageVertex;
|
joint.shapePosition = jointShapeInfo.averageVertex;
|
||||||
} else {
|
} else {
|
||||||
joint.shapePosition = glm::vec3(0.f);
|
joint.shapePosition = glm::vec3(0.0f);
|
||||||
}
|
}
|
||||||
if (jointShapeInfo.numVertexWeights == 0
|
if (jointShapeInfo.numVertexWeights == 0
|
||||||
&& jointShapeInfo.numVertices > 0) {
|
&& jointShapeInfo.numVertices > 0) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ bool CoverageMap::wantDebugging = false;
|
||||||
|
|
||||||
const int MAX_POLYGONS_PER_REGION = 50;
|
const int MAX_POLYGONS_PER_REGION = 50;
|
||||||
|
|
||||||
const BoundingBox CoverageMap::ROOT_BOUNDING_BOX = BoundingBox(glm::vec2(-1.f,-1.f), glm::vec2(2.f,2.f));
|
const BoundingBox CoverageMap::ROOT_BOUNDING_BOX = BoundingBox(glm::vec2(-1.0f,-1.0f), glm::vec2(2.0f,2.0f));
|
||||||
|
|
||||||
// Coverage Map's polygon coordinates are from -1 to 1 in the following mapping to screen space.
|
// Coverage Map's polygon coordinates are from -1 to 1 in the following mapping to screen space.
|
||||||
//
|
//
|
||||||
|
|
|
@ -23,7 +23,7 @@ int CoverageMapV2::_checkMapRootCalls = 0;
|
||||||
int CoverageMapV2::_notAllInView = 0;
|
int CoverageMapV2::_notAllInView = 0;
|
||||||
bool CoverageMapV2::wantDebugging = false;
|
bool CoverageMapV2::wantDebugging = false;
|
||||||
|
|
||||||
const BoundingBox CoverageMapV2::ROOT_BOUNDING_BOX = BoundingBox(glm::vec2(-1.f,-1.f), glm::vec2(2.f,2.f));
|
const BoundingBox CoverageMapV2::ROOT_BOUNDING_BOX = BoundingBox(glm::vec2(-1.0f,-1.0f), glm::vec2(2.0f,2.0f));
|
||||||
|
|
||||||
// Coverage Map's polygon coordinates are from -1 to 1 in the following mapping to screen space.
|
// Coverage Map's polygon coordinates are from -1 to 1 in the following mapping to screen space.
|
||||||
//
|
//
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
|
|
||||||
const float DEFAULT_KEYHOLE_RADIUS = 3.0f;
|
const float DEFAULT_KEYHOLE_RADIUS = 3.0f;
|
||||||
const float DEFAULT_FIELD_OF_VIEW_DEGREES = 45.0f;
|
const float DEFAULT_FIELD_OF_VIEW_DEGREES = 45.0f;
|
||||||
const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.f;
|
const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.0f;
|
||||||
const float DEFAULT_ASPECT_RATIO = 16.f/9.f;
|
const float DEFAULT_ASPECT_RATIO = 16.0f/9.0f;
|
||||||
const float DEFAULT_NEAR_CLIP = 0.08f;
|
const float DEFAULT_NEAR_CLIP = 0.08f;
|
||||||
const float DEFAULT_FAR_CLIP = TREE_SCALE;
|
const float DEFAULT_FAR_CLIP = TREE_SCALE;
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@ CollisionInfo::CollisionInfo() :
|
||||||
_intData(0),
|
_intData(0),
|
||||||
_shapeA(NULL),
|
_shapeA(NULL),
|
||||||
_shapeB(NULL),
|
_shapeB(NULL),
|
||||||
_damping(0.f),
|
_damping(0.0f),
|
||||||
_elasticity(1.f),
|
_elasticity(1.0f),
|
||||||
_contactPoint(0.f),
|
_contactPoint(0.0f),
|
||||||
_penetration(0.f),
|
_penetration(0.0f),
|
||||||
_addedVelocity(0.f) {
|
_addedVelocity(0.0f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 CollisionInfo::getShapePairKey() const {
|
quint64 CollisionInfo::getShapePairKey() const {
|
||||||
|
|
|
@ -73,11 +73,11 @@ void ListShape::clear() {
|
||||||
delete _subShapeEntries[i]._shape;
|
delete _subShapeEntries[i]._shape;
|
||||||
}
|
}
|
||||||
_subShapeEntries.clear();
|
_subShapeEntries.clear();
|
||||||
setBoundingRadius(0.f);
|
setBoundingRadius(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListShape::computeBoundingRadius() {
|
void ListShape::computeBoundingRadius() {
|
||||||
float maxRadius = 0.f;
|
float maxRadius = 0.0f;
|
||||||
for (int i = 0; i < _subShapeEntries.size(); ++i) {
|
for (int i = 0; i < _subShapeEntries.size(); ++i) {
|
||||||
ListShapeEntry& entry = _subShapeEntries[i];
|
ListShapeEntry& entry = _subShapeEntries[i];
|
||||||
float radius = glm::length(entry._localPosition) + entry._shape->getBoundingRadius();
|
float radius = glm::length(entry._localPosition) + entry._shape->getBoundingRadius();
|
||||||
|
|
|
@ -39,8 +39,8 @@ public:
|
||||||
|
|
||||||
static quint32 getNextID() { static quint32 nextID = 0; return ++nextID; }
|
static quint32 getNextID() { static quint32 nextID = 0; return ++nextID; }
|
||||||
|
|
||||||
Shape() : _type(UNKNOWN_SHAPE), _owningEntity(NULL), _boundingRadius(0.f),
|
Shape() : _type(UNKNOWN_SHAPE), _owningEntity(NULL), _boundingRadius(0.0f),
|
||||||
_translation(0.f), _rotation(), _mass(MAX_SHAPE_MASS) {
|
_translation(0.0f), _rotation(), _mass(MAX_SHAPE_MASS) {
|
||||||
_id = getNextID();
|
_id = getNextID();
|
||||||
}
|
}
|
||||||
virtual ~Shape() { }
|
virtual ~Shape() { }
|
||||||
|
@ -87,20 +87,20 @@ public:
|
||||||
protected:
|
protected:
|
||||||
// these ctors are protected (used by derived classes only)
|
// these ctors are protected (used by derived classes only)
|
||||||
Shape(Type type) : _type(type), _owningEntity(NULL),
|
Shape(Type type) : _type(type), _owningEntity(NULL),
|
||||||
_boundingRadius(0.f), _translation(0.f),
|
_boundingRadius(0.0f), _translation(0.0f),
|
||||||
_rotation(), _mass(MAX_SHAPE_MASS) {
|
_rotation(), _mass(MAX_SHAPE_MASS) {
|
||||||
_id = getNextID();
|
_id = getNextID();
|
||||||
}
|
}
|
||||||
|
|
||||||
Shape(Type type, const glm::vec3& position) :
|
Shape(Type type, const glm::vec3& position) :
|
||||||
_type(type), _owningEntity(NULL),
|
_type(type), _owningEntity(NULL),
|
||||||
_boundingRadius(0.f), _translation(position),
|
_boundingRadius(0.0f), _translation(position),
|
||||||
_rotation(), _mass(MAX_SHAPE_MASS) {
|
_rotation(), _mass(MAX_SHAPE_MASS) {
|
||||||
_id = getNextID();
|
_id = getNextID();
|
||||||
}
|
}
|
||||||
|
|
||||||
Shape(Type type, const glm::vec3& position, const glm::quat& rotation) : _type(type), _owningEntity(NULL),
|
Shape(Type type, const glm::vec3& position, const glm::quat& rotation) : _type(type), _owningEntity(NULL),
|
||||||
_boundingRadius(0.f), _translation(position),
|
_boundingRadius(0.0f), _translation(position),
|
||||||
_rotation(rotation), _mass(MAX_SHAPE_MASS) {
|
_rotation(rotation), _mass(MAX_SHAPE_MASS) {
|
||||||
_id = getNextID();
|
_id = getNextID();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1139,7 +1139,7 @@ bool sphereAACube_StarkAngles(const glm::vec3& sphereCenter, float sphereRadius,
|
||||||
glm::vec3 surfaceB = cubeCenter - (0.5f * cubeSide / maxBA) * BA;
|
glm::vec3 surfaceB = cubeCenter - (0.5f * cubeSide / maxBA) * BA;
|
||||||
// collision happens when "vector to surfaceA from surfaceB" dots with BA to produce a positive value
|
// collision happens when "vector to surfaceA from surfaceB" dots with BA to produce a positive value
|
||||||
glm::vec3 surfaceAB = surfaceA - surfaceB;
|
glm::vec3 surfaceAB = surfaceA - surfaceB;
|
||||||
if (glm::dot(surfaceAB, BA) > 0.f) {
|
if (glm::dot(surfaceAB, BA) > 0.0f) {
|
||||||
CollisionInfo* collision = collisions.getNewCollision();
|
CollisionInfo* collision = collisions.getNewCollision();
|
||||||
if (collision) {
|
if (collision) {
|
||||||
// penetration is parallel to box side direction
|
// penetration is parallel to box side direction
|
||||||
|
|
|
@ -72,27 +72,27 @@ int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm
|
||||||
|
|
||||||
|
|
||||||
int packFloatAngleToTwoByte(unsigned char* buffer, float degrees) {
|
int packFloatAngleToTwoByte(unsigned char* buffer, float degrees) {
|
||||||
const float ANGLE_CONVERSION_RATIO = (std::numeric_limits<uint16_t>::max() / 360.f);
|
const float ANGLE_CONVERSION_RATIO = (std::numeric_limits<uint16_t>::max() / 360.0f);
|
||||||
|
|
||||||
uint16_t angleHolder = floorf((degrees + 180.f) * ANGLE_CONVERSION_RATIO);
|
uint16_t angleHolder = floorf((degrees + 180.0f) * ANGLE_CONVERSION_RATIO);
|
||||||
memcpy(buffer, &angleHolder, sizeof(uint16_t));
|
memcpy(buffer, &angleHolder, sizeof(uint16_t));
|
||||||
|
|
||||||
return sizeof(uint16_t);
|
return sizeof(uint16_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer) {
|
int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer) {
|
||||||
*destinationPointer = (*byteAnglePointer / (float) std::numeric_limits<uint16_t>::max()) * 360.f - 180.f;
|
*destinationPointer = (*byteAnglePointer / (float) std::numeric_limits<uint16_t>::max()) * 360.0f - 180.0f;
|
||||||
return sizeof(uint16_t);
|
return sizeof(uint16_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput) {
|
int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput) {
|
||||||
glm::quat quatNormalized = glm::normalize(quatInput);
|
glm::quat quatNormalized = glm::normalize(quatInput);
|
||||||
const float QUAT_PART_CONVERSION_RATIO = (std::numeric_limits<uint16_t>::max() / 2.f);
|
const float QUAT_PART_CONVERSION_RATIO = (std::numeric_limits<uint16_t>::max() / 2.0f);
|
||||||
uint16_t quatParts[4];
|
uint16_t quatParts[4];
|
||||||
quatParts[0] = floorf((quatNormalized.x + 1.f) * QUAT_PART_CONVERSION_RATIO);
|
quatParts[0] = floorf((quatNormalized.x + 1.0f) * QUAT_PART_CONVERSION_RATIO);
|
||||||
quatParts[1] = floorf((quatNormalized.y + 1.f) * QUAT_PART_CONVERSION_RATIO);
|
quatParts[1] = floorf((quatNormalized.y + 1.0f) * QUAT_PART_CONVERSION_RATIO);
|
||||||
quatParts[2] = floorf((quatNormalized.z + 1.f) * QUAT_PART_CONVERSION_RATIO);
|
quatParts[2] = floorf((quatNormalized.z + 1.0f) * QUAT_PART_CONVERSION_RATIO);
|
||||||
quatParts[3] = floorf((quatNormalized.w + 1.f) * QUAT_PART_CONVERSION_RATIO);
|
quatParts[3] = floorf((quatNormalized.w + 1.0f) * QUAT_PART_CONVERSION_RATIO);
|
||||||
|
|
||||||
memcpy(buffer, &quatParts, sizeof(quatParts));
|
memcpy(buffer, &quatParts, sizeof(quatParts));
|
||||||
return sizeof(quatParts);
|
return sizeof(quatParts);
|
||||||
|
@ -102,10 +102,10 @@ int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatO
|
||||||
uint16_t quatParts[4];
|
uint16_t quatParts[4];
|
||||||
memcpy(&quatParts, buffer, sizeof(quatParts));
|
memcpy(&quatParts, buffer, sizeof(quatParts));
|
||||||
|
|
||||||
quatOutput.x = ((quatParts[0] / (float) std::numeric_limits<uint16_t>::max()) * 2.f) - 1.f;
|
quatOutput.x = ((quatParts[0] / (float) std::numeric_limits<uint16_t>::max()) * 2.0f) - 1.0f;
|
||||||
quatOutput.y = ((quatParts[1] / (float) std::numeric_limits<uint16_t>::max()) * 2.f) - 1.f;
|
quatOutput.y = ((quatParts[1] / (float) std::numeric_limits<uint16_t>::max()) * 2.0f) - 1.0f;
|
||||||
quatOutput.z = ((quatParts[2] / (float) std::numeric_limits<uint16_t>::max()) * 2.f) - 1.f;
|
quatOutput.z = ((quatParts[2] / (float) std::numeric_limits<uint16_t>::max()) * 2.0f) - 1.0f;
|
||||||
quatOutput.w = ((quatParts[3] / (float) std::numeric_limits<uint16_t>::max()) * 2.f) - 1.f;
|
quatOutput.w = ((quatParts[3] / (float) std::numeric_limits<uint16_t>::max()) * 2.0f) - 1.0f;
|
||||||
|
|
||||||
return sizeof(quatParts);
|
return sizeof(quatParts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,9 +131,9 @@ bool findSphereDiskPenetration(const glm::vec3& sphereCenter, float sphereRadius
|
||||||
if (glm::length(localCenter - axialOffset) < diskRadius) {
|
if (glm::length(localCenter - axialOffset) < diskRadius) {
|
||||||
// yes, hit the disk
|
// yes, hit the disk
|
||||||
penetration = (std::fabs(axialDistance) - (sphereRadius + 0.5f * diskThickness) ) * diskNormal;
|
penetration = (std::fabs(axialDistance) - (sphereRadius + 0.5f * diskThickness) ) * diskNormal;
|
||||||
if (axialDistance < 0.f) {
|
if (axialDistance < 0.0f) {
|
||||||
// hit the backside of the disk, so negate penetration vector
|
// hit the backside of the disk, so negate penetration vector
|
||||||
penetration *= -1.f;
|
penetration *= -1.0f;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ quint64 usecTimestampNow(bool wantDebug) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float randFloat() {
|
float randFloat() {
|
||||||
return (rand() % 10000)/10000.f;
|
return (rand() % 10000)/10000.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
int randIntInRange (int min, int max) {
|
int randIntInRange (int min, int max) {
|
||||||
|
@ -106,7 +106,7 @@ int randIntInRange (int min, int max) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float randFloatInRange (float min,float max) {
|
float randFloatInRange (float min,float max) {
|
||||||
return min + ((rand() % 10000)/10000.f * (max-min));
|
return min + ((rand() % 10000)/10000.0f * (max-min));
|
||||||
}
|
}
|
||||||
|
|
||||||
float randomSign() {
|
float randomSign() {
|
||||||
|
@ -501,8 +501,8 @@ int removeFromSortedArrays(void* value, void** valueArray, float* keyArray, int*
|
||||||
return -1; // error case
|
return -1; // error case
|
||||||
}
|
}
|
||||||
|
|
||||||
float SMALL_LIMIT = 10.f;
|
float SMALL_LIMIT = 10.0f;
|
||||||
float LARGE_LIMIT = 1000.f;
|
float LARGE_LIMIT = 1000.0f;
|
||||||
|
|
||||||
int packFloatRatioToTwoByte(unsigned char* buffer, float ratio) {
|
int packFloatRatioToTwoByte(unsigned char* buffer, float ratio) {
|
||||||
// if the ratio is less than 10, then encode it as a positive number scaled from 0 to int16::max()
|
// if the ratio is less than 10, then encode it as a positive number scaled from 0 to int16::max()
|
||||||
|
|
|
@ -49,14 +49,14 @@ static const float ONE_HALF = 0.5f;
|
||||||
static const float ONE_THIRD = 0.333333f;
|
static const float ONE_THIRD = 0.333333f;
|
||||||
|
|
||||||
static const float PI = 3.14159265358979f;
|
static const float PI = 3.14159265358979f;
|
||||||
static const float TWO_PI = 2.f * PI;
|
static const float TWO_PI = 2.0f * PI;
|
||||||
static const float PI_OVER_TWO = ONE_HALF * PI;
|
static const float PI_OVER_TWO = ONE_HALF * PI;
|
||||||
static const float RADIANS_PER_DEGREE = PI / 180.0f;
|
static const float RADIANS_PER_DEGREE = PI / 180.0f;
|
||||||
static const float DEGREES_PER_RADIAN = 180.0f / PI;
|
static const float DEGREES_PER_RADIAN = 180.0f / PI;
|
||||||
|
|
||||||
static const float EPSILON = 0.000001f; //smallish positive number - used as margin of error for some computations
|
static const float EPSILON = 0.000001f; //smallish positive number - used as margin of error for some computations
|
||||||
static const float SQUARE_ROOT_OF_2 = (float)sqrt(2.f);
|
static const float SQUARE_ROOT_OF_2 = (float)sqrt(2.0f);
|
||||||
static const float SQUARE_ROOT_OF_3 = (float)sqrt(3.f);
|
static const float SQUARE_ROOT_OF_3 = (float)sqrt(3.0f);
|
||||||
static const float METERS_PER_DECIMETER = 0.1f;
|
static const float METERS_PER_DECIMETER = 0.1f;
|
||||||
static const float METERS_PER_CENTIMETER = 0.01f;
|
static const float METERS_PER_CENTIMETER = 0.01f;
|
||||||
static const float METERS_PER_MILLIMETER = 0.001f;
|
static const float METERS_PER_MILLIMETER = 0.001f;
|
||||||
|
|
|
@ -86,7 +86,7 @@ std::ostream& operator<<(std::ostream& s, const SphereShape& sphere) {
|
||||||
std::ostream& operator<<(std::ostream& s, const CapsuleShape& capsule) {
|
std::ostream& operator<<(std::ostream& s, const CapsuleShape& capsule) {
|
||||||
s << "{type='capsule', center=" << capsule.getPosition()
|
s << "{type='capsule', center=" << capsule.getPosition()
|
||||||
<< ", radius=" << capsule.getRadius()
|
<< ", radius=" << capsule.getRadius()
|
||||||
<< ", length=" << (2.f * capsule.getHalfHeight())
|
<< ", length=" << (2.0f * capsule.getHalfHeight())
|
||||||
<< ", begin=" << capsule.getStartPoint()
|
<< ", begin=" << capsule.getStartPoint()
|
||||||
<< ", end=" << capsule.getEndPoint()
|
<< ", end=" << capsule.getEndPoint()
|
||||||
<< "}";
|
<< "}";
|
||||||
|
|
|
@ -15,28 +15,28 @@
|
||||||
void Transform::evalRotationScale(Quat& rotation, Vec3& scale, const Mat3& rotationScaleMatrix) {
|
void Transform::evalRotationScale(Quat& rotation, Vec3& scale, const Mat3& rotationScaleMatrix) {
|
||||||
const float ACCURACY_THREASHOLD = 0.00001f;
|
const float ACCURACY_THREASHOLD = 0.00001f;
|
||||||
|
|
||||||
// Following technique taken from:
|
// Following technique taken from:
|
||||||
// http://callumhay.blogspot.com/2010/10/decomposing-affine-transforms.html
|
// http://callumhay.blogspot.com/2010/10/decomposing-affine-transforms.html
|
||||||
// Extract the rotation component - this is done using polar decompostion, where
|
// Extract the rotation component - this is done using polar decompostion, where
|
||||||
// we successively average the matrix with its inverse transpose until there is
|
// we successively average the matrix with its inverse transpose until there is
|
||||||
// no/a very small difference between successive averages
|
// no/a very small difference between successive averages
|
||||||
float norm;
|
float norm;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
Mat3 rotationMat = rotationScaleMatrix;
|
Mat3 rotationMat = rotationScaleMatrix;
|
||||||
do {
|
do {
|
||||||
Mat3 currInvTranspose = glm::inverse(glm::transpose(rotationMat));
|
Mat3 currInvTranspose = glm::inverse(glm::transpose(rotationMat));
|
||||||
|
|
||||||
Mat3 nextRotation = 0.5f * (rotationMat + currInvTranspose);
|
Mat3 nextRotation = 0.5f * (rotationMat + currInvTranspose);
|
||||||
|
|
||||||
norm = 0.0;
|
norm = 0.0;
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
float n = static_cast<float>(
|
float n = static_cast<float>(
|
||||||
fabs(rotationMat[0][i] - nextRotation[0][i]) +
|
fabs(rotationMat[0][i] - nextRotation[0][i]) +
|
||||||
fabs(rotationMat[1][i] - nextRotation[1][i]) +
|
fabs(rotationMat[1][i] - nextRotation[1][i]) +
|
||||||
fabs(rotationMat[2][i] - nextRotation[2][i]));
|
fabs(rotationMat[2][i] - nextRotation[2][i]));
|
||||||
norm = (norm > n ? norm : n);
|
norm = (norm > n ? norm : n);
|
||||||
}
|
}
|
||||||
rotationMat = nextRotation;
|
rotationMat = nextRotation;
|
||||||
} while (count < 100 && norm > ACCURACY_THREASHOLD);
|
} while (count < 100 && norm > ACCURACY_THREASHOLD);
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,14 +49,14 @@ void Transform::evalRotationScale(Quat& rotation, Vec3& scale, const Mat3& rotat
|
||||||
Mat3 matRot(
|
Mat3 matRot(
|
||||||
rotationScaleMatrix[0] / scale.x,
|
rotationScaleMatrix[0] / scale.x,
|
||||||
rotationScaleMatrix[1] / scale.y,
|
rotationScaleMatrix[1] / scale.y,
|
||||||
rotationScaleMatrix[2] / scale.z);
|
rotationScaleMatrix[2] / scale.z);
|
||||||
|
|
||||||
// Beware!!! needs to detect for the case there is a negative scale
|
// Beware!!! needs to detect for the case there is a negative scale
|
||||||
// Based on the determinant sign we just can flip the scale sign of one component: we choose X axis
|
// Based on the determinant sign we just can flip the scale sign of one component: we choose X axis
|
||||||
float determinant = glm::determinant(matRot);
|
float determinant = glm::determinant(matRot);
|
||||||
if (determinant < 0.f) {
|
if (determinant < 0.0f) {
|
||||||
scale.x = -scale.x;
|
scale.x = -scale.x;
|
||||||
matRot[0] *= -1.f;
|
matRot[0] *= -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Beware: even though the matRot is supposed to be normalized at that point,
|
// Beware: even though the matRot is supposed to be normalized at that point,
|
||||||
|
|
|
@ -292,13 +292,13 @@ inline Transform::Mat4& Transform::getMatrix(Transform::Mat4& result) const {
|
||||||
rot[2] *= _scale.z;
|
rot[2] *= _scale.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
result[0] = Vec4(rot[0], 0.f);
|
result[0] = Vec4(rot[0], 0.0f);
|
||||||
result[1] = Vec4(rot[1], 0.f);
|
result[1] = Vec4(rot[1], 0.0f);
|
||||||
result[2] = Vec4(rot[2], 0.f);
|
result[2] = Vec4(rot[2], 0.0f);
|
||||||
} else {
|
} else {
|
||||||
result[0] = Vec4(_scale.x, 0.f, 0.f, 0.f);
|
result[0] = Vec4(_scale.x, 0.0f, 0.0f, 0.0f);
|
||||||
result[1] = Vec4(0.f, _scale.y, 0.f, 0.f);
|
result[1] = Vec4(0.0f, _scale.y, 0.0f, 0.0f);
|
||||||
result[2] = Vec4(0.f, 0.f, _scale.z, 0.f);
|
result[2] = Vec4(0.0f, 0.0f, _scale.z, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
result[3] = Vec4(_translation, 1.0f);
|
result[3] = Vec4(_translation, 1.0f);
|
||||||
|
@ -313,7 +313,7 @@ inline Transform::Mat4& Transform::getInverseMatrix(Transform::Mat4& result) con
|
||||||
|
|
||||||
inline void Transform::evalFromRawMatrix(const Mat4& matrix) {
|
inline void Transform::evalFromRawMatrix(const Mat4& matrix) {
|
||||||
// for now works only in the case of TRS transformation
|
// for now works only in the case of TRS transformation
|
||||||
if ((matrix[0][3] == 0) && (matrix[1][3] == 0) && (matrix[2][3] == 0) && (matrix[3][3] == 1.f)) {
|
if ((matrix[0][3] == 0) && (matrix[1][3] == 0) && (matrix[2][3] == 0) && (matrix[3][3] == 1.0f)) {
|
||||||
setTranslation(Vec3(matrix[3]));
|
setTranslation(Vec3(matrix[3]));
|
||||||
evalFromRawMatrix(Mat3(matrix));
|
evalFromRawMatrix(Mat3(matrix));
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
static glm::vec3 xAxis(1.f, 0.f, 0.f);
|
static glm::vec3 xAxis(1.0f, 0.0f, 0.0f);
|
||||||
static glm::vec3 xZxis(0.f, 1.f, 0.f);
|
static glm::vec3 xZxis(0.0f, 1.0f, 0.0f);
|
||||||
static glm::vec3 xYxis(0.f, 0.f, 1.f);
|
static glm::vec3 xYxis(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
void CollisionInfoTests::rotateThenTranslate() {
|
void CollisionInfoTests::rotateThenTranslate() {
|
||||||
CollisionInfo collision;
|
CollisionInfo collision;
|
||||||
|
@ -34,7 +34,7 @@ void CollisionInfoTests::rotateThenTranslate() {
|
||||||
collision._addedVelocity = xAxis + yAxis + zAxis;
|
collision._addedVelocity = xAxis + yAxis + zAxis;
|
||||||
|
|
||||||
glm::quat rotation = glm::angleAxis(PI_OVER_TWO, zAxis);
|
glm::quat rotation = glm::angleAxis(PI_OVER_TWO, zAxis);
|
||||||
float distance = 3.f;
|
float distance = 3.0f;
|
||||||
glm::vec3 translation = distance * yAxis;
|
glm::vec3 translation = distance * yAxis;
|
||||||
|
|
||||||
collision.rotateThenTranslate(rotation, translation);
|
collision.rotateThenTranslate(rotation, translation);
|
||||||
|
@ -73,7 +73,7 @@ void CollisionInfoTests::translateThenRotate() {
|
||||||
collision._addedVelocity = xAxis + yAxis + zAxis;
|
collision._addedVelocity = xAxis + yAxis + zAxis;
|
||||||
|
|
||||||
glm::quat rotation = glm::angleAxis( -PI_OVER_TWO, zAxis);
|
glm::quat rotation = glm::angleAxis( -PI_OVER_TWO, zAxis);
|
||||||
float distance = 3.f;
|
float distance = 3.0f;
|
||||||
glm::vec3 translation = distance * yAxis;
|
glm::vec3 translation = distance * yAxis;
|
||||||
|
|
||||||
collision.translateThenRotate(translation, rotation);
|
collision.translateThenRotate(translation, rotation);
|
||||||
|
@ -86,7 +86,7 @@ void CollisionInfoTests::translateThenRotate() {
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 expectedContactPoint = (1.f + distance) * xAxis;
|
glm::vec3 expectedContactPoint = (1.0f + distance) * xAxis;
|
||||||
error = glm::distance(collision._contactPoint, expectedContactPoint);
|
error = glm::distance(collision._contactPoint, expectedContactPoint);
|
||||||
if (error > EPSILON) {
|
if (error > EPSILON) {
|
||||||
std::cout << __FILE__ << ":" << __LINE__
|
std::cout << __FILE__ << ":" << __LINE__
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
#include <CollisionInfo.h>
|
#include <CollisionInfo.h>
|
||||||
|
|
||||||
const glm::vec3 xAxis(1.f, 0.f, 0.f);
|
const glm::vec3 xAxis(1.0f, 0.0f, 0.0f);
|
||||||
const glm::vec3 yAxis(0.f, 1.f, 0.f);
|
const glm::vec3 yAxis(0.0f, 1.0f, 0.0f);
|
||||||
const glm::vec3 zAxis(0.f, 0.f, 1.f);
|
const glm::vec3 zAxis(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& s, const CollisionInfo& c);
|
std::ostream& operator<<(std::ostream& s, const CollisionInfo& c);
|
||||||
|
|
||||||
|
|
|
@ -2342,7 +2342,7 @@ void ShapeColliderTests::rayMissesAACube() {
|
||||||
//glm::vec3 cubeCenter(1.23f, 4.56f, 7.89f);
|
//glm::vec3 cubeCenter(1.23f, 4.56f, 7.89f);
|
||||||
//float cubeSide = 2.127f;
|
//float cubeSide = 2.127f;
|
||||||
glm::vec3 cubeCenter(0.0f);
|
glm::vec3 cubeCenter(0.0f);
|
||||||
float cubeSide = 2.f;
|
float cubeSide = 2.0f;
|
||||||
AACubeShape cube(cubeSide, cubeCenter);
|
AACubeShape cube(cubeSide, cubeCenter);
|
||||||
|
|
||||||
float rayOffset = 3.796f;
|
float rayOffset = 3.796f;
|
||||||
|
|
|
@ -37,7 +37,7 @@ void VerletShapeTests::setSpherePosition() {
|
||||||
VerletPoint point;
|
VerletPoint point;
|
||||||
VerletSphereShape sphere(radius, &point);
|
VerletSphereShape sphere(radius, &point);
|
||||||
|
|
||||||
point._position = glm::vec3(0.f);
|
point._position = glm::vec3(0.0f);
|
||||||
float d = glm::distance(glm::vec3(0.0f), sphere.getTranslation());
|
float d = glm::distance(glm::vec3(0.0f), sphere.getTranslation());
|
||||||
if (d != 0.0f) {
|
if (d != 0.0f) {
|
||||||
std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere should be at origin" << std::endl;
|
std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere should be at origin" << std::endl;
|
||||||
|
|
|
@ -47,7 +47,7 @@ void AngularConstraintTests::testHingeConstraint() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ // test just inside min edge of constraint
|
{ // test just inside min edge of constraint
|
||||||
float angle = minAngle + 10.f * EPSILON;
|
float angle = minAngle + 10.0f * EPSILON;
|
||||||
glm::quat rotation = glm::angleAxis(angle, yAxis);
|
glm::quat rotation = glm::angleAxis(angle, yAxis);
|
||||||
|
|
||||||
glm::quat newRotation = rotation;
|
glm::quat newRotation = rotation;
|
||||||
|
@ -62,7 +62,7 @@ void AngularConstraintTests::testHingeConstraint() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ // test just inside max edge of constraint
|
{ // test just inside max edge of constraint
|
||||||
float angle = maxAngle - 10.f * EPSILON;
|
float angle = maxAngle - 10.0f * EPSILON;
|
||||||
glm::quat rotation = glm::angleAxis(angle, yAxis);
|
glm::quat rotation = glm::angleAxis(angle, yAxis);
|
||||||
|
|
||||||
glm::quat newRotation = rotation;
|
glm::quat newRotation = rotation;
|
||||||
|
|
|
@ -34,7 +34,7 @@ void addCornersAndAxisLines(VoxelTree* tree) {
|
||||||
|
|
||||||
void addSurfaceScene(VoxelTree * tree) {
|
void addSurfaceScene(VoxelTree * tree) {
|
||||||
qDebug("adding surface scene...");
|
qDebug("adding surface scene...");
|
||||||
float voxelSize = 1.f / (8 * TREE_SCALE);
|
float voxelSize = 1.0f / (8 * TREE_SCALE);
|
||||||
|
|
||||||
// color 1= blue, color 2=green
|
// color 1= blue, color 2=green
|
||||||
unsigned char r1, g1, b1, r2, g2, b2, red, green, blue;
|
unsigned char r1, g1, b1, r2, g2, b2, red, green, blue;
|
||||||
|
@ -45,7 +45,7 @@ void addSurfaceScene(VoxelTree * tree) {
|
||||||
for (float z = 0.0; z < 1.0; z += voxelSize) {
|
for (float z = 0.0; z < 1.0; z += voxelSize) {
|
||||||
|
|
||||||
glm::vec2 position = glm::vec2(x, z);
|
glm::vec2 position = glm::vec2(x, z);
|
||||||
float perlin = glm::perlin(position) + .25f * glm::perlin(position * 4.f) + .125f * glm::perlin(position * 16.f);
|
float perlin = glm::perlin(position) + .25f * glm::perlin(position * 4.0f) + .125f * glm::perlin(position * 16.0f);
|
||||||
float gradient = (1.0f + perlin)/ 2.0f;
|
float gradient = (1.0f + perlin)/ 2.0f;
|
||||||
red = (unsigned char)std::min(255, std::max(0, (int)(r1 + ((r2 - r1) * gradient))));
|
red = (unsigned char)std::min(255, std::max(0, (int)(r1 + ((r2 - r1) * gradient))));
|
||||||
green = (unsigned char)std::min(255, std::max(0, (int)(g1 + ((g2 - g1) * gradient))));
|
green = (unsigned char)std::min(255, std::max(0, (int)(g1 + ((g2 - g1) * gradient))));
|
||||||
|
|
Loading…
Reference in a new issue