mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 08:14:48 +02:00
move stuff out of shared and into physics library
This commit is contained in:
parent
4e7e9641f0
commit
4c3cdf5b7a
54 changed files with 193 additions and 63 deletions
|
@ -8,6 +8,7 @@ include_glm()
|
|||
link_hifi_libraries(
|
||||
audio avatars octree voxels fbx entities metavoxels
|
||||
networking animation shared script-engine embedded-webserver
|
||||
physics
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
|
|
|
@ -101,7 +101,7 @@ endif()
|
|||
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM})
|
||||
|
||||
# link required hifi libraries
|
||||
link_hifi_libraries(shared octree voxels fbx metavoxels networking entities avatars audio animation script-engine)
|
||||
link_hifi_libraries(shared octree voxels fbx metavoxels networking entities avatars audio animation script-engine physics)
|
||||
|
||||
# find any optional and required libraries
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
|
|
@ -655,19 +655,19 @@ void SkeletonModel::buildShapes() {
|
|||
Shape::Type type = joint.shapeType;
|
||||
int parentIndex = joint.parentIndex;
|
||||
if (parentIndex == -1 || radius < EPSILON) {
|
||||
type = UNKNOWN_SHAPE;
|
||||
} else if (type == CAPSULE_SHAPE && halfHeight < EPSILON) {
|
||||
type = SHAPE_TYPE_UNKNOWN;
|
||||
} else if (type == SHAPE_TYPE_CAPSULE && halfHeight < EPSILON) {
|
||||
// this shape is forced to be a sphere
|
||||
type = SPHERE_SHAPE;
|
||||
type = SHAPE_TYPE_SPHERE;
|
||||
}
|
||||
Shape* shape = NULL;
|
||||
if (type == SPHERE_SHAPE) {
|
||||
if (type == SHAPE_TYPE_SPHERE) {
|
||||
shape = new VerletSphereShape(radius, &(points[i]));
|
||||
shape->setEntity(this);
|
||||
float mass = massScale * glm::max(MIN_JOINT_MASS, DENSITY_OF_WATER * shape->getVolume());
|
||||
points[i].setMass(mass);
|
||||
totalMass += mass;
|
||||
} else if (type == CAPSULE_SHAPE) {
|
||||
} else if (type == SHAPE_TYPE_CAPSULE) {
|
||||
assert(parentIndex != -1);
|
||||
shape = new VerletCapsuleShape(radius, &(points[parentIndex]), &(points[i]));
|
||||
shape->setEntity(this);
|
||||
|
|
|
@ -5,8 +5,8 @@ setup_hifi_library(Network Script)
|
|||
|
||||
include_glm()
|
||||
|
||||
link_hifi_libraries(shared octree voxels networking)
|
||||
link_hifi_libraries(shared octree voxels networking physics)
|
||||
include_hifi_library_headers(fbx)
|
||||
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
||||
link_shared_dependencies()
|
||||
|
|
|
@ -5,7 +5,7 @@ setup_hifi_library(Network Script)
|
|||
|
||||
include_glm()
|
||||
|
||||
link_hifi_libraries(shared octree fbx networking animation)
|
||||
link_hifi_libraries(shared octree fbx networking animation physics)
|
||||
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <AACubeShape.h>
|
||||
#include <AnimationCache.h> // for Animation, AnimationCache, and AnimationPointer classes
|
||||
#include <CollisionInfo.h>
|
||||
#include <Octree.h> // for EncodeBitstreamParams class
|
||||
#include <OctreeElement.h> // for OctreeElement::AppendState
|
||||
#include <OctreePacketData.h>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <GeometryUtil.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include <OctalCode.h>
|
||||
#include <Shape.h>
|
||||
|
||||
#include <VoxelTree.h>
|
||||
|
||||
|
@ -1534,7 +1533,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
|||
joint.inverseBindRotation = joint.inverseDefaultRotation;
|
||||
joint.name = model.name;
|
||||
joint.shapePosition = glm::vec3(0.f);
|
||||
joint.shapeType = UNKNOWN_SHAPE;
|
||||
joint.shapeType = SHAPE_TYPE_UNKNOWN;
|
||||
|
||||
foreach (const QString& childID, childMap.values(modelID)) {
|
||||
QString type = typeFlags.value(childID);
|
||||
|
@ -1911,10 +1910,10 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
|||
if (collideLikeCapsule) {
|
||||
joint.shapeRotation = rotationBetween(defaultCapsuleAxis, jointShapeInfo.boneBegin);
|
||||
joint.shapePosition = 0.5f * jointShapeInfo.boneBegin;
|
||||
joint.shapeType = CAPSULE_SHAPE;
|
||||
joint.shapeType = SHAPE_TYPE_CAPSULE;
|
||||
} else {
|
||||
// collide the joint like a sphere
|
||||
joint.shapeType = SPHERE_SHAPE;
|
||||
joint.shapeType = SHAPE_TYPE_SPHERE;
|
||||
if (jointShapeInfo.numVertices > 0) {
|
||||
jointShapeInfo.averageVertex /= (float)jointShapeInfo.numVertices;
|
||||
joint.shapePosition = jointShapeInfo.averageVertex;
|
||||
|
@ -1934,8 +1933,8 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
|||
if (distanceFromEnd > joint.distanceToParent && distanceFromBegin > joint.distanceToParent) {
|
||||
// The shape is further from both joint endpoints than the endpoints are from each other
|
||||
// which probably means the model has a bad transform somewhere. We disable this shape
|
||||
// by setting its type to UNKNOWN_SHAPE.
|
||||
joint.shapeType = UNKNOWN_SHAPE;
|
||||
// by setting its type to SHAPE_TYPE_UNKNOWN.
|
||||
joint.shapeType = SHAPE_TYPE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
#include <QVector>
|
||||
|
||||
#include <Extents.h>
|
||||
#include <Shape.h>
|
||||
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
@ -55,6 +53,12 @@ public:
|
|||
QVector<glm::vec3> normals;
|
||||
};
|
||||
|
||||
enum ShapeType {
|
||||
SHAPE_TYPE_SPHERE = 0,
|
||||
SHAPE_TYPE_CAPSULE = 1,
|
||||
SHAPE_TYPE_UNKNOWN = 2
|
||||
};
|
||||
|
||||
/// A single joint (transformation node) extracted from an FBX document.
|
||||
class FBXJoint {
|
||||
public:
|
||||
|
@ -79,7 +83,7 @@ public:
|
|||
QString name;
|
||||
glm::vec3 shapePosition; // in joint frame
|
||||
glm::quat shapeRotation; // in joint frame
|
||||
Shape::Type shapeType;
|
||||
ShapeType shapeType;
|
||||
bool isSkeletonJoint;
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ setup_hifi_library()
|
|||
|
||||
include_glm()
|
||||
|
||||
link_hifi_libraries(shared networking)
|
||||
link_hifi_libraries(shared networking physics)
|
||||
|
||||
# find ZLIB
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
@ -16,4 +16,4 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
|
|||
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}")
|
||||
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
||||
link_shared_dependencies()
|
||||
|
|
|
@ -31,8 +31,6 @@ class Shape;
|
|||
#include "OctreePacketData.h"
|
||||
#include "OctreeSceneStats.h"
|
||||
|
||||
#include <CollisionInfo.h>
|
||||
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
#include <QReadWriteLock>
|
||||
|
|
19
libraries/physics/CMakeLists.txt
Normal file
19
libraries/physics/CMakeLists.txt
Normal file
|
@ -0,0 +1,19 @@
|
|||
set(TARGET_NAME physics)
|
||||
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library()
|
||||
|
||||
include_glm()
|
||||
|
||||
link_hifi_libraries(shared)
|
||||
|
||||
## find BULLET
|
||||
#find_package(BULLET REQUIRED)
|
||||
#
|
||||
#include_directories(SYSTEM "${BULLET_INCLUDE_DIRS}")
|
||||
#
|
||||
## append BULLET to our list of libraries to link
|
||||
#list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${BULLET_LIBRARIES}")
|
||||
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
|
@ -13,7 +13,7 @@
|
|||
#include <glm/gtx/norm.hpp>
|
||||
|
||||
#include "AACubeShape.h"
|
||||
#include "SharedUtil.h" // for SQUARE_ROOT_OF_3
|
||||
#include <SharedUtil.h> // for SQUARE_ROOT_OF_3
|
||||
|
||||
glm::vec3 faceNormals[3] = { glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f) };
|
||||
|
|
@ -12,10 +12,10 @@
|
|||
#include <iostream>
|
||||
#include <glm/gtx/vector_angle.hpp>
|
||||
|
||||
#include "CapsuleShape.h"
|
||||
#include <GeometryUtil.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "GeometryUtil.h"
|
||||
#include "SharedUtil.h"
|
||||
#include "CapsuleShape.h"
|
||||
|
||||
|
||||
CapsuleShape::CapsuleShape() : Shape(CAPSULE_SHAPE), _radius(0.0f), _halfHeight(0.0f) {}
|
|
@ -12,9 +12,9 @@
|
|||
#ifndef hifi_CapsuleShape_h
|
||||
#define hifi_CapsuleShape_h
|
||||
|
||||
#include "Shape.h"
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "SharedUtil.h"
|
||||
#include "Shape.h"
|
||||
|
||||
// default axis of CapsuleShape is Y-axis
|
||||
const glm::vec3 DEFAULT_CAPSULE_AXIS(0.0f, 1.0f, 0.0f);
|
|
@ -9,10 +9,11 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "CollisionInfo.h"
|
||||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "CollisionInfo.h"
|
||||
#include "Shape.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
CollisionInfo::CollisionInfo() :
|
||||
_data(NULL),
|
53
libraries/physics/src/ContactConstraint.cpp
Normal file
53
libraries/physics/src/ContactConstraint.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
//
|
||||
// ContactConstraint.cpp
|
||||
// interface/src/avatar
|
||||
//
|
||||
// Created by Andrew Meadows 2014.07.24
|
||||
// Copyright 2014 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 <SharedUtil.h>
|
||||
|
||||
#include "ContactConstraint.h"
|
||||
#include "VerletPoint.h"
|
||||
|
||||
|
||||
ContactConstraint::ContactConstraint(VerletPoint* pointA, VerletPoint* pointB)
|
||||
: _pointA(pointA), _pointB(pointB), _strength(1.0f) {
|
||||
assert(_pointA != NULL && _pointB != NULL);
|
||||
_offset = _pointB->_position - _pointA->_position;
|
||||
}
|
||||
|
||||
float ContactConstraint::enforce() {
|
||||
_pointB->_position += _strength * (_pointA->_position + _offset - _pointB->_position);
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float ContactConstraint::enforceWithNormal(const glm::vec3& normal) {
|
||||
glm::vec3 delta = _pointA->_position + _offset - _pointB->_position;
|
||||
|
||||
// split delta into parallel (pDelta) and perpendicular (qDelta) components
|
||||
glm::vec3 pDelta = glm::dot(delta, normal) * normal;
|
||||
glm::vec3 qDelta = delta - pDelta;
|
||||
|
||||
// use the relative sizes of the components to decide how much perpenducular delta to use
|
||||
// (i.e. dynamic friction)
|
||||
float lpDelta = glm::length(pDelta);
|
||||
float lqDelta = glm::length(qDelta);
|
||||
float qFactor = lqDelta > lpDelta ? (lpDelta / lqDelta - 1.0f) : 0.0f;
|
||||
// recombine the two components to get the final delta
|
||||
delta = pDelta + qFactor * qDelta;
|
||||
|
||||
// attenuate strength by how much _offset is perpendicular to normal
|
||||
float distance = glm::length(_offset);
|
||||
float strength = _strength * ((distance > EPSILON) ? glm::abs(glm::dot(_offset, normal)) / distance : 1.0f);
|
||||
|
||||
// move _pointB
|
||||
_pointB->_position += strength * delta;
|
||||
|
||||
return strength * glm::length(delta);
|
||||
}
|
||||
|
39
libraries/physics/src/ContactConstraint.h
Normal file
39
libraries/physics/src/ContactConstraint.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// ContactConstraint.h
|
||||
// interface/src/avatar
|
||||
//
|
||||
// Created by Andrew Meadows 2014.07.24
|
||||
// Copyright 2014 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
|
||||
//
|
||||
|
||||
#ifndef hifi_ContactConstraint_h
|
||||
#define hifi_ContactConstraint_h
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "Constraint.h"
|
||||
#include "VerletPoint.h"
|
||||
|
||||
class ContactConstraint : public Constraint {
|
||||
public:
|
||||
ContactConstraint(VerletPoint* pointA, VerletPoint* pointB);
|
||||
|
||||
float enforce();
|
||||
float enforceWithNormal(const glm::vec3& normal);
|
||||
|
||||
glm::vec3 getTargetPointA() const { return _pointB->_position - _offset; }
|
||||
|
||||
void setOffset(const glm::vec3& offset) { _offset = offset; }
|
||||
void setStrength(float strength) { _strength = glm::clamp(strength, 0.0f, 1.0f); }
|
||||
float getStrength() const { return _strength; }
|
||||
private:
|
||||
VerletPoint* _pointA;
|
||||
VerletPoint* _pointB;
|
||||
glm::vec3 _offset; // from pointA toward pointB
|
||||
float _strength; // a value in range [0,1]
|
||||
};
|
||||
|
||||
#endif // hifi_ContactConstraint_h
|
|
@ -9,9 +9,10 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "ContactPoint.h"
|
||||
#include "Shape.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
// This parameter helps keep the actual point of contact slightly inside each shape
|
||||
// which allows the collisions to happen almost every frame for more frequent updates.
|
|
@ -9,8 +9,9 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <SharedUtil.h> // for EPSILON
|
||||
|
||||
#include "DistanceConstraint.h"
|
||||
#include "SharedUtil.h" // for EPSILON
|
||||
#include "VerletPoint.h"
|
||||
|
||||
DistanceConstraint::DistanceConstraint(VerletPoint* startPoint, VerletPoint* endPoint) : _distance(-1.0f) {
|
|
@ -11,14 +11,14 @@
|
|||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "PhysicsSimulation.h"
|
||||
#include <PerfStat.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "PerfStat.h"
|
||||
#include "PhysicsSimulation.h"
|
||||
#include "PhysicsEntity.h"
|
||||
#include "Ragdoll.h"
|
||||
#include "Shape.h"
|
||||
#include "ShapeCollider.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
int MAX_DOLLS_PER_SIMULATION = 16;
|
||||
int MAX_ENTITIES_PER_SIMULATION = 64;
|
|
@ -9,9 +9,10 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <SharedUtil.h>
|
||||
#include <GLMHelpers.h>
|
||||
|
||||
#include "PlaneShape.h"
|
||||
#include "SharedUtil.h"
|
||||
#include "GLMHelpers.h"
|
||||
|
||||
const glm::vec3 UNROTATED_NORMAL(0.0f, 1.0f, 0.0f);
|
||||
|
|
@ -11,13 +11,14 @@
|
|||
|
||||
#include <glm/gtx/norm.hpp>
|
||||
|
||||
#include <SharedUtil.h> // for EPSILON
|
||||
|
||||
#include "Ragdoll.h"
|
||||
|
||||
#include "Constraint.h"
|
||||
#include "DistanceConstraint.h"
|
||||
#include "FixedConstraint.h"
|
||||
#include "PhysicsSimulation.h"
|
||||
#include "SharedUtil.h" // for EPSILON
|
||||
|
||||
Ragdoll::Ragdoll() : _massScale(1.0f), _translation(0.0f), _translationInSimulationFrame(0.0f),
|
||||
_rootIndex(0), _accumulatedMovement(0.0f), _simulation(NULL) {
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#include "VerletPoint.h"
|
||||
|
||||
#include <QVector>
|
||||
|
||||
#include "VerletPoint.h"
|
||||
//#include "PhysicsSimulation.h"
|
||||
|
||||
class DistanceConstraint;
|
|
@ -11,16 +11,17 @@
|
|||
|
||||
#include <glm/gtx/norm.hpp>
|
||||
|
||||
#include <GeometryUtil.h>
|
||||
#include <StreamUtils.h>
|
||||
|
||||
#include "ShapeCollider.h"
|
||||
|
||||
#include "AACubeShape.h"
|
||||
#include "CapsuleShape.h"
|
||||
#include "GeometryUtil.h"
|
||||
#include "ListShape.h"
|
||||
#include "PlaneShape.h"
|
||||
#include "SphereShape.h"
|
||||
|
||||
#include "StreamUtils.h"
|
||||
|
||||
// NOTE:
|
||||
//
|
|
@ -14,9 +14,10 @@
|
|||
|
||||
#include <QVector>
|
||||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "CollisionInfo.h"
|
||||
#include "RayIntersectionInfo.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
class Shape;
|
||||
class SphereShape;
|
|
@ -12,9 +12,10 @@
|
|||
#ifndef hifi_SphereShape_h
|
||||
#define hifi_SphereShape_h
|
||||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "Shape.h"
|
||||
|
||||
#include "SharedUtil.h"
|
||||
|
||||
class SphereShape : public Shape {
|
||||
public:
|
|
@ -9,10 +9,11 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "VerletCapsuleShape.h"
|
||||
|
||||
#include "Ragdoll.h" // for VerletPoint
|
||||
#include "SharedUtil.h"
|
||||
#include "VerletPoint.h"
|
||||
|
||||
VerletCapsuleShape::VerletCapsuleShape(VerletPoint* startPoint, VerletPoint* endPoint) :
|
||||
CapsuleShape(), _startPoint(startPoint), _endPoint(endPoint), _startLagrangeCoef(0.5f), _endLagrangeCoef(0.5f) {
|
|
@ -5,7 +5,7 @@ setup_hifi_library(Gui Network Script Widgets)
|
|||
|
||||
include_glm()
|
||||
|
||||
link_hifi_libraries(shared octree voxels fbx entities animation audio)
|
||||
link_hifi_libraries(shared octree voxels fbx entities animation audio physics)
|
||||
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
|
||||
#include <glm/gtx/norm.hpp>
|
||||
|
||||
#include "GLMHelpers.h"
|
||||
|
||||
#include "AngularConstraint.h"
|
||||
#include "GLMHelpers.h"
|
||||
|
||||
// helper function
|
||||
/// \param angle radian angle to be clamped within angleMin and angleMax
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include <QUrl>
|
||||
#include <QUuid>
|
||||
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include "RegisteredMetaTypes.h"
|
||||
|
||||
static int vec4MetaTypeId = qRegisterMetaType<glm::vec4>();
|
||||
|
@ -21,7 +23,7 @@ static int vec2MetaTypeId = qRegisterMetaType<glm::vec2>();
|
|||
static int quatMetaTypeId = qRegisterMetaType<glm::quat>();
|
||||
static int xColorMetaTypeId = qRegisterMetaType<xColor>();
|
||||
static int pickRayMetaTypeId = qRegisterMetaType<PickRay>();
|
||||
static int collisionMetaTypeId = qRegisterMetaType<CollisionInfo>();
|
||||
static int collisionMetaTypeId = qRegisterMetaType<Collision>();
|
||||
|
||||
void registerMetaTypes(QScriptEngine* engine) {
|
||||
qScriptRegisterMetaType(engine, vec4toScriptValue, vec4FromScriptValue);
|
||||
|
@ -163,14 +165,14 @@ void pickRayFromScriptValue(const QScriptValue& object, PickRay& pickRay) {
|
|||
}
|
||||
}
|
||||
|
||||
QScriptValue collisionToScriptValue(QScriptEngine* engine, const CollisionInfo& collision) {
|
||||
QScriptValue collisionToScriptValue(QScriptEngine* engine, const Collision& collision) {
|
||||
QScriptValue obj = engine->newObject();
|
||||
obj.setProperty("penetration", vec3toScriptValue(engine, collision._penetration));
|
||||
obj.setProperty("contactPoint", vec3toScriptValue(engine, collision._contactPoint));
|
||||
obj.setProperty("penetration", vec3toScriptValue(engine, collision.penetration));
|
||||
obj.setProperty("contactPoint", vec3toScriptValue(engine, collision.contactPoint));
|
||||
return obj;
|
||||
}
|
||||
|
||||
void collisionFromScriptValue(const QScriptValue &object, CollisionInfo& collision) {
|
||||
void collisionFromScriptValue(const QScriptValue &object, Collision& collision) {
|
||||
// TODO: implement this when we know what it means to accept collision events from JS
|
||||
}
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
#ifndef hifi_RegisteredMetaTypes_h
|
||||
#define hifi_RegisteredMetaTypes_h
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <QtScript/QScriptEngine>
|
||||
|
||||
#include "CollisionInfo.h"
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include "SharedUtil.h"
|
||||
|
||||
class QColor;
|
||||
|
@ -53,7 +53,7 @@ void qURLFromScriptValue(const QScriptValue& object, QUrl& url);
|
|||
|
||||
class PickRay {
|
||||
public:
|
||||
PickRay() : origin(0), direction(0) { };
|
||||
PickRay() : origin(0.0f), direction(0.0f) { }
|
||||
glm::vec3 origin;
|
||||
glm::vec3 direction;
|
||||
};
|
||||
|
@ -61,9 +61,15 @@ Q_DECLARE_METATYPE(PickRay)
|
|||
QScriptValue pickRayToScriptValue(QScriptEngine* engine, const PickRay& pickRay);
|
||||
void pickRayFromScriptValue(const QScriptValue& object, PickRay& pickRay);
|
||||
|
||||
Q_DECLARE_METATYPE(CollisionInfo)
|
||||
QScriptValue collisionToScriptValue(QScriptEngine* engine, const CollisionInfo& collision);
|
||||
void collisionFromScriptValue(const QScriptValue &object, CollisionInfo& collision);
|
||||
class Collision {
|
||||
public:
|
||||
Collision() : contactPoint(0.0f), penetration(0.0f) { }
|
||||
glm::vec3 contactPoint;
|
||||
glm::vec3 penetration;
|
||||
};
|
||||
Q_DECLARE_METATYPE(Collision)
|
||||
QScriptValue collisionToScriptValue(QScriptEngine* engine, const Collision& collision);
|
||||
void collisionFromScriptValue(const QScriptValue &object, Collision& collision);
|
||||
|
||||
//Q_DECLARE_METATYPE(QUuid) // don't need to do this for QUuid since it's already a meta type
|
||||
QScriptValue quuidToScriptValue(QScriptEngine* engine, const QUuid& uuid);
|
||||
|
|
|
@ -5,6 +5,6 @@ setup_hifi_project(Script Network)
|
|||
include_glm()
|
||||
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(shared octree voxels fbx metavoxels networking entities avatars audio animation script-engine)
|
||||
link_hifi_libraries(shared octree voxels fbx metavoxels networking entities avatars audio animation script-engine physics)
|
||||
|
||||
link_shared_dependencies()
|
||||
|
|
|
@ -5,6 +5,6 @@ setup_hifi_project()
|
|||
include_glm()
|
||||
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(shared)
|
||||
link_hifi_libraries(shared physics)
|
||||
|
||||
link_shared_dependencies()
|
||||
link_shared_dependencies()
|
||||
|
|
Loading…
Reference in a new issue