Avatar flickering at high velocities - movie and scripts


#1

I wanted see if others are having the same issues as me before I submit a bug report. I’ve come across a bug that show up as the avatar flickering / disappearing when moving at high velocities and a bug in the stats. Specifically:

  • script induced velocity is not reported in stats
  • actual velocity is clamped at 300 m/s when using movement keys, but is unlimited for scripted movement
  • avi flickers when moved at high velocity using the movement keys
  • avi flickers / disappears during large scripted translations
  • avi disappears at around 270 m/s when scripting translations

Demo here: http://www.youtube.com/watch?v=yBivj8FEvz8

There is also an issue with the amount of movement - when oscillating, the script moves the avi left and right using values of -1 to +1, yet in the movie the avatar clearly moves a lot more than 2 metres left to right. I’d assumed that x+1 would move the avatar one metre, but apparently not. It could be decimetres, but that’s just a guess. Or maybe there something more complex going on with conservation of momentum? Does anyone know which units (if any) are in use?

I’ve included the scripts here so my results can be verified. The control keys for the movement test script are:

  • sidestep left: ,
  • sidestep right: .
  • fly upwards at ever increasing speed: l
  • oscillate: o

Script for the debug info panel:

// davedub’s debugging panel script
var overlayWidth = 300;
var overlayHeight = 100;
var statsHeight = 88;
var leftHandMargin = 5;
var debugInfoDisplay = Overlays.addOverlay(“image”, {
bounds: { x: Window.innerWidth - overlayWidth, y: Window.innerHeight - overlayHeight - statsHeight, width: overlayWidth, height: overlayHeight},
imageURL: “http://davedub.co.uk/downloads/hf/overlays/dd-debug-background.png”,
color: { red: 255, green: 255, blue: 255},
alpha: 1
});
var textOverlay = Overlays.addOverlay(“text”, {
x: Window.innerWidth - overlayWidth + leftHandMargin,
y: Window.innerHeight - overlayHeight - statsHeight,
width: 300,
height: 100,
color: { red: 0, green: 0, blue: 0},
textColor: { red: 255, green: 0, blue: 0},
topMargin: 10,
leftMargin: leftHandMargin,
text: “initialising”
});
var cumulativeTime = 0;
var lastPosition;
var peakVelocity = 0;
var frameTimeMax = 0;
var frameTimeMin = 1000;
Script.update.connect(function(deltaTime) {
cumulativeTime += deltaTime;
var aviPosition = MyAvatar.position;
if(!lastPosition) lastPosition = aviPosition; // first run through
var deltaPos = Vec3.distance(aviPosition,lastPosition);
var velocity = deltaPos / deltaTime;
var fps = 1/deltaTime; if(fps<55||fps>65) print('Unsteady fps: '+fps);
var frameTime = 1000/fps;
if(velocity>peakVelocity) peakVelocity = velocity;
if(frameTime> frameTimeMax) frameTimeMax = frameTime;
if(frameTime< frameTimeMin) frameTimeMin = frameTime;
lastPosition = MyAvatar.position;
Overlays.editOverlay(textOverlay, {text: "Debug Info:\n|\nFPS: “+fps.toFixed(2)+” FT: “+frameTime.toFixed(2)
+” ms\n\nVelocity: “+velocity.toFixed(2)+” m/s Peak Velocity: “+peakVelocity.toFixed(2)
+” m/s\n\nFTmax: “+frameTimeMax.toFixed(2)+” ms FTmin: “+frameTimeMin.toFixed(2) + " ms”} );
});
Script.scriptEnding.connect(function() {
Overlays.deleteOverlay(debugInfoDisplay);
Overlays.deleteOverlay(textOverlay);
});

Movement test script

// davedub's hips translation test // convert hips translations to global (i.e. take account of avi orientation) function translateHips(localHipsTranslation) { // get avi's orientation as a quaternion var aviOrientation = MyAvatar.orientation; // get unit vectors for each direction var front = Quat.getFront(aviOrientation); var right = Quat.getRight(aviOrientation); var up = Quat.getUp (aviOrientation); //multiply avi orientation by each unit vector var aviFront = Vec3.multiply(front,localHipsTranslation.y); var aviRight = Vec3.multiply(right,localHipsTranslation.x); var aviUp = Vec3.multiply(up ,localHipsTranslation.z); // add translations in z,x,y order var AviTranslationOffset = {x:0,y:0,z:0}; // final value AviTranslationOffset = Vec3.sum(AviTranslationOffset, aviFront); AviTranslationOffset = Vec3.sum(AviTranslationOffset, aviRight); AviTranslationOffset = Vec3.sum(AviTranslationOffset, aviUp); // set new avi position MyAvatar.position = {x: MyAvatar.position.x + AviTranslationOffset.x, y: MyAvatar.position.y + AviTranslationOffset.y, z: MyAvatar.position.z + AviTranslationOffset.z }; } var oscillate = false; var goToInfinity = false; function keyPressEvent(event) { if (event.text == ",") { translateHips({x:-1,y:0,z:0}); } else if (event.text == ".") { translateHips({x:1,y:0,z:0}); } else if (event.text == "o") { oscillate = !oscillate; } else if (event.text == "l") { goToInfinity = !goToInfinity; } } Controller.keyPressEvent.connect(keyPressEvent); Controller.captureKeyEvents({ text: "," }); Controller.captureKeyEvents({ text: "." }); Controller.captureKeyEvents({ text: "o" }); Controller.captureKeyEvents({ text: "l" }); var increment = 0; var cumulativeTime = 0; Script.update.connect(function(deltaTime) { if(oscillate) { cumulativeTime += deltaTime; translateHips({x:Math.sin(cumulativeTime),y:0,z:0}); } if(goToInfinity) { increment+=0.01; translateHips({x:0,y:0,z:increment}); } });
  • Dave

#2

Yeah I get the flicker thing happening but Just figured it was better for me to blame people then attempt to do anything productive about it :slight_smile:


#3

First off, nice little debug script… second, yes, confirmed everything you stated in your post. I imagine that’s why velocity is clamped at 300…


#4

I just seen this flickring problem myself to, but it only appears on the Y axis. if i go up and down at high speed, my avatar dissapear.