mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 07:04:05 +02:00
update crowd-agent and summon for bubble, avatar-mixin optimizations.
This commit is contained in:
parent
0fb9ef947a
commit
9a44f63b74
2 changed files with 20 additions and 7 deletions
scripts/developer/tests/performance
|
@ -16,7 +16,7 @@
|
|||
|
||||
var MESSAGE_CHANNEL = "io.highfidelity.summon-crowd";
|
||||
|
||||
print('crowd-agent version 4');
|
||||
print('crowd-agent version 5');
|
||||
|
||||
/* Observations:
|
||||
- File urls for AC scripts silently fail. Use a local server (e.g., python SimpleHTTPServer) for development.
|
||||
|
@ -84,6 +84,9 @@ function startAgent(parameters) { // Can also be used to update.
|
|||
clearStopper();
|
||||
var wasOff = !Agent.isAvatar;
|
||||
Agent.isAvatar = true;
|
||||
if (parameters.displayName !== undefined) {
|
||||
Avatar.displayName = parameters.displayName;
|
||||
}
|
||||
if (parameters.position) {
|
||||
Avatar.position = parameters.position;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
// See crowd-agent.js
|
||||
|
||||
var version = 2;
|
||||
var version = 3;
|
||||
var label = "summon";
|
||||
function debug() {
|
||||
print.apply(null, [].concat.apply([label, version], [].map.call(arguments, JSON.stringify)));
|
||||
|
@ -23,6 +23,9 @@ var MINIMUM_AVATARS = 25; // We will summon agents to produce this many total. (
|
|||
var N_LISTENING = MINIMUM_AVATARS - 1;
|
||||
var AVATARS_CHATTERING_AT_ONCE = 4; // How many of the agents should we request to play SOUND_DATA at once.
|
||||
|
||||
var initialBubble = Users.getIgnoreRadiusEnabled();
|
||||
debug('startup seeking:', MINIMUM_AVATARS, 'listening:', N_LISTENING, 'chattering:', AVATARS_CHATTERING_AT_ONCE, 'had bubble:', initialBubble);
|
||||
|
||||
// If we add or remove things too quickly, we get problems (e.g., audio, fogbugz 2095).
|
||||
// For now, spread them out this timing apart.
|
||||
var SPREAD_TIME_MS = 500;
|
||||
|
@ -66,7 +69,7 @@ function messageHandler(channel, messageString, senderID) {
|
|||
if (MyAvatar.sessionUUID === senderID) { // ignore my own
|
||||
return;
|
||||
}
|
||||
var message = {}, avatarIdentifiers;
|
||||
var message = {};
|
||||
try {
|
||||
message = JSON.parse(messageString);
|
||||
} catch (e) {
|
||||
|
@ -76,9 +79,10 @@ function messageHandler(channel, messageString, senderID) {
|
|||
case "hello":
|
||||
Script.setTimeout(function () {
|
||||
// There can be avatars we've summoned that do not yet appear in the AvatarList.
|
||||
avatarIdentifiers = without(AvatarList.getAvatarIdentifiers(), summonedAgents);
|
||||
var avatarIdentifiers = without(AvatarList.getAvatarIdentifiers(), summonedAgents);
|
||||
var nSummoned = summonedAgents.length;
|
||||
debug('present', avatarIdentifiers, summonedAgents);
|
||||
if ((summonedAgents.length + avatarIdentifiers.length) < MINIMUM_AVATARS ) {
|
||||
if ((nSummoned + avatarIdentifiers.length) < MINIMUM_AVATARS ) {
|
||||
var chatter = chattering.length < AVATARS_CHATTERING_AT_ONCE;
|
||||
var listen = nListening < N_LISTENING;
|
||||
if (chatter) {
|
||||
|
@ -91,6 +95,7 @@ function messageHandler(channel, messageString, senderID) {
|
|||
messageSend({
|
||||
key: 'SUMMON',
|
||||
rcpt: senderID,
|
||||
displayName: "crowd " + nSummoned + " " + senderID,
|
||||
position: Vec3.sum(MyAvatar.position, {x: coord(), y: 0, z: coord()}),
|
||||
orientation: Quat.fromPitchYawRollDegrees(0, Quat.safeEulerAngles(MyAvatar.orientation).y + (turnSpread * (Math.random() - 0.5)), 0),
|
||||
soundData: chatter && SOUND_DATA,
|
||||
|
@ -100,7 +105,7 @@ function messageHandler(channel, messageString, senderID) {
|
|||
});
|
||||
}
|
||||
}, accumulatedDelay);
|
||||
accumulatedDelay += SPREAD_TIME_MS; // assume we'll get all the hello respsponses more or less together.
|
||||
accumulatedDelay += SPREAD_TIME_MS; // assume we'll get all the hello responses more or less together.
|
||||
break;
|
||||
case "finishedSound": // Give someone else a chance.
|
||||
chattering = without(chattering, [senderID]);
|
||||
|
@ -123,6 +128,8 @@ Messages.subscribe(MESSAGE_CHANNEL);
|
|||
Messages.messageReceived.connect(messageHandler);
|
||||
Script.scriptEnding.connect(function () {
|
||||
debug('stopping agents', summonedAgents);
|
||||
Users.requestsDomainListData = false;
|
||||
if (initialBubble && !Users.getIgnoreRadiusEnabled()) { Users.toggleIgnoreRadius(); }
|
||||
Messages.messageReceived.disconnect(messageHandler); // don't respond to any messages during shutdown
|
||||
accumulatedDelay = 0;
|
||||
summonedAgents.forEach(function (id) {
|
||||
|
@ -134,14 +141,17 @@ Script.scriptEnding.connect(function () {
|
|||
debug('unsubscribed');
|
||||
});
|
||||
|
||||
Users.requestsDomainListData = true; // Get avatar data for the whole domain, even if not in our view.
|
||||
if (initialBubble) { Users.toggleIgnoreRadius(); }
|
||||
messageSend({key: 'HELO'}); // Ask agents to report in now.
|
||||
Script.setTimeout(function () {
|
||||
var total = AvatarList.getAvatarIdentifiers().length;
|
||||
if (0 === summonedAgents.length) {
|
||||
Window.alert("No agents reported.\n\Please run " + MINIMUM_AVATARS + " instances of\n\
|
||||
http://hifi-content.s3.amazonaws.com/howard/scripts/tests/performance/crowd-agent.js\n\
|
||||
http://hifi-content.s3.amazonaws.com/howard/scripts/tests/performance/crowd-agent.js?v=someDate\n\
|
||||
on your domain server.");
|
||||
} else if (total < MINIMUM_AVATARS) {
|
||||
Window.alert("Only " + summonedAgents.length + " agents reported. Now missing " + (MINIMUM_AVATARS - total) + " avatars, total.");
|
||||
}
|
||||
Users.requestsDomainListData = false;
|
||||
}, MINIMUM_AVATARS * SPREAD_TIME_MS )
|
||||
|
|
Loading…
Reference in a new issue