gak - get streaming working again

This commit is contained in:
Brad Hefta-Gaub 2015-10-02 17:06:32 -07:00
parent 86a3825a5a
commit f618a2adfa
5 changed files with 51 additions and 33 deletions

View file

@ -24,8 +24,7 @@ AnimationLoop::AnimationLoop() :
_running(false),
_frameIndex(0.0f),
_maxFrameIndexHint(MAXIMUM_POSSIBLE_FRAME),
_resetOnRunning(false),
_firstRun(true)
_resetOnRunning(false)
{
}
@ -38,8 +37,7 @@ AnimationLoop::AnimationLoop(const AnimationDetails& animationDetails) :
_lastFrame(animationDetails.lastFrame),
_running(animationDetails.running),
_frameIndex(animationDetails.frameIndex),
_resetOnRunning(false),
_firstRun(true)
_resetOnRunning(false)
{
}
@ -53,8 +51,7 @@ AnimationLoop::AnimationLoop(float fps, bool loop, bool hold, bool startAutomati
_lastFrame(lastFrame),
_running(running),
_frameIndex(frameIndex),
_resetOnRunning(false),
_firstRun(true)
_resetOnRunning(false)
{
}
@ -94,10 +91,10 @@ void AnimationLoop::setRunning(bool running) {
_running = running;
// If we just set running to true, then also reset the frame to the first frame
if (running && (_resetOnRunning || _firstRun)) {
if (running && (_resetOnRunning)) {
// move back to the beginning
qDebug() << "resetting _frameIndex:" << _frameIndex << "to _firstFrame:" << _firstFrame;
_frameIndex = _firstFrame;
_firstRun = false;
}
}
}

View file

@ -70,7 +70,6 @@ private:
float _frameIndex;
float _maxFrameIndexHint;
bool _resetOnRunning;
bool _firstRun;
};
#endif // hifi_AnimationLoop_h

View file

@ -100,7 +100,8 @@ void AnimationPropertyGroup::copyFromScriptValue(const QScriptValue& object, boo
void AnimationPropertyGroup::setFromOldAnimationSettings(const QString& value) {
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() value:" << value;
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() url:" << getURL() << "value:" << value;
// the animations setting is a JSON string that may contain various animation settings.
// if it includes fps, frameIndex, or running, those values will be parsed out and
// will over ride the regular animation settings
@ -125,37 +126,37 @@ void AnimationPropertyGroup::setFromOldAnimationSettings(const QString& value) {
if (settingsMap.contains("frameIndex")) {
frameIndex = settingsMap["frameIndex"].toFloat();
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had frameIndex";
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had frameIndex:" << frameIndex;
}
if (settingsMap.contains("running")) {
running = settingsMap["running"].toBool();
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had running";
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had running:" << running;
}
if (settingsMap.contains("firstFrame")) {
frameIndex = settingsMap["firstFrame"].toFloat();
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had firstFrame";
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had firstFrame:" << firstFrame;
}
if (settingsMap.contains("lastFrame")) {
frameIndex = settingsMap["lastFrame"].toFloat();
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had lastFrame";
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had lastFrame:" << lastFrame;
}
if (settingsMap.contains("loop")) {
running = settingsMap["loop"].toBool();
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had loop";
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had loop:" << loop;
}
if (settingsMap.contains("hold")) {
running = settingsMap["hold"].toBool();
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had hold";
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had hold:" << hold;
}
if (settingsMap.contains("startAutomatically")) {
running = settingsMap["startAutomatically"].toBool();
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had startAutomatically";
qDebug() << "AnimationPropertyGroup::setFromOldAnimationSettings() had startAutomatically:" << startAutomatically;
}
if (_animationLoop) {
@ -182,7 +183,9 @@ void AnimationPropertyGroup::setFromOldAnimationSettings(const QString& value) {
void AnimationPropertyGroup::debugDump() const {
qDebug() << " AnimationPropertyGroup: ---------------------------------------------";
qDebug() << " URL:" << getURL() << " has changed:" << urlChanged();
qDebug() << " url:" << getURL() << " has changed:" << urlChanged();
qDebug() << " fps:" << getFPS() << " has changed:" << fpsChanged();
qDebug() << "frameIndex:" << getFrameIndex() << " has changed:" << frameIndexChanged();
}
bool AnimationPropertyGroup::appendToEditPacket(OctreePacketData* packetData,
@ -377,15 +380,6 @@ void AnimationPropertyGroup::appendSubclassData(OctreePacketData* packetData, En
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_URL, getURL());
if (_animationLoop) {
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FPS, getFPS());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, getFrameIndex());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, getRunning());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_LOOP, getLoop());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FIRST_FRAME, getFirstFrame());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_LAST_FRAME, getLastFrame());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_HOLD, getHold());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_START_AUTOMATICALLY, getStartAutomatically());
} else {
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FPS, _animationLoop->getFPS());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, _animationLoop->getFrameIndex());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, _animationLoop->getRunning());
@ -395,6 +389,16 @@ void AnimationPropertyGroup::appendSubclassData(OctreePacketData* packetData, En
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_HOLD, _animationLoop->getHold());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_START_AUTOMATICALLY, _animationLoop->getStartAutomatically());
}
else {
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FPS, getFPS());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, getFrameIndex());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, getRunning());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_LOOP, getLoop());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FIRST_FRAME, getFirstFrame());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_LAST_FRAME, getLastFrame());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_HOLD, getHold());
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_START_AUTOMATICALLY, getStartAutomatically());
}
}
int AnimationPropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
@ -410,7 +414,7 @@ int AnimationPropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char
if (_animationLoop) {
// apply new properties to our associated AnimationLoop
//qDebug() << "AnimationPropertyGroup::readEntitySubclassDataFromBuffer() -- apply new properties to our associated AnimationLoop";
qDebug() << "AnimationPropertyGroup::readEntitySubclassDataFromBuffer() -- apply new properties to our associated AnimationLoop";
READ_ENTITY_PROPERTY(PROP_ANIMATION_FPS, float, _animationLoop->setFPS);
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, _animationLoop->setFrameIndex);
READ_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, bool, _animationLoop->setRunning);
@ -420,6 +424,7 @@ int AnimationPropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char
READ_ENTITY_PROPERTY(PROP_ANIMATION_HOLD, bool, _animationLoop->setHold);
READ_ENTITY_PROPERTY(PROP_ANIMATION_START_AUTOMATICALLY, bool, _animationLoop->setStartAutomatically);
} else {
qDebug() << "AnimationPropertyGroup::readEntitySubclassDataFromBuffer() -- NO AnimationLoop store locally";
READ_ENTITY_PROPERTY(PROP_ANIMATION_FPS, float, setFPS);
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, setFrameIndex);
READ_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, bool, setRunning);
@ -430,6 +435,10 @@ int AnimationPropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char
READ_ENTITY_PROPERTY(PROP_ANIMATION_START_AUTOMATICALLY, bool, setStartAutomatically);
}
if (_animationLoop) {
qDebug() << "_animationLoop->isRunning():" << _animationLoop->isRunning();
}
return bytesRead;
}

View file

@ -176,6 +176,7 @@ void EntityItemProperties::debugDump() const {
qCDebug(entities) << " _modelURL=" << _modelURL;
qCDebug(entities) << " _compoundShapeURL=" << _compoundShapeURL;
getAnimation().debugDump();
getAtmosphere().debugDump();
getSkybox().debugDump();

View file

@ -49,6 +49,8 @@ ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID, const EntityI
EntityItemProperties ModelEntityItem::getProperties(EntityPropertyFlags desiredProperties) const {
EntityItemProperties properties = EntityItem::getProperties(desiredProperties); // get the properties from our base class
//qDebug() << "ModelEntityItem::getProperties() id:" << getEntityItemID();
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getXColor);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(modelURL, getModelURL);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(compoundShapeURL, getCompoundShapeURL);
@ -58,6 +60,8 @@ EntityItemProperties ModelEntityItem::getProperties(EntityPropertyFlags desiredP
_animationProperties.getProperties(properties);
//properties.debugDump();
return properties;
}
@ -73,7 +77,11 @@ bool ModelEntityItem::setProperties(const EntityItemProperties& properties) {
SET_ENTITY_PROPERTY_FROM_PROPERTIES(textures, setTextures);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(shapeType, updateShapeType);
qDebug() << "ModelEntityItem::setProperties() id:" << getEntityItemID() << "modelURL:" << getModelURL();
qDebug() << "ModelEntityItem::setProperties() id:" << getEntityItemID() << "calling _animationProperties.setProperties()";
bool somethingChangedInAnimations = _animationProperties.setProperties(properties);
qDebug() << "ModelEntityItem::setProperties() id:" << getEntityItemID() << "AFTER _animationProperties.setProperties() running:" << _animationLoop.getRunning();
qDebug() << "ModelEntityItem::setProperties() id:" << getEntityItemID() << "AFTER _animationProperties.setProperties() frameIndex:" << _animationLoop.getFrameIndex();
somethingChanged = somethingChanged || somethingChangedInAnimations;
@ -102,17 +110,15 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
READ_ENTITY_PROPERTY(PROP_MODEL_URL, QString, setModelURL);
if (args.bitstreamVersion < VERSION_ENTITIES_HAS_COLLISION_MODEL) {
setCompoundShapeURL("");
} else if (args.bitstreamVersion == VERSION_ENTITIES_HAS_COLLISION_MODEL) {
READ_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL);
} else {
READ_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL);
}
READ_ENTITY_PROPERTY(PROP_ANIMATION_URL, QString, setAnimationURL);
// Because we're using AnimationLoop which will reset the frame index if you change it's running state
// we want to read these values in the order they appear in the buffer, but call our setters in an
// order that allows AnimationLoop to preserve the correct frame rate.
if (args.bitstreamVersion < VERSION_ENTITIES_ANIMATION_PROPERTIES_GROUP) {
READ_ENTITY_PROPERTY(PROP_ANIMATION_URL, QString, setAnimationURL);
READ_ENTITY_PROPERTY(PROP_ANIMATION_FPS, float, setAnimationFPS);
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, setAnimationFrameIndex);
READ_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, bool, setAnimationIsPlaying);
@ -135,6 +141,9 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
READ_ENTITY_PROPERTY(PROP_SHAPE_TYPE, ShapeType, updateShapeType);
qDebug() << "ModelEntityItem::readEntitySubclassDataFromBuffer()";
debugDump();
return bytesRead;
}
@ -278,7 +287,9 @@ void ModelEntityItem::update(const quint64& now) {
float deltaTime = (float)(now - _lastAnimated) / (float)USECS_PER_SECOND;
_lastAnimated = now;
_animationLoop.simulate(deltaTime);
} else {
//qDebug() << "ModelEntityItem::update() id:" << getEntityItemID() << "frameIndex:" << _animationLoop.getFrameIndex();
}
else {
_lastAnimated = now;
}
EntityItem::update(now); // let our base class handle it's updates...
@ -290,7 +301,8 @@ void ModelEntityItem::debugDump() const {
qCDebug(entities) << " position:" << getPosition();
qCDebug(entities) << " dimensions:" << getDimensions();
qCDebug(entities) << " model URL:" << getModelURL();
qCDebug(entities) << " compound shape URL:" << getCompoundShapeURL();
qCDebug(entities) << " _animationLoop.isRunning():" << _animationLoop.isRunning();
//qCDebug(entities) << " compound shape URL:" << getCompoundShapeURL();
}
void ModelEntityItem::updateShapeType(ShapeType type) {