mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-04 12:58:46 +02:00
interface/src/avatar: cppcheck fixes
This commit is contained in:
parent
54cc49283c
commit
1e94d9bdf5
12 changed files with 25 additions and 26 deletions
|
@ -36,11 +36,11 @@ var AUDIO_LISTENER_MODE_CUSTOM = "Audio from custom position";
|
||||||
|
|
||||||
// be sure that the audio listener options are in the right order (same as the enumerator)
|
// be sure that the audio listener options are in the right order (same as the enumerator)
|
||||||
var AUDIO_LISTENER_OPTIONS = [
|
var AUDIO_LISTENER_OPTIONS = [
|
||||||
// MyAvatar.FROM_HEAD (0)
|
// MyAvatar.audioListenerModeHead (0)
|
||||||
AUDIO_LISTENER_MODE_FROM_HEAD,
|
AUDIO_LISTENER_MODE_FROM_HEAD,
|
||||||
// MyAvatar.FROM_CAMERA (1)
|
// MyAvatar.audioListenerModeCamera (1)
|
||||||
AUDIO_LISTENER_MODE_FROM_CAMERA,
|
AUDIO_LISTENER_MODE_FROM_CAMERA,
|
||||||
// MyAvatar.CUSTOM (2)
|
// MyAvatar.audioListenerCustom (2)
|
||||||
AUDIO_LISTENER_MODE_CUSTOM
|
AUDIO_LISTENER_MODE_CUSTOM
|
||||||
];
|
];
|
||||||
var AUDIO_STEREO_INPUT = "Stereo Input";
|
var AUDIO_STEREO_INPUT = "Stereo Input";
|
||||||
|
|
|
@ -972,7 +972,6 @@ void Avatar::renderJointConnectingCone(gpu::Batch& batch, glm::vec3 position1, g
|
||||||
glm::vec3 perpCos = glm::normalize(glm::cross(axis, perpSin));
|
glm::vec3 perpCos = glm::normalize(glm::cross(axis, perpSin));
|
||||||
perpSin = glm::cross(perpCos, axis);
|
perpSin = glm::cross(perpCos, axis);
|
||||||
|
|
||||||
float anglea = 0.0f;
|
|
||||||
float angleb = 0.0f;
|
float angleb = 0.0f;
|
||||||
QVector<glm::vec3> points;
|
QVector<glm::vec3> points;
|
||||||
|
|
||||||
|
@ -980,7 +979,7 @@ void Avatar::renderJointConnectingCone(gpu::Batch& batch, glm::vec3 position1, g
|
||||||
|
|
||||||
// the rectangles that comprise the sides of the cone section are
|
// the rectangles that comprise the sides of the cone section are
|
||||||
// referenced by "a" and "b" in one dimension, and "1", and "2" in the other dimension.
|
// referenced by "a" and "b" in one dimension, and "1", and "2" in the other dimension.
|
||||||
anglea = angleb;
|
int anglea = angleb;
|
||||||
angleb = ((float)(i+1) / (float)NUM_BODY_CONE_SIDES) * TWO_PI;
|
angleb = ((float)(i+1) / (float)NUM_BODY_CONE_SIDES) * TWO_PI;
|
||||||
|
|
||||||
float sa = sinf(anglea);
|
float sa = sinf(anglea);
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Avatar : public AvatarData {
|
||||||
Q_PROPERTY(glm::vec3 skeletonOffset READ getSkeletonOffset WRITE setSkeletonOffset)
|
Q_PROPERTY(glm::vec3 skeletonOffset READ getSkeletonOffset WRITE setSkeletonOffset)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Avatar(RigPointer rig = nullptr);
|
explicit Avatar(RigPointer rig = nullptr);
|
||||||
~Avatar();
|
~Avatar();
|
||||||
|
|
||||||
typedef render::Payload<AvatarData> Payload;
|
typedef render::Payload<AvatarData> Payload;
|
||||||
|
|
|
@ -308,7 +308,6 @@ bool AvatarActionHold::updateArguments(QVariantMap arguments) {
|
||||||
hand = _hand;
|
hand = _hand;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = true;
|
|
||||||
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||||
holderID = myAvatar->getSessionUUID();
|
holderID = myAvatar->getSessionUUID();
|
||||||
|
|
||||||
|
|
|
@ -63,11 +63,11 @@ void AvatarManager::registerMetaTypes(QScriptEngine* engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarManager::AvatarManager(QObject* parent) :
|
AvatarManager::AvatarManager(QObject* parent) :
|
||||||
_avatarFades()
|
_avatarFades(),
|
||||||
|
_myAvatar(std::make_shared<MyAvatar>(std::make_shared<Rig>()))
|
||||||
{
|
{
|
||||||
// register a meta type for the weak pointer we'll use for the owning avatar mixer for each avatar
|
// register a meta type for the weak pointer we'll use for the owning avatar mixer for each avatar
|
||||||
qRegisterMetaType<QWeakPointer<Node> >("NodeWeakPointer");
|
qRegisterMetaType<QWeakPointer<Node> >("NodeWeakPointer");
|
||||||
_myAvatar = std::make_shared<MyAvatar>(std::make_shared<Rig>());
|
|
||||||
|
|
||||||
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
|
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
|
||||||
packetReceiver.registerListener(PacketType::BulkAvatarData, this, "processAvatarDataPacket");
|
packetReceiver.registerListener(PacketType::BulkAvatarData, this, "processAvatarDataPacket");
|
||||||
|
|
|
@ -71,8 +71,8 @@ public slots:
|
||||||
void updateAvatarRenderStatus(bool shouldRenderAvatars);
|
void updateAvatarRenderStatus(bool shouldRenderAvatars);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AvatarManager(QObject* parent = 0);
|
explicit AvatarManager(QObject* parent = 0);
|
||||||
AvatarManager(const AvatarManager& other);
|
explicit AvatarManager(const AvatarManager& other);
|
||||||
|
|
||||||
void simulateAvatarFades(float deltaTime);
|
void simulateAvatarFades(float deltaTime);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <display-plugins/DisplayPlugin.h>
|
#include <display-plugins/DisplayPlugin.h>
|
||||||
#include "InterfaceLogging.h"
|
#include "InterfaceLogging.h"
|
||||||
|
|
||||||
AvatarUpdate::AvatarUpdate() : GenericThread(), _lastAvatarUpdate(0) {
|
AvatarUpdate::AvatarUpdate() : GenericThread(), _lastAvatarUpdate(0), _isHMDMode(false) {
|
||||||
setObjectName("Avatar Update"); // GenericThread::initialize uses this to set the thread name.
|
setObjectName("Avatar Update"); // GenericThread::initialize uses this to set the thread name.
|
||||||
Settings settings;
|
Settings settings;
|
||||||
const int DEFAULT_TARGET_AVATAR_SIMRATE = 60;
|
const int DEFAULT_TARGET_AVATAR_SIMRATE = 60;
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Avatar;
|
||||||
|
|
||||||
class Head : public HeadData {
|
class Head : public HeadData {
|
||||||
public:
|
public:
|
||||||
Head(Avatar* owningAvatar);
|
explicit Head(Avatar* owningAvatar);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
|
@ -1522,9 +1522,9 @@ glm::vec3 MyAvatar::applyKeyboardMotor(float deltaTime, const glm::vec3& localVe
|
||||||
// (1) braking --> short timescale (aggressive motor assertion)
|
// (1) braking --> short timescale (aggressive motor assertion)
|
||||||
// (2) pushing --> medium timescale (mild motor assertion)
|
// (2) pushing --> medium timescale (mild motor assertion)
|
||||||
// (3) inactive --> long timescale (gentle friction for low speeds)
|
// (3) inactive --> long timescale (gentle friction for low speeds)
|
||||||
float MIN_KEYBOARD_MOTOR_TIMESCALE = 0.125f;
|
const float MIN_KEYBOARD_MOTOR_TIMESCALE = 0.125f;
|
||||||
float MAX_KEYBOARD_MOTOR_TIMESCALE = 0.4f;
|
const float MAX_KEYBOARD_MOTOR_TIMESCALE = 0.4f;
|
||||||
float MIN_KEYBOARD_BRAKE_SPEED = 0.3f;
|
const float MIN_KEYBOARD_BRAKE_SPEED = 0.3f;
|
||||||
float timescale = MAX_KEYBOARD_MOTOR_TIMESCALE;
|
float timescale = MAX_KEYBOARD_MOTOR_TIMESCALE;
|
||||||
bool isThrust = (glm::length2(_thrust) > EPSILON);
|
bool isThrust = (glm::length2(_thrust) > EPSILON);
|
||||||
if (_isPushing || isThrust ||
|
if (_isPushing || isThrust ||
|
||||||
|
|
|
@ -63,9 +63,9 @@ class MyAvatar : public Avatar {
|
||||||
Q_PROPERTY(AudioListenerMode audioListenerMode READ getAudioListenerMode WRITE setAudioListenerMode)
|
Q_PROPERTY(AudioListenerMode audioListenerMode READ getAudioListenerMode WRITE setAudioListenerMode)
|
||||||
Q_PROPERTY(glm::vec3 customListenPosition READ getCustomListenPosition WRITE setCustomListenPosition)
|
Q_PROPERTY(glm::vec3 customListenPosition READ getCustomListenPosition WRITE setCustomListenPosition)
|
||||||
Q_PROPERTY(glm::quat customListenOrientation READ getCustomListenOrientation WRITE setCustomListenOrientation)
|
Q_PROPERTY(glm::quat customListenOrientation READ getCustomListenOrientation WRITE setCustomListenOrientation)
|
||||||
Q_PROPERTY(AudioListenerMode FROM_HEAD READ getAudioListenerModeHead)
|
Q_PROPERTY(AudioListenerMode audioListenerModeHead READ getAudioListenerModeHead)
|
||||||
Q_PROPERTY(AudioListenerMode FROM_CAMERA READ getAudioListenerModeCamera)
|
Q_PROPERTY(AudioListenerMode audioListenerModeCamera READ getAudioListenerModeCamera)
|
||||||
Q_PROPERTY(AudioListenerMode CUSTOM READ getAudioListenerModeCustom)
|
Q_PROPERTY(AudioListenerMode audioListenerModeCustom READ getAudioListenerModeCustom)
|
||||||
//TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
|
//TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class MyAvatar : public Avatar {
|
||||||
Q_PROPERTY(float energy READ getEnergy WRITE setEnergy)
|
Q_PROPERTY(float energy READ getEnergy WRITE setEnergy)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MyAvatar(RigPointer rig);
|
explicit MyAvatar(RigPointer rig);
|
||||||
~MyAvatar();
|
~MyAvatar();
|
||||||
|
|
||||||
virtual void simulateAttachments(float deltaTime) override;
|
virtual void simulateAttachments(float deltaTime) override;
|
||||||
|
|
|
@ -46,14 +46,15 @@ void MyCharacterController::updateShapeIfNecessary() {
|
||||||
// NOTE: _shapeLocalOffset is already computed
|
// NOTE: _shapeLocalOffset is already computed
|
||||||
|
|
||||||
if (_radius > 0.0f) {
|
if (_radius > 0.0f) {
|
||||||
// HACK: use some simple mass property defaults for now
|
|
||||||
float mass = 100.0f;
|
|
||||||
btVector3 inertia(30.0f, 8.0f, 30.0f);
|
|
||||||
|
|
||||||
// create RigidBody if it doesn't exist
|
// create RigidBody if it doesn't exist
|
||||||
if (!_rigidBody) {
|
if (!_rigidBody) {
|
||||||
|
|
||||||
|
// HACK: use some simple mass property defaults for now
|
||||||
|
const float DEFAULT_AVATAR_MASS = 100.0f;
|
||||||
|
const btVector3 DEFAULT_AVATAR_INERTIA_TENSOR(30.0f, 8.0f, 30.0f);
|
||||||
|
|
||||||
btCollisionShape* shape = new btCapsuleShape(_radius, 2.0f * _halfHeight);
|
btCollisionShape* shape = new btCapsuleShape(_radius, 2.0f * _halfHeight);
|
||||||
_rigidBody = new btRigidBody(mass, nullptr, shape, inertia);
|
_rigidBody = new btRigidBody(DEFAULT_AVATAR_MASS, nullptr, shape, DEFAULT_AVATAR_INERTIA_TENSOR);
|
||||||
} else {
|
} else {
|
||||||
btCollisionShape* shape = _rigidBody->getCollisionShape();
|
btCollisionShape* shape = _rigidBody->getCollisionShape();
|
||||||
if (shape) {
|
if (shape) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ class MyAvatar;
|
||||||
|
|
||||||
class MyCharacterController : public CharacterController {
|
class MyCharacterController : public CharacterController {
|
||||||
public:
|
public:
|
||||||
MyCharacterController(MyAvatar* avatar);
|
explicit MyCharacterController(MyAvatar* avatar);
|
||||||
~MyCharacterController ();
|
~MyCharacterController ();
|
||||||
|
|
||||||
virtual void updateShapeIfNecessary() override;
|
virtual void updateShapeIfNecessary() override;
|
||||||
|
|
Loading…
Reference in a new issue