This commit is contained in:
Andrzej Kapolka 2014-05-16 17:20:40 -07:00
commit 1bbd9c326a
5 changed files with 29 additions and 19 deletions

View file

@ -714,6 +714,7 @@ void ModelItem::mapJoints(const QStringList& modelJointNames) {
if (!_jointMappingCompleted) {
QStringList animationJointNames = myAnimation->getJointNames();
if (modelJointNames.size() > 0 && animationJointNames.size() > 0) {
_jointMapping.resize(modelJointNames.size());
for (int i = 0; i < modelJointNames.size(); i++) {
@ -729,13 +730,17 @@ QVector<glm::quat> ModelItem::getAnimationFrame() {
if (hasAnimation() && _jointMappingCompleted) {
Animation* myAnimation = getAnimation(_animationURL);
QVector<FBXAnimationFrame> frames = myAnimation->getFrames();
int animationFrameIndex = (int)std::floor(_animationFrameIndex) % frames.size();
QVector<glm::quat> rotations = frames[animationFrameIndex].rotations;
frameData.resize(_jointMapping.size());
for (int j = 0; j < _jointMapping.size(); j++) {
int rotationIndex = _jointMapping[j];
if (rotationIndex != -1 && rotationIndex < rotations.size()) {
frameData[j] = rotations[rotationIndex];
int frameCount = frames.size();
if (frameCount > 0) {
int animationFrameIndex = (int)glm::floor(_animationFrameIndex) % frameCount;
QVector<glm::quat> rotations = frames[animationFrameIndex].rotations;
frameData.resize(_jointMapping.size());
for (int j = 0; j < _jointMapping.size(); j++) {
int rotationIndex = _jointMapping[j];
if (rotationIndex != -1 && rotationIndex < rotations.size()) {
frameData[j] = rotations[rotationIndex];
}
}
}
}

View file

@ -108,6 +108,7 @@ bool FindAndUpdateModelOperator::PostRecursion(OctreeElement* element) {
return !_found; // if we haven't yet found it, keep looking
}
// TODO: improve this to not use multiple recursions
void ModelTree::storeModel(const ModelItem& model, const SharedNodePointer& senderNode) {
// First, look for the existing model in the tree..
FindAndUpdateModelOperator theOperator(model);
@ -118,8 +119,13 @@ void ModelTree::storeModel(const ModelItem& model, const SharedNodePointer& send
AABox modelBox = model.getAABox();
ModelTreeElement* element = (ModelTreeElement*)getOrCreateChildElementContaining(model.getAABox());
element->storeModel(model);
// In the case where we stored it, we also need to mark the entire "path" down to the model as
// having changed. Otherwise viewers won't see this change. So we call this recursion now that
// we know it will be found, this find/update will correctly mark the tree as changed.
recurseTreeWithOperator(&theOperator);
}
// what else do we need to do here to get reaveraging to work
_isDirty = true;
}

View file

@ -1389,6 +1389,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element,
keepDiggingDeeper = (inViewNotLeafCount > 0);
if (continueThisLevel && keepDiggingDeeper) {
// at this point, we need to iterate the children who are in view, even if not colored
// and we need to determine if there's a deeper tree below them that we care about.
//
@ -1433,7 +1434,12 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element,
//
// This only applies in the view frustum case, in other cases, like file save and copy/past where
// no viewFrustum was requested, we still want to recurse the child tree.
if (!params.viewFrustum || !oneAtBit(childrenColoredBits, originalIndex)) {
//
// NOTE: some octree styles (like models and particles) will store content in parent elements, and child
// elements. In this case, if we stop recursion when we include any data (the colorbits should really be
// called databits), then we wouldn't send the children. So those types of Octree's should tell us to keep
// recursing, by returning TRUE in recurseChildrenWithData().
if (recurseChildrenWithData() || !params.viewFrustum || !oneAtBit(childrenColoredBits, originalIndex)) {
childTreeBytesOut = encodeTreeBitstreamRecursion(childElement, packetData, bag, params,
thisLevel, nodeLocationThisView);
}
@ -1519,16 +1525,6 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element,
} // end keepDiggingDeeper
// At this point all our BitMasks are complete... so let's output them to see how they compare...
/**
printf("This Level's BitMasks: childInTree:");
outputBits(childrenExistInTreeBits, false, true);
printf(" childInPacket:");
outputBits(childrenExistInPacketBits, false, true);
printf(" childrenColored:");
outputBits(childrenColoredBits, false, true);
qDebug("");
**/
// if we were unable to fit this level in our packet, then rewind and add it to the element bag for
// sending later...
if (continueThisLevel) {

View file

@ -209,6 +209,8 @@ public:
virtual bool handlesEditPacketType(PacketType packetType) const { return false; }
virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
const unsigned char* editData, int maxLength, const SharedNodePointer& sourceNode) { return 0; }
virtual bool recurseChildrenWithData() const { return true; }
virtual void update() { }; // nothing to do by default

View file

@ -55,6 +55,7 @@ public:
virtual bool handlesEditPacketType(PacketType packetType) const;
virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
const unsigned char* editData, int maxLength, const SharedNodePointer& node);
virtual bool recurseChildrenWithData() const { return false; }
private:
// helper functions for nudgeSubTree