mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:57:59 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into yellow
This commit is contained in:
commit
a002560003
7 changed files with 50 additions and 26 deletions
|
@ -54,7 +54,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const glm::vec3 DEFAULT_UP_DIRECTION(0.0f, 1.0f, 0.0f);
|
const glm::vec3 DEFAULT_UP_DIRECTION(0.0f, 1.0f, 0.0f);
|
||||||
const float YAW_SPEED = 500.0f; // degrees/sec
|
const float YAW_SPEED = 150.0f; // degrees/sec
|
||||||
const float PITCH_SPEED = 100.0f; // degrees/sec
|
const float PITCH_SPEED = 100.0f; // degrees/sec
|
||||||
const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.0f;
|
const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.0f;
|
||||||
|
|
||||||
|
@ -1290,22 +1290,34 @@ bool MyAvatar::shouldRenderHead(const RenderArgs* renderArgs) const {
|
||||||
|
|
||||||
void MyAvatar::updateOrientation(float deltaTime) {
|
void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
// Smoothly rotate body with arrow keys
|
// Smoothly rotate body with arrow keys
|
||||||
_bodyYawDelta -= _driveKeys[ROT_RIGHT] * YAW_SPEED * deltaTime;
|
float driveLeft = _driveKeys[ROT_LEFT] - _driveKeys[ROT_RIGHT];
|
||||||
_bodyYawDelta += _driveKeys[ROT_LEFT] * YAW_SPEED * deltaTime;
|
float targetSpeed = (_driveKeys[ROT_LEFT] - _driveKeys[ROT_RIGHT]) * YAW_SPEED;
|
||||||
getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime);
|
if (targetSpeed != 0.0f) {
|
||||||
|
const float ROTATION_RAMP_TIMESCALE = 0.1f;
|
||||||
// update body orientation by movement inputs
|
float blend = deltaTime / ROTATION_RAMP_TIMESCALE;
|
||||||
setOrientation(getOrientation() *
|
if (blend > 1.0f) {
|
||||||
glm::quat(glm::radians(glm::vec3(0.0f, _bodyYawDelta, 0.0f) * deltaTime)));
|
blend = 1.0f;
|
||||||
|
}
|
||||||
// decay body rotation momentum
|
_bodyYawDelta = (1.0f - blend) * _bodyYawDelta + blend * targetSpeed;
|
||||||
const float BODY_SPIN_FRICTION = 7.5f;
|
} else if (_bodyYawDelta != 0.0f) {
|
||||||
float bodySpinMomentum = 1.0f - BODY_SPIN_FRICTION * deltaTime;
|
// attenuate body rotation speed
|
||||||
if (bodySpinMomentum < 0.0f) { bodySpinMomentum = 0.0f; }
|
const float ROTATION_DECAY_TIMESCALE = 0.05f;
|
||||||
_bodyYawDelta *= bodySpinMomentum;
|
float attenuation = 1.0f - deltaTime / ROTATION_DECAY_TIMESCALE;
|
||||||
|
if (attenuation < 0.0f) {
|
||||||
|
attenuation = 0.0f;
|
||||||
|
}
|
||||||
|
_bodyYawDelta *= attenuation;
|
||||||
|
|
||||||
float MINIMUM_ROTATION_RATE = 2.0f;
|
float MINIMUM_ROTATION_RATE = 2.0f;
|
||||||
if (fabs(_bodyYawDelta) < MINIMUM_ROTATION_RATE) { _bodyYawDelta = 0.0f; }
|
if (fabsf(_bodyYawDelta) < MINIMUM_ROTATION_RATE) {
|
||||||
|
_bodyYawDelta = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime);
|
||||||
|
// update body orientation by movement inputs
|
||||||
|
setOrientation(getOrientation() *
|
||||||
|
glm::quat(glm::radians(glm::vec3(0.0f, _bodyYawDelta * deltaTime, 0.0f))));
|
||||||
|
|
||||||
if (qApp->isHMDMode()) {
|
if (qApp->isHMDMode()) {
|
||||||
// these angles will be in radians
|
// these angles will be in radians
|
||||||
|
|
|
@ -21,6 +21,9 @@ float evalOpaqueFinalAlpha(float alpha, float mapAlpha) {
|
||||||
return mix(alpha * glowIntensity, 1.0 - alpha * glowIntensity, step(mapAlpha, alphaThreshold));
|
return mix(alpha * glowIntensity, 1.0 - alpha * glowIntensity, step(mapAlpha, alphaThreshold));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const vec3 DEFAULT_SPECULAR = vec3(0.1);
|
||||||
|
const float DEFAULT_SHININESS = 10;
|
||||||
|
|
||||||
void packDeferredFragment(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess) {
|
void packDeferredFragment(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess) {
|
||||||
if (alpha != glowIntensity) {
|
if (alpha != glowIntensity) {
|
||||||
discard;
|
discard;
|
||||||
|
|
|
@ -143,6 +143,10 @@ void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch, bool textured,
|
||||||
SimpleProgramKey config{textured, culled, emmisive, depthBias};
|
SimpleProgramKey config{textured, culled, emmisive, depthBias};
|
||||||
batch.setPipeline(getPipeline(config));
|
batch.setPipeline(getPipeline(config));
|
||||||
|
|
||||||
|
gpu::ShaderPointer program = (config.isEmissive()) ? _emissiveShader : _simpleShader;
|
||||||
|
int glowIntensity = program->getUniforms().findLocation("glowIntensity");
|
||||||
|
batch._glUniform1f(glowIntensity, 1.0f);
|
||||||
|
|
||||||
if (!config.isTextured()) {
|
if (!config.isTextured()) {
|
||||||
// If it is not textured, bind white texture and keep using textured pipeline
|
// If it is not textured, bind white texture and keep using textured pipeline
|
||||||
batch.setResourceTexture(0, DependencyManager::get<TextureCache>()->getWhiteTexture());
|
batch.setResourceTexture(0, DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||||
|
|
|
@ -22,6 +22,5 @@ void main(void) {
|
||||||
normalize(interpolatedNormal.xyz),
|
normalize(interpolatedNormal.xyz),
|
||||||
glowIntensity,
|
glowIntensity,
|
||||||
gl_Color.rgb,
|
gl_Color.rgb,
|
||||||
gl_FrontMaterial.specular.rgb,
|
DEFAULT_SPECULAR, DEFAULT_SHININESS);
|
||||||
gl_FrontMaterial.shininess);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,5 @@ void main(void) {
|
||||||
normalize(interpolatedNormal.xyz),
|
normalize(interpolatedNormal.xyz),
|
||||||
glowIntensity * texel.a,
|
glowIntensity * texel.a,
|
||||||
gl_Color.rgb * texel.rgb,
|
gl_Color.rgb * texel.rgb,
|
||||||
gl_FrontMaterial.specular.rgb,
|
DEFAULT_SPECULAR, DEFAULT_SHININESS);
|
||||||
gl_FrontMaterial.shininess);
|
|
||||||
}
|
}
|
|
@ -27,7 +27,6 @@ void main(void) {
|
||||||
normalize(interpolatedNormal.xyz),
|
normalize(interpolatedNormal.xyz),
|
||||||
glowIntensity * texel.a,
|
glowIntensity * texel.a,
|
||||||
gl_Color.rgb,
|
gl_Color.rgb,
|
||||||
gl_FrontMaterial.specular.rgb,
|
DEFAULT_SPECULAR, DEFAULT_SHININESS,
|
||||||
gl_FrontMaterial.shininess,
|
|
||||||
texel.rgb);
|
texel.rgb);
|
||||||
}
|
}
|
|
@ -46,13 +46,21 @@
|
||||||
|
|
||||||
|
|
||||||
static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){
|
static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){
|
||||||
qCDebug(scriptengine) << "script:print()<<" << context->argument(0).toString();
|
QString message = "";
|
||||||
QString message = context->argument(0).toString()
|
for (int i = 0; i < context->argumentCount(); i++) {
|
||||||
.replace("\\", "\\\\")
|
if (i > 0) {
|
||||||
|
message += " ";
|
||||||
|
}
|
||||||
|
message += context->argument(i).toString();
|
||||||
|
}
|
||||||
|
qCDebug(scriptengine) << "script:print()<<" << message;
|
||||||
|
|
||||||
|
message = message.replace("\\", "\\\\")
|
||||||
.replace("\n", "\\n")
|
.replace("\n", "\\n")
|
||||||
.replace("\r", "\\r")
|
.replace("\r", "\\r")
|
||||||
.replace("'", "\\'");
|
.replace("'", "\\'");
|
||||||
engine->evaluate("Script.print('" + message + "')");
|
engine->evaluate("Script.print('" + message + "')");
|
||||||
|
|
||||||
return QScriptValue();
|
return QScriptValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue