mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-15 06:20:34 +02:00
52 lines
1.8 KiB
C++
52 lines
1.8 KiB
C++
//
|
|
// CharacterControllerInterface.cpp
|
|
// libraries/physcis/src
|
|
//
|
|
// Created by Andrew Meadows 2015.10.21
|
|
// Copyright 2015 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
#include "CharacterController.h"
|
|
|
|
#include "PhysicsCollisionGroups.h"
|
|
|
|
bool CharacterController::needsRemoval() const {
|
|
return ((_pendingFlags & PENDING_FLAG_REMOVE_FROM_SIMULATION) == PENDING_FLAG_REMOVE_FROM_SIMULATION);
|
|
}
|
|
|
|
bool CharacterController::needsAddition() const {
|
|
return ((_pendingFlags & PENDING_FLAG_ADD_TO_SIMULATION) == PENDING_FLAG_ADD_TO_SIMULATION);
|
|
}
|
|
|
|
void CharacterController::setDynamicsWorld(btDynamicsWorld* world) {
|
|
if (_dynamicsWorld != world) {
|
|
if (_dynamicsWorld) {
|
|
if (_rigidBody) {
|
|
_dynamicsWorld->removeRigidBody(_rigidBody);
|
|
_dynamicsWorld->removeAction(this);
|
|
}
|
|
_dynamicsWorld = nullptr;
|
|
}
|
|
if (world && _rigidBody) {
|
|
_dynamicsWorld = world;
|
|
_pendingFlags &= ~PENDING_FLAG_JUMP;
|
|
_dynamicsWorld->addRigidBody(_rigidBody, COLLISION_GROUP_MY_AVATAR, COLLISION_MASK_MY_AVATAR);
|
|
_dynamicsWorld->addAction(this);
|
|
//reset(_dynamicsWorld);
|
|
}
|
|
}
|
|
if (_dynamicsWorld) {
|
|
if (_pendingFlags & PENDING_FLAG_UPDATE_SHAPE) {
|
|
// shouldn't fall in here, but if we do make sure both ADD and REMOVE bits are still set
|
|
_pendingFlags |= PENDING_FLAG_ADD_TO_SIMULATION | PENDING_FLAG_REMOVE_FROM_SIMULATION;
|
|
} else {
|
|
_pendingFlags &= ~PENDING_FLAG_ADD_TO_SIMULATION;
|
|
}
|
|
} else {
|
|
_pendingFlags &= ~PENDING_FLAG_REMOVE_FROM_SIMULATION;
|
|
}
|
|
}
|
|
|