mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 21:29:33 +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 currentNumLights = 1;
|
||||||
var maxNumLights = 2;
|
var maxNumLights = 2;
|
||||||
var currentNumAvatars = 0;
|
var currentNumAvatars = 0;
|
||||||
var avatarHashIDs = [];
|
|
||||||
|
|
||||||
function keyPressEvent(event) {
|
function keyPressEvent(event) {
|
||||||
|
|
||||||
|
@ -142,23 +141,14 @@ function updateLocalLights()
|
||||||
// new avatars, so add lights
|
// new avatars, so add lights
|
||||||
var numAvatars = AvatarManager.getNumAvatars();
|
var numAvatars = AvatarManager.getNumAvatars();
|
||||||
if (numAvatars != currentNumAvatars) {
|
if (numAvatars != currentNumAvatars) {
|
||||||
|
|
||||||
for (var i = 0; i < numAvatars; i++) {
|
for (var i = 0; i < numAvatars; i++) {
|
||||||
var id = AvatarManager.getAvatarHashKey(i);
|
var id = AvatarManager.getAvatarHashKey(i);
|
||||||
|
|
||||||
// check if avatar has already been registered
|
var numLights = AvatarManager.getNumLightsInAvatar(i);
|
||||||
var hasRegistered = false;
|
|
||||||
for (var j = 0; j < numAvatars; j++) {
|
|
||||||
if (avatarHashIDs[j] == id) {
|
|
||||||
hasRegistered = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add new id and set light params
|
// check if new avatar has lights
|
||||||
if (!hasRegistered) {
|
if (numLights <= 0) {
|
||||||
|
|
||||||
avatarHashIDs.push(id);
|
|
||||||
AvatarManager.addAvatarLocalLight(i);
|
AvatarManager.addAvatarLocalLight(i);
|
||||||
|
|
||||||
// set color and direction for new avatar
|
// 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) {
|
void Avatar::setLocalLightDirection(const glm::vec3& direction, int lightIndex) {
|
||||||
_localLightDirections[lightIndex] = direction;
|
_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) {
|
void Avatar::setLocalLightColor(const glm::vec3& color, int lightIndex) {
|
||||||
_localLightColors[lightIndex] = color;
|
_localLightColors[lightIndex] = color;
|
||||||
qDebug( "set light %d color ( %f, %f, %f )\n", lightIndex, color.x, color.y, color.z );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::addLocalLight() {
|
void Avatar::addLocalLight() {
|
||||||
if (_numLocalLights + 1 <= MAX_LOCAL_LIGHTS) {
|
if (_numLocalLights + 1 <= MAX_LOCAL_LIGHTS) {
|
||||||
++_numLocalLights;
|
++_numLocalLights;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("ADD LOCAL LIGHT (numLocalLights = %d)\n", _numLocalLights);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::removeLocalLight() {
|
void Avatar::removeLocalLight() {
|
||||||
if (_numLocalLights - 1 >= 0) {
|
if (_numLocalLights - 1 >= 0) {
|
||||||
--_numLocalLights;
|
--_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 setLocalLightDirection(const glm::vec3& direction, int lightIndex);
|
||||||
void setLocalLightColor(const glm::vec3& color, int lightIndex);
|
void setLocalLightColor(const glm::vec3& color, int lightIndex);
|
||||||
void addLocalLight();
|
void addLocalLight();
|
||||||
void removeLocalLight();
|
void removeLocalLight();
|
||||||
|
int getNumLocalLights();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void collisionWithAvatar(const QUuid& myUUID, const QUuid& theirUUID, const CollisionInfo& collision);
|
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() {
|
int AvatarManager::getNumAvatars() {
|
||||||
return _avatarHash.count();
|
return _avatarHash.count();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ public slots:
|
||||||
void setAvatarLightDirection(const glm::vec3& direction, int lightIndex, int avatarIndex);
|
void setAvatarLightDirection(const glm::vec3& direction, int lightIndex, int avatarIndex);
|
||||||
void removeAvatarLocalLight(int avatarIndex);
|
void removeAvatarLocalLight(int avatarIndex);
|
||||||
void addAvatarLocalLight(int avatarIndex);
|
void addAvatarLocalLight(int avatarIndex);
|
||||||
|
int getNumLightsInAvatar(int avatarIndex);
|
||||||
int getNumAvatars();
|
int getNumAvatars();
|
||||||
QString getAvatarHashKey(int index);
|
QString getAvatarHashKey(int index);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue