mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 15:50:37 +02:00
git rid of unneeded bump code. re-indent billiards.js and rez in balls with some y velocity so they fall to the table
This commit is contained in:
parent
864f8cb3b3
commit
5a7f8a2f5a
4 changed files with 145 additions and 177 deletions
|
@ -114,12 +114,16 @@ function makeBalls(pos) {
|
|||
for (var spot = 0; spot < row; spot++) {
|
||||
balls.push(Entities.addEntity(
|
||||
{ type: "Model",
|
||||
modelURL: "https://s3.amazonaws.com/hifi-public/models/props/Pool/ball_" + whichBall[ballNumber].toString() + ".fbx",
|
||||
modelURL: "https://s3.amazonaws.com/hifi-public/models/props/Pool/ball_" +
|
||||
whichBall[ballNumber].toString() + ".fbx",
|
||||
position: ballPosition,
|
||||
dimensions: { x: BALL_SIZE * SCALE, y: BALL_SIZE * SCALE, z: BALL_SIZE * SCALE },
|
||||
rotation: Quat.fromPitchYawRollDegrees((Math.random() - 0.5) * 20, (Math.random() - 0.5) * 20, (Math.random() - 0.5) * 20),
|
||||
rotation: Quat.fromPitchYawRollDegrees((Math.random() - 0.5) * 20,
|
||||
(Math.random() - 0.5) * 20,
|
||||
(Math.random() - 0.5) * 20),
|
||||
color: { red: 255, green: 255, blue: 255 },
|
||||
gravity: { x: 0, y: GRAVITY, z: 0 },
|
||||
velocity: {x: 0, y: -0.2, z: 0 },
|
||||
ignoreCollisions: false,
|
||||
damping: 0.50,
|
||||
shapeType: "sphere",
|
||||
|
@ -140,7 +144,7 @@ function makeBalls(pos) {
|
|||
color: { red: 255, green: 255, blue: 255 },
|
||||
gravity: { x: 0, y: GRAVITY, z: 0 },
|
||||
angularVelocity: { x: 0, y: 0, z: 0 },
|
||||
velocity: {x: 0, y: 0, z: 0 },
|
||||
velocity: {x: 0, y: -0.2, z: 0 },
|
||||
ignoreCollisions: false,
|
||||
damping: 0.50,
|
||||
shapeType: "sphere",
|
||||
|
|
|
@ -65,16 +65,19 @@ void setSimId(EntityItemProperties& propertiesWithSimID, EntityItem* entity) {
|
|||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
const QUuid myNodeID = nodeList->getSessionUUID();
|
||||
|
||||
// if this entity has non-zero physics/simulation related values, claim simulation ownership
|
||||
if (propertiesWithSimID.velocityChanged() ||
|
||||
propertiesWithSimID.rotationChanged() ||
|
||||
propertiesWithSimID.containsPositionChange()) {
|
||||
// // if this entity has non-zero physics/simulation related values, claim simulation ownership
|
||||
// if (propertiesWithSimID.velocityChanged() ||
|
||||
// propertiesWithSimID.rotationChanged() ||
|
||||
// propertiesWithSimID.containsPositionChange()) {
|
||||
// propertiesWithSimID.setSimulatorID(myNodeID);
|
||||
// entity->setSimulatorID(myNodeID);
|
||||
// } else if (entity->getSimulatorID() == myNodeID) {
|
||||
// propertiesWithSimID.setSimulatorID(QUuid()); // give up simulation ownership
|
||||
// entity->setSimulatorID(QUuid());
|
||||
// }
|
||||
|
||||
propertiesWithSimID.setSimulatorID(myNodeID);
|
||||
entity->setSimulatorID(myNodeID);
|
||||
} else if (entity->getSimulatorID() == myNodeID) {
|
||||
propertiesWithSimID.setSimulatorID(QUuid()); // give up simulation ownership
|
||||
entity->setSimulatorID(QUuid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -366,45 +366,6 @@ void PhysicsEngine::stepNonPhysicalKinematics(const quint64& now) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void PhysicsEngine::bump(EntityItem* bumpEntity) {
|
||||
// If this node is doing something like deleting an entity, scan for contacts involving the
|
||||
// entity. For each found, flag the other entity involved as being simulated by this node.
|
||||
lock();
|
||||
int numManifolds = _collisionDispatcher->getNumManifolds();
|
||||
for (int i = 0; i < numManifolds; ++i) {
|
||||
btPersistentManifold* contactManifold = _collisionDispatcher->getManifoldByIndexInternal(i);
|
||||
if (contactManifold->getNumContacts() > 0) {
|
||||
const btCollisionObject* objectA = static_cast<const btCollisionObject*>(contactManifold->getBody0());
|
||||
const btCollisionObject* objectB = static_cast<const btCollisionObject*>(contactManifold->getBody1());
|
||||
if (objectA && objectB) {
|
||||
void* a = objectA->getUserPointer();
|
||||
void* b = objectB->getUserPointer();
|
||||
if (a && b) {
|
||||
EntityItem* entityA = a ? static_cast<EntityMotionState*>(a)->getEntity() : NULL;
|
||||
EntityItem* entityB = b ? static_cast<EntityMotionState*>(b)->getEntity() : NULL;
|
||||
if (entityA && entityB) {
|
||||
if (entityA == bumpEntity) {
|
||||
entityB->setShouldClaimSimulationOwnership(true);
|
||||
if (!objectB->isActive()) {
|
||||
objectB->setActivationState(ACTIVE_TAG);
|
||||
}
|
||||
}
|
||||
if (entityB == bumpEntity) {
|
||||
entityA->setShouldClaimSimulationOwnership(true);
|
||||
if (!objectA->isActive()) {
|
||||
objectA->setActivationState(ACTIVE_TAG);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
|
||||
|
||||
void PhysicsEngine::computeCollisionEvents() {
|
||||
BT_PROFILE("computeCollisionEvents");
|
||||
|
||||
|
@ -570,9 +531,10 @@ void PhysicsEngine::addObject(const ShapeInfo& shapeInfo, btCollisionShape* shap
|
|||
|
||||
void PhysicsEngine::removeObjectFromBullet(ObjectMotionState* motionState) {
|
||||
assert(motionState);
|
||||
EntityItem* entity = static_cast<EntityMotionState*>(motionState)->getEntity();
|
||||
bump(entity);
|
||||
btRigidBody* body = motionState->getRigidBody();
|
||||
// set the about-to-be-deleted entity active in order to wake up the island it's part of. this is done
|
||||
// so that anything resting on top of it will fall.
|
||||
body->setActivationState(ACTIVE_TAG);
|
||||
if (body) {
|
||||
const btCollisionShape* shape = body->getCollisionShape();
|
||||
_dynamicsWorld->removeRigidBody(body);
|
||||
|
|
|
@ -98,7 +98,6 @@ private:
|
|||
// return 'true' of update was successful
|
||||
bool updateObjectHard(btRigidBody* body, ObjectMotionState* motionState, uint32_t flags);
|
||||
void updateObjectEasy(btRigidBody* body, ObjectMotionState* motionState, uint32_t flags);
|
||||
void bump(EntityItem* bumpEntity);
|
||||
|
||||
btClock _clock;
|
||||
btDefaultCollisionConfiguration* _collisionConfig = NULL;
|
||||
|
|
Loading…
Reference in a new issue