mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 04:08:13 +02:00
move code from Avatar to OtherAvatar
This commit is contained in:
parent
1c87d7b109
commit
99aafb1f95
4 changed files with 30 additions and 28 deletions
|
@ -71,3 +71,21 @@ void OtherAvatar::updateSpaceProxy(workload::Transaction& transaction) const {
|
||||||
transaction.update(_spaceIndex, sphere);
|
transaction.update(_spaceIndex, sphere);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int OtherAvatar::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
|
int32_t bytesRead = Avatar::parseDataFromBuffer(buffer);
|
||||||
|
if (_moving && _physicsCallback) {
|
||||||
|
_physicsCallback(Simulation::DIRTY_POSITION);
|
||||||
|
}
|
||||||
|
return bytesRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OtherAvatar::rebuildCollisionShape() {
|
||||||
|
if (_physicsCallback) {
|
||||||
|
_physicsCallback(Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OtherAvatar::setPhysicsCallback(AvatarPhysicsCallback cb) {
|
||||||
|
_physicsCallback = cb;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// Created by Bradley Austin Davis on 2017/04/27
|
// Created by amantly 2018.06.26
|
||||||
// Copyright 2013-2017 High Fidelity, Inc.
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
@ -18,6 +18,8 @@
|
||||||
#include "ui/overlays/Overlays.h"
|
#include "ui/overlays/Overlays.h"
|
||||||
#include "ui/overlays/Sphere3DOverlay.h"
|
#include "ui/overlays/Sphere3DOverlay.h"
|
||||||
|
|
||||||
|
using AvatarPhysicsCallback = std::function<void(uint32_t)>;
|
||||||
|
|
||||||
class OtherAvatar : public Avatar {
|
class OtherAvatar : public Avatar {
|
||||||
public:
|
public:
|
||||||
explicit OtherAvatar(QThread* thread);
|
explicit OtherAvatar(QThread* thread);
|
||||||
|
@ -32,9 +34,16 @@ public:
|
||||||
int32_t getSpaceIndex() const { return _spaceIndex; }
|
int32_t getSpaceIndex() const { return _spaceIndex; }
|
||||||
void updateSpaceProxy(workload::Transaction& transaction) const;
|
void updateSpaceProxy(workload::Transaction& transaction) const;
|
||||||
|
|
||||||
|
int parseDataFromBuffer(const QByteArray& buffer) override;
|
||||||
|
|
||||||
|
void setPhysicsCallback(AvatarPhysicsCallback cb);
|
||||||
|
bool isInPhysicsSimulation() const { return _physicsCallback != nullptr; }
|
||||||
|
void rebuildCollisionShape() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<Sphere3DOverlay> _otherAvatarOrbMeshPlaceholder { nullptr };
|
std::shared_ptr<Sphere3DOverlay> _otherAvatarOrbMeshPlaceholder { nullptr };
|
||||||
OverlayID _otherAvatarOrbMeshPlaceholderID { UNKNOWN_OVERLAY_ID };
|
OverlayID _otherAvatarOrbMeshPlaceholderID { UNKNOWN_OVERLAY_ID };
|
||||||
|
AvatarPhysicsCallback _physicsCallback { nullptr };
|
||||||
int32_t _spaceIndex { -1 };
|
int32_t _spaceIndex { -1 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1483,9 +1483,6 @@ int Avatar::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
|
|
||||||
const float MOVE_DISTANCE_THRESHOLD = 0.001f;
|
const float MOVE_DISTANCE_THRESHOLD = 0.001f;
|
||||||
_moving = glm::distance(oldPosition, getWorldPosition()) > MOVE_DISTANCE_THRESHOLD;
|
_moving = glm::distance(oldPosition, getWorldPosition()) > MOVE_DISTANCE_THRESHOLD;
|
||||||
if (_moving) {
|
|
||||||
addPhysicsFlags(Simulation::DIRTY_POSITION);
|
|
||||||
}
|
|
||||||
if (_moving || _hasNewJointData) {
|
if (_moving || _hasNewJointData) {
|
||||||
locationChanged();
|
locationChanged();
|
||||||
}
|
}
|
||||||
|
@ -1627,20 +1624,6 @@ float Avatar::computeMass() {
|
||||||
return _density * TWO_PI * radius * radius * (glm::length(end - start) + 2.0f * radius / 3.0f);
|
return _density * TWO_PI * radius * radius * (glm::length(end - start) + 2.0f * radius / 3.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::rebuildCollisionShape() {
|
|
||||||
addPhysicsFlags(Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Avatar::setPhysicsCallback(AvatarPhysicsCallback cb) {
|
|
||||||
_physicsCallback = cb;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Avatar::addPhysicsFlags(uint32_t flags) {
|
|
||||||
if (_physicsCallback) {
|
|
||||||
_physicsCallback(flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// thread-safe
|
// thread-safe
|
||||||
glm::vec3 Avatar::getLeftPalmPosition() const {
|
glm::vec3 Avatar::getLeftPalmPosition() const {
|
||||||
return _leftPalmPositionCache.get();
|
return _leftPalmPositionCache.get();
|
||||||
|
|
|
@ -50,8 +50,6 @@ enum ScreenTintLayer {
|
||||||
|
|
||||||
class Texture;
|
class Texture;
|
||||||
|
|
||||||
using AvatarPhysicsCallback = std::function<void(uint32_t)>;
|
|
||||||
|
|
||||||
class Avatar : public AvatarData, public scriptable::ModelProvider {
|
class Avatar : public AvatarData, public scriptable::ModelProvider {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -244,7 +242,7 @@ public:
|
||||||
// (otherwise floating point error will cause problems at large positions).
|
// (otherwise floating point error will cause problems at large positions).
|
||||||
void applyPositionDelta(const glm::vec3& delta);
|
void applyPositionDelta(const glm::vec3& delta);
|
||||||
|
|
||||||
virtual void rebuildCollisionShape();
|
virtual void rebuildCollisionShape() = 0;
|
||||||
|
|
||||||
virtual void computeShapeInfo(ShapeInfo& shapeInfo);
|
virtual void computeShapeInfo(ShapeInfo& shapeInfo);
|
||||||
void getCapsule(glm::vec3& start, glm::vec3& end, float& radius);
|
void getCapsule(glm::vec3& start, glm::vec3& end, float& radius);
|
||||||
|
@ -332,10 +330,6 @@ public:
|
||||||
render::ItemID getRenderItemID() { return _renderItemID; }
|
render::ItemID getRenderItemID() { return _renderItemID; }
|
||||||
bool isMoving() const { return _moving; }
|
bool isMoving() const { return _moving; }
|
||||||
|
|
||||||
void setPhysicsCallback(AvatarPhysicsCallback cb);
|
|
||||||
void addPhysicsFlags(uint32_t flags);
|
|
||||||
bool isInPhysicsSimulation() const { return _physicsCallback != nullptr; }
|
|
||||||
|
|
||||||
void fadeIn(render::ScenePointer scene);
|
void fadeIn(render::ScenePointer scene);
|
||||||
void fadeOut(render::ScenePointer scene, KillAvatarReason reason);
|
void fadeOut(render::ScenePointer scene, KillAvatarReason reason);
|
||||||
bool isFading() const { return _isFading; }
|
bool isFading() const { return _isFading; }
|
||||||
|
@ -530,8 +524,6 @@ protected:
|
||||||
|
|
||||||
int _voiceSphereID;
|
int _voiceSphereID;
|
||||||
|
|
||||||
AvatarPhysicsCallback _physicsCallback { nullptr };
|
|
||||||
|
|
||||||
float _displayNameTargetAlpha { 1.0f };
|
float _displayNameTargetAlpha { 1.0f };
|
||||||
float _displayNameAlpha { 1.0f };
|
float _displayNameAlpha { 1.0f };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue