mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 07:37:16 +02:00
Use the number of local lights to update new avatars instead of checking hashes.
This commit is contained in:
parent
4cea4d2838
commit
90d56bc108
5 changed files with 22 additions and 21 deletions
|
@ -17,7 +17,6 @@ var currentSelection = 0;
|
|||
var currentNumLights = 1;
|
||||
var maxNumLights = 2;
|
||||
var currentNumAvatars = 0;
|
||||
var avatarHashIDs = [];
|
||||
|
||||
function keyPressEvent(event) {
|
||||
|
||||
|
@ -142,23 +141,14 @@ function updateLocalLights()
|
|||
// new avatars, so add lights
|
||||
var numAvatars = AvatarManager.getNumAvatars();
|
||||
if (numAvatars != currentNumAvatars) {
|
||||
|
||||
|
||||
for (var i = 0; i < numAvatars; i++) {
|
||||
var id = AvatarManager.getAvatarHashKey(i);
|
||||
|
||||
// check if avatar has already been registered
|
||||
var hasRegistered = false;
|
||||
for (var j = 0; j < numAvatars; j++) {
|
||||
if (avatarHashIDs[j] == id) {
|
||||
hasRegistered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var numLights = AvatarManager.getNumLightsInAvatar(i);
|
||||
|
||||
// add new id and set light params
|
||||
if (!hasRegistered) {
|
||||
|
||||
avatarHashIDs.push(id);
|
||||
// check if new avatar has lights
|
||||
if (numLights <= 0) {
|
||||
AvatarManager.addAvatarLocalLight(i);
|
||||
|
||||
// set color and direction for new avatar
|
||||
|
|
|
@ -928,27 +928,25 @@ void Avatar::setShowDisplayName(bool showDisplayName) {
|
|||
|
||||
void Avatar::setLocalLightDirection(const glm::vec3& direction, int lightIndex) {
|
||||
_localLightDirections[lightIndex] = direction;
|
||||
qDebug( "set light %d direction ( %f, %f, %f )\n", lightIndex, direction.x, direction.y, direction.z );
|
||||
}
|
||||
|
||||
void Avatar::setLocalLightColor(const glm::vec3& color, int lightIndex) {
|
||||
_localLightColors[lightIndex] = color;
|
||||
qDebug( "set light %d color ( %f, %f, %f )\n", lightIndex, color.x, color.y, color.z );
|
||||
}
|
||||
|
||||
void Avatar::addLocalLight() {
|
||||
if (_numLocalLights + 1 <= MAX_LOCAL_LIGHTS) {
|
||||
++_numLocalLights;
|
||||
}
|
||||
|
||||
qDebug("ADD LOCAL LIGHT (numLocalLights = %d)\n", _numLocalLights);
|
||||
}
|
||||
|
||||
void Avatar::removeLocalLight() {
|
||||
if (_numLocalLights - 1 >= 0) {
|
||||
--_numLocalLights;
|
||||
}
|
||||
|
||||
qDebug("REMOVE LOCAL LIGHT (numLocalLights = %d)\n", _numLocalLights);
|
||||
}
|
||||
|
||||
int Avatar::getNumLocalLights() {
|
||||
return _numLocalLights;
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,8 @@ public slots:
|
|||
void setLocalLightDirection(const glm::vec3& direction, int lightIndex);
|
||||
void setLocalLightColor(const glm::vec3& color, int lightIndex);
|
||||
void addLocalLight();
|
||||
void removeLocalLight();
|
||||
void removeLocalLight();
|
||||
int getNumLocalLights();
|
||||
|
||||
signals:
|
||||
void collisionWithAvatar(const QUuid& myUUID, const QUuid& theirUUID, const CollisionInfo& collision);
|
||||
|
|
|
@ -200,6 +200,17 @@ void AvatarManager::setAvatarLightColor(const glm::vec3& color, int lightIndex,
|
|||
}
|
||||
}
|
||||
|
||||
int AvatarManager::getNumLightsInAvatar(int avatarIndex) {
|
||||
int numLights = 0;
|
||||
|
||||
Avatar* avatar = getAvatarFromIndex(avatarIndex);
|
||||
if (avatar) {
|
||||
numLights = avatar->getNumLocalLights();
|
||||
}
|
||||
|
||||
return numLights;
|
||||
}
|
||||
|
||||
int AvatarManager::getNumAvatars() {
|
||||
return _avatarHash.count();
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ public slots:
|
|||
void setAvatarLightDirection(const glm::vec3& direction, int lightIndex, int avatarIndex);
|
||||
void removeAvatarLocalLight(int avatarIndex);
|
||||
void addAvatarLocalLight(int avatarIndex);
|
||||
int getNumLightsInAvatar(int avatarIndex);
|
||||
int getNumAvatars();
|
||||
QString getAvatarHashKey(int index);
|
||||
|
||||
|
|
Loading…
Reference in a new issue