mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:41:02 +02:00
Merge pull request #468 from ey6es/master
Fixes for reorientation: load/save pitch/roll, don't update orientation for remote avatars.
This commit is contained in:
commit
27f4674c10
2 changed files with 93 additions and 83 deletions
|
@ -55,6 +55,14 @@ int main(int argc, const char* argv[]) {
|
|||
AgentList* agentList = AgentList::createInstance(AGENT_TYPE_AVATAR_MIXER, AVATAR_LISTEN_PORT);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
// Handle Local Domain testing with the --local command line
|
||||
const char* local = "--local";
|
||||
if (cmdOptionExists(argc, argv, local)) {
|
||||
printf("Local Domain MODE!\n");
|
||||
int ip = getLocalAddress();
|
||||
sprintf(DOMAIN_IP,"%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF));
|
||||
}
|
||||
|
||||
agentList->linkedDataCreateCallback = attachAvatarDataToAgent;
|
||||
|
||||
agentList->startDomainServerCheckInThread();
|
||||
|
|
|
@ -304,13 +304,10 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
up;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update body yaw by body yaw delta
|
||||
if (!_owningAgent) {
|
||||
orientation = orientation * glm::quat(glm::radians(
|
||||
glm::vec3(_bodyPitchDelta, _bodyYawDelta, _bodyRollDelta) * deltaTime));
|
||||
}
|
||||
|
||||
// decay body rotation momentum
|
||||
float bodySpinMomentum = 1.0 - BODY_SPIN_FRICTION * deltaTime;
|
||||
|
@ -355,7 +352,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
}
|
||||
|
||||
// If another avatar is near, dampen velocity as a function of closeness
|
||||
if (!_owningAgent && (_distanceToNearestAvatar < PERIPERSONAL_RADIUS)) {
|
||||
if (_distanceToNearestAvatar < PERIPERSONAL_RADIUS) {
|
||||
float closeness = 1.0f - (_distanceToNearestAvatar / PERIPERSONAL_RADIUS);
|
||||
float drag = 1.0f - closeness * AVATAR_BRAKING_STRENGTH * deltaTime;
|
||||
if ( drag > 0.0f ) {
|
||||
|
@ -393,6 +390,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
// correct the oculus yaw offset
|
||||
OculusManager::updateYawOffset();
|
||||
}
|
||||
}
|
||||
|
||||
//apply the head lean values to the springy position...
|
||||
if (USING_HEAD_LEAN) {
|
||||
|
@ -1250,7 +1248,7 @@ void Avatar::writeAvatarDataToFile() {
|
|||
FILE* avatarFile = fopen(AVATAR_DATA_FILENAME, "w");
|
||||
|
||||
if (avatarFile) {
|
||||
fprintf(avatarFile, "%f,%f,%f %f", _position.x, _position.y, _position.z, _bodyYaw);
|
||||
fprintf(avatarFile, "%f,%f,%f %f,%f,%f", _position.x, _position.y, _position.z, _bodyYaw, _bodyPitch, _bodyRoll);
|
||||
fclose(avatarFile);
|
||||
}
|
||||
}
|
||||
|
@ -1260,13 +1258,17 @@ void Avatar::readAvatarDataFromFile() {
|
|||
|
||||
if (avatarFile) {
|
||||
glm::vec3 readPosition;
|
||||
float readYaw;
|
||||
fscanf(avatarFile, "%f,%f,%f %f", &readPosition.x, &readPosition.y, &readPosition.z, &readYaw);
|
||||
float readYaw, readPitch, readRoll;
|
||||
fscanf(avatarFile, "%f,%f,%f %f,%f,%f", &readPosition.x, &readPosition.y, &readPosition.z,
|
||||
&readYaw, &readPitch, &readRoll);
|
||||
|
||||
// make sure these values are sane
|
||||
if (!isnan(readPosition.x) && !isnan(readPosition.y) && !isnan(readPosition.z) && !isnan(readYaw)) {
|
||||
if (!isnan(readPosition.x) && !isnan(readPosition.y) && !isnan(readPosition.z) &&
|
||||
!isnan(readYaw) && !isnan(readPitch) && !isnan(readRoll)) {
|
||||
_position = readPosition;
|
||||
_bodyYaw = readYaw;
|
||||
_bodyPitch = readPitch;
|
||||
_bodyRoll = readRoll;
|
||||
}
|
||||
fclose(avatarFile);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue