made some changes to fix coding standard problems in the code, also added the update for the EntityItem base class to the update function

This commit is contained in:
amantley 2017-11-28 18:42:03 -08:00
parent 101e67498a
commit 778d98f56b
5 changed files with 37 additions and 53 deletions

View file

@ -403,7 +403,7 @@ void EntityTreeRenderer::update(bool simulate) {
if (_tree && !_shuttingDown) {
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
//here we update _currentFrame and _lastAnimated and sync with the server properties.
// here we update _currentFrame and _lastAnimated and sync with the server properties.
tree->update(simulate);
// Update the rendereable entities as needed
@ -738,7 +738,7 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event) {
PickRay ray = _viewState->computePickRay(event->x(), event->y());
RayToEntityIntersectionResult rayPickResult = _getPrevRayPickResultOperator(_mouseRayPickID);
if (rayPickResult.intersects && rayPickResult.entity) {
//qCDebug(entitiesrenderer) << "mouseReleaseEvent over entity:" << rayPickResult.entityID;
// qCDebug(entitiesrenderer) << "mouseReleaseEvent over entity:" << rayPickResult.entityID;
glm::vec2 pos2D = projectOntoEntityXYPlane(rayPickResult.entity, ray, rayPickResult);
PointerEvent pointerEvent(PointerEvent::Release, PointerManager::MOUSE_POINTER_ID,

View file

@ -465,7 +465,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
shapeInfo.setParams(type, dimensions, getCompoundShapeURL());
} else if (type >= SHAPE_TYPE_SIMPLE_HULL && type <= SHAPE_TYPE_STATIC_MESH) {
// TODO: assert we never fall in here when model not fully loaded
//assert(_model && _model->isLoaded());
// assert(_model && _model->isLoaded());
updateModelBounds();
model->updateGeometry();
@ -992,10 +992,10 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) {
//the code to find the current frame is now in modelEntityItem.cpp and we access it below -Angus
{
//where are we in the currently defined animation segment?
// where are we in the currently defined animation segment?
int animationCurrentFrame = (int)(glm::floor(entity->getAnimationCurrentFrame()));
//in the case where the last frame is greater than the framecount then clamp
//it to the end of the animation until it loops around.
// in the case where the last frame is greater than the framecount then clamp
// it to the end of the animation until it loops around.
if (animationCurrentFrame < 0 || animationCurrentFrame > frameCount) {
animationCurrentFrame = 0;
@ -1032,10 +1032,10 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) {
glm::mat4 translationMat;
if (allowTranslation) {
if(index < translations.size()){
if (index < translations.size()) {
translationMat = glm::translate(translations[index]);
}
} else if (index < animationJointNames.size()){
} else if (index < animationJointNames.size()) {
QString jointName = fbxJoints[index].name; // Pushing this here so its not done on every entity, with the exceptions of those allowing for translation
if (originalFbxIndices.contains(jointName)) {
@ -1312,8 +1312,8 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
model->updateRenderItems();
}
//The code to deal with the change of properties is now in ModelEntityItem.cpp
//That is where _currentFrame and _lastAnimated are updated.
// The code to deal with the change of properties is now in ModelEntityItem.cpp
// That is where _currentFrame and _lastAnimated are updated.
if (_animating) {

View file

@ -33,7 +33,7 @@ namespace render { namespace entities {
class ModelEntityRenderer;
} }
//#define MODEL_ENTITY_USE_FADE_EFFECT
// #define MODEL_ENTITY_USE_FADE_EFFECT
class ModelEntityWrapper : public ModelEntityItem {
using Parent = ModelEntityItem;
friend class render::entities::ModelEntityRenderer;
@ -185,8 +185,6 @@ private:
bool _animating { false };
uint64_t _lastAnimated { 0 };
float _currentFrame { -1 };
float _endAnim{ 0 };
bool tempbool{ false };
};
} } // namespace

View file

@ -34,8 +34,7 @@ EntityItemPointer ModelEntityItem::factory(const EntityItemID& entityID, const E
ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID) : EntityItem(entityItemID)
{
_lastAnimated = usecTimestampNow();
qCDebug(entities) << "init last animated " << _lastAnimated;
//set the last animated when interface (re)starts
// set the last animated when interface (re)starts
_type = EntityTypes::Model;
_lastKnownCurrentFrame = -1;
_color[0] = _color[1] = _color[2] = 0;
@ -190,79 +189,71 @@ void ModelEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
//added update for property fix
// added update for property fix
void ModelEntityItem::update(const quint64& now) {
{
auto currentAnimationProperties = this->getAnimationProperties();
if (_previousAnimationProperties != currentAnimationProperties) {
withWriteLock([&] {
if ( (currentAnimationProperties.getFirstFrame() != _previousAnimationProperties.getFirstFrame()) || (currentAnimationProperties.getLastFrame() != _previousAnimationProperties.getLastFrame()) || (currentAnimationProperties.getRunning() && !_previousAnimationProperties.getRunning())) {
if ((currentAnimationProperties.getFirstFrame() != _previousAnimationProperties.getFirstFrame()) || (currentAnimationProperties.getLastFrame() != _previousAnimationProperties.getLastFrame()) || (currentAnimationProperties.getRunning() && !_previousAnimationProperties.getRunning())) {
if (_currentFrame < 0) {
_currentFrame = currentAnimationProperties.getCurrentFrame();
setAnimationCurrentFrame(_currentFrame);
qCDebug(entities) << "restart code hit " << _currentFrame;
}
else {
qCDebug(entities) << "restart code hit last animated is " << _lastAnimated << " now is " << now;
} else {
_lastAnimated = usecTimestampNow();
qCDebug(entities) << "last animated 1" << _lastAnimated;
_currentFrame = currentAnimationProperties.getFirstFrame();
qCDebug(entities) << "point 2 " << _currentFrame;
setAnimationCurrentFrame(currentAnimationProperties.getFirstFrame());
}
}else if (currentAnimationProperties.getHold() && !_previousAnimationProperties.getHold()) {
} else if (currentAnimationProperties.getHold() && !_previousAnimationProperties.getHold()) {
qCDebug(entities) << "hold is pressed" << _currentFrame;
}else if (!currentAnimationProperties.getHold() && _previousAnimationProperties.getHold()) {
} else if (!currentAnimationProperties.getHold() && _previousAnimationProperties.getHold()) {
qCDebug(entities) << "hold is unpressed" << _currentFrame;
}else if (!currentAnimationProperties.getLoop() && _previousAnimationProperties.getLoop()) {
} else if (!currentAnimationProperties.getLoop() && _previousAnimationProperties.getLoop()) {
qCDebug(entities) << "loop is unpressed" << _currentFrame;
}else if (currentAnimationProperties.getLoop() && !_previousAnimationProperties.getLoop()) {
} else if (currentAnimationProperties.getLoop() && !_previousAnimationProperties.getLoop()) {
qCDebug(entities) << "loop is pressed" << _currentFrame;
}else if(currentAnimationProperties.getCurrentFrame() != _previousAnimationProperties.getCurrentFrame()){
} else if (currentAnimationProperties.getCurrentFrame() != _previousAnimationProperties.getCurrentFrame()) {
_currentFrame = currentAnimationProperties.getCurrentFrame();
qCDebug(entities) << "point 3 " << _currentFrame;
}
});
_previousAnimationProperties = this->getAnimationProperties();
}
else {
} else {
//if the first frame is less than zero that is an error, so don't do anything.
// if the first frame is less than zero that is an error, so don't do anything.
if (!(getAnimationFirstFrame() < 0)) {
//if the current frame is less than zero then we are restarting the server.
// if the current frame is less than zero then we are restarting the server.
if (_currentFrame < 0) {
qCDebug(entities) << "point 3.5 " << _currentFrame;
//_previousAnimationProperties = currentAnimationProperties;
if ((currentAnimationProperties.getCurrentFrame() < currentAnimationProperties.getLastFrame()) && (currentAnimationProperties.getCurrentFrame() > currentAnimationProperties.getFirstFrame())) {
_currentFrame = currentAnimationProperties.getCurrentFrame();
qCDebug(entities) << "current frame less than zero " << _currentFrame;
}
else {
} else {
_currentFrame = currentAnimationProperties.getFirstFrame();
setAnimationCurrentFrame(_currentFrame);
_lastAnimated = usecTimestampNow();
qCDebug(entities) << "last animated 2" << _lastAnimated;
}
}
}
}
//_previousAnimationProperties = currentAnimationProperties;
// _previousAnimationProperties = currentAnimationProperties;
if (isAnimatingSomething()) {
if (!(getAnimationFirstFrame() < 0) && !(getAnimationFirstFrame() > getAnimationLastFrame()) ) {
if (!(getAnimationFirstFrame() < 0) && !(getAnimationFirstFrame() > getAnimationLastFrame())) {
updateFrameCount();
}
}
}
EntityItem::update(now);
}
bool ModelEntityItem::needsToCallUpdate() const {
return true;
//return isAnimatingSomething() || EntityItem::needsToCallUpdate();
return true;
}
void ModelEntityItem::updateFrameCount() {
@ -276,7 +267,7 @@ void ModelEntityItem::updateFrameCount() {
auto now = usecTimestampNow();
//this is now getting the time since the server started the animation.
// this is now getting the time since the server started the animation.
auto interval = now - _lastAnimated;
_lastAnimated = now;
@ -291,23 +282,20 @@ void ModelEntityItem::updateFrameCount() {
while ((_currentFrame - getAnimationFirstFrame()) > (updatedFrameCount - 1)) {
_currentFrame -= (updatedFrameCount - 1);
}
}
else {
} else {
_currentFrame = getAnimationLastFrame();
}
}
else if (_currentFrame < getAnimationFirstFrame()) {
} else if (_currentFrame < getAnimationFirstFrame()) {
if (getAnimationFirstFrame() < 0) {
_currentFrame = 0;
}
else {
} else {
_currentFrame = getAnimationFirstFrame();
}
}
setAnimationCurrentFrame(_currentFrame);
}
//qCDebug(entities) << "_currentFrame is " << _currentFrame;
}
@ -709,7 +697,7 @@ float ModelEntityItem::getAnimationLastFrame() const {
return _animationProperties.getLastFrame();
});
}
//angus change
bool ModelEntityItem::getAnimationIsPlaying() const {
return resultWithReadLock<bool>([&] {
return _animationProperties.getRunning();

View file

@ -47,7 +47,7 @@ public:
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
bool& somethingChanged) override;
//update and needstocallupdate added back for the entity property fix
// update() and needstocallupdate() added back for the entity property fix
virtual void update(const quint64& now) override;
virtual bool needsToCallUpdate() const override;
void updateFrameCount();
@ -170,11 +170,9 @@ protected:
ShapeType _shapeType = SHAPE_TYPE_NONE;
private:
//angus
uint64_t _lastAnimated{ 0 };
AnimationPropertyGroup _previousAnimationProperties;
float _currentFrame{ -1 };
//angus
};
#endif // hifi_ModelEntityItem_h