mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 15:53:35 +02:00
Added onLoadComplete signal to MyAvatar
This can be used in javaScript to detect when the model has finished loading because the url has changed or the model has been reset.
This commit is contained in:
parent
b943a664b6
commit
1682598be7
4 changed files with 16 additions and 3 deletions
|
@ -198,6 +198,8 @@ MyAvatar::MyAvatar(RigPointer rig) :
|
|||
_headData->setLookAtPosition(headData->getLookAtPosition());
|
||||
}
|
||||
});
|
||||
|
||||
connect(rig.get(), SIGNAL(onLoadComplete()), SLOT(onRigLoadComplete()));
|
||||
}
|
||||
|
||||
MyAvatar::~MyAvatar() {
|
||||
|
@ -2080,7 +2082,7 @@ float MyAvatar::getAccelerationEnergy() {
|
|||
int changeInVelocity = abs(velocity.length() - priorVelocity.length());
|
||||
float changeInEnergy = priorVelocity.length() * changeInVelocity * AVATAR_MOVEMENT_ENERGY_CONSTANT;
|
||||
priorVelocity = velocity;
|
||||
|
||||
|
||||
return changeInEnergy;
|
||||
}
|
||||
|
||||
|
@ -2103,3 +2105,6 @@ bool MyAvatar::didTeleport() {
|
|||
return (changeInPosition.length() > MAX_AVATAR_MOVEMENT_PER_FRAME);
|
||||
}
|
||||
|
||||
void MyAvatar::onRigLoadComplete() {
|
||||
emit onLoadComplete();
|
||||
}
|
||||
|
|
|
@ -295,7 +295,7 @@ signals:
|
|||
void collisionWithEntity(const Collision& collision);
|
||||
void energyChanged(float newEnergy);
|
||||
void positionGoneTo();
|
||||
|
||||
void onLoadComplete();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -469,6 +469,8 @@ private:
|
|||
float getEnergy();
|
||||
void setEnergy(float value);
|
||||
bool didTeleport();
|
||||
private slots:
|
||||
void onRigLoadComplete();
|
||||
};
|
||||
|
||||
QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode);
|
||||
|
|
|
@ -1161,6 +1161,7 @@ void Rig::initAnimGraph(const QUrl& url) {
|
|||
overrideAnimation(origState.url, origState.fps, origState.loop, origState.firstFrame, origState.lastFrame);
|
||||
}
|
||||
|
||||
emitOnLoadComplete();
|
||||
});
|
||||
connect(_animLoader.get(), &AnimNodeLoader::error, [url](int error, QString str) {
|
||||
qCCritical(animation) << "Error loading" << url.toDisplayString() << "code = " << error << "str =" << str;
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef std::shared_ptr<Rig> RigPointer;
|
|||
// However only specific methods thread-safe. Noted below.
|
||||
|
||||
class Rig : public QObject, public std::enable_shared_from_this<Rig> {
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct StateHandler {
|
||||
AnimVariantMap results;
|
||||
|
@ -223,7 +224,11 @@ public:
|
|||
|
||||
const glm::mat4& getGeometryToRigTransform() const { return _geometryToRigTransform; }
|
||||
|
||||
protected:
|
||||
signals:
|
||||
void onLoadComplete();
|
||||
|
||||
protected:
|
||||
void emitOnLoadComplete() { emit onLoadComplete(); }
|
||||
bool isIndexValid(int index) const { return _animSkeleton && index >= 0 && index < _animSkeleton->getNumJoints(); }
|
||||
void updateAnimationStateHandlers();
|
||||
void applyOverridePoses();
|
||||
|
|
Loading…
Reference in a new issue