Started working on dialogue
This commit is contained in:
@@ -269,11 +269,13 @@ public:
|
||||
void DrawLine(JPH::RVec3Arg inFrom, JPH::RVec3Arg inTo,
|
||||
JPH::ColorArg inColor) override
|
||||
{
|
||||
JPH::Vec4 color = inColor.ToVec4();
|
||||
mLines.push_back({ { inFrom[0], inFrom[1], inFrom[2] },
|
||||
{ inTo[0], inTo[1], inTo[2] },
|
||||
Ogre::ColourValue(color[0], color[1],
|
||||
color[2], color[3]) });
|
||||
JPH::Vec4 color = inColor.ToVec4();
|
||||
mLines.push_back(
|
||||
{ { (float)inFrom[0], (float)inFrom[1],
|
||||
(float)inFrom[2] },
|
||||
{ (float)inTo[0], (float)inTo[1], (float)inTo[2] },
|
||||
Ogre::ColourValue(color[0], color[1], color[2],
|
||||
color[3]) });
|
||||
}
|
||||
void DrawTriangle(JPH::RVec3Arg inV1, JPH::RVec3Arg inV2,
|
||||
JPH::RVec3Arg inV3, JPH::ColorArg inColor,
|
||||
@@ -444,7 +446,7 @@ Ogre::Vector3 convert(const JPH::Vec3Arg &vec)
|
||||
{
|
||||
return { vec[0], vec[1], vec[2] };
|
||||
}
|
||||
JPH::Vec3 convert(const Ogre::Vector3 &vec)
|
||||
JPH::RVec3 convert(const Ogre::Vector3 &vec)
|
||||
{
|
||||
return { vec.x, vec.y, vec.z };
|
||||
}
|
||||
@@ -460,7 +462,7 @@ void CompoundShapeBuilder::addShape(JPH::ShapeRefC shape,
|
||||
const Ogre::Vector3 &position,
|
||||
const Ogre::Quaternion &rotation)
|
||||
{
|
||||
shapeSettings.AddShape(JoltPhysics::convert(position),
|
||||
shapeSettings.AddShape(JoltPhysics::convert<JPH::Vec3>(position),
|
||||
JoltPhysics::convert(rotation), shape.GetPtr());
|
||||
}
|
||||
JPH::ShapeRefC CompoundShapeBuilder::build()
|
||||
@@ -769,7 +771,7 @@ public:
|
||||
timeAccumulator -= fixedDeltaTime;
|
||||
}
|
||||
for (JPH::BodyID bID : bodies) {
|
||||
JPH::Vec3 p;
|
||||
JPH::RVec3 p;
|
||||
JPH::Quat q;
|
||||
if (id2node.find(bID) == id2node.end())
|
||||
continue;
|
||||
@@ -810,7 +812,7 @@ public:
|
||||
}
|
||||
static JPH::ShapeRefC createBoxShape(float x, float y, float z)
|
||||
{
|
||||
return new JPH::BoxShape(JPH::RVec3(x, y, z));
|
||||
return new JPH::BoxShape(JPH::Vec3(x, y, z));
|
||||
}
|
||||
static JPH::ShapeRefC createCylinderShape(float halfHeight,
|
||||
float radius)
|
||||
@@ -818,7 +820,7 @@ public:
|
||||
return new JPH::CylinderShape(halfHeight, radius);
|
||||
}
|
||||
JPH::BodyCreationSettings createBodyCreationSettings(
|
||||
JPH::Shape *shape, JPH::Vec3 &position, JPH::Quat &rotation,
|
||||
JPH::Shape *shape, JPH::RVec3 &position, JPH::Quat &rotation,
|
||||
JPH::EMotionType motionType, JPH::ObjectLayer layer)
|
||||
{
|
||||
JPH::BodyCreationSettings body_settings(
|
||||
@@ -827,7 +829,7 @@ public:
|
||||
}
|
||||
JPH::BodyCreationSettings
|
||||
createBodyCreationSettings(JPH::ShapeSettings *shapeSettings,
|
||||
JPH::Vec3 &position, JPH::Quat &rotation,
|
||||
JPH::RVec3 &position, JPH::Quat &rotation,
|
||||
JPH::EMotionType motionType,
|
||||
JPH::ObjectLayer layer)
|
||||
{
|
||||
@@ -852,8 +854,8 @@ public:
|
||||
{
|
||||
JPH::BodyInterface &body_interface =
|
||||
physics_system.GetBodyInterface();
|
||||
body_interface.AddAngularImpulse(id,
|
||||
JoltPhysics::convert(impulse));
|
||||
body_interface.AddAngularImpulse(
|
||||
id, JoltPhysics::convert<JPH::Vec3>(impulse));
|
||||
}
|
||||
JPH::BodyID createBody(const JPH::BodyCreationSettings &settings,
|
||||
ActivationListener *listener = nullptr)
|
||||
@@ -964,7 +966,7 @@ public:
|
||||
JPH::MutableCompoundShape *master =
|
||||
static_cast<JPH::MutableCompoundShape *>(
|
||||
compoundShape.GetPtr());
|
||||
master->AddShape(JoltPhysics::convert(position),
|
||||
master->AddShape(JoltPhysics::convert<JPH::Vec3>(position),
|
||||
JoltPhysics::convert(rotation),
|
||||
childShape.GetPtr());
|
||||
}
|
||||
@@ -1275,8 +1277,9 @@ public:
|
||||
{
|
||||
int i;
|
||||
JPH::HeightFieldShapeSettings heightfieldSettings(
|
||||
samples, JoltPhysics::convert(offset),
|
||||
JoltPhysics::convert(scale), (uint32_t)sampleCount);
|
||||
samples, JoltPhysics::convert<JPH::Vec3>(offset),
|
||||
JoltPhysics::convert<JPH::Vec3>(scale),
|
||||
(uint32_t)sampleCount);
|
||||
for (i = 0; i < sampleCount; i++) {
|
||||
memcpy(heightfieldSettings.mHeightSamples.data() +
|
||||
sampleCount * i,
|
||||
@@ -1299,9 +1302,10 @@ public:
|
||||
"bad parameters");
|
||||
JPH::MutableCompoundShapeSettings settings;
|
||||
for (i = 0; i < shapes.size(); i++)
|
||||
settings.AddShape(JoltPhysics::convert(positions[i]),
|
||||
JoltPhysics::convert(rotations[i]),
|
||||
shapes[i].GetPtr());
|
||||
settings.AddShape(
|
||||
JoltPhysics::convert<JPH::Vec3>(positions[i]),
|
||||
JoltPhysics::convert(rotations[i]),
|
||||
shapes[i].GetPtr());
|
||||
JPH::ShapeSettings::ShapeResult result = settings.Create();
|
||||
OgreAssert(result.Get(), "Can not create compound shape");
|
||||
return result.Get();
|
||||
@@ -1317,9 +1321,10 @@ public:
|
||||
"bad parameters");
|
||||
JPH::StaticCompoundShapeSettings settings;
|
||||
for (i = 0; i < shapes.size(); i++)
|
||||
settings.AddShape(JoltPhysics::convert(positions[i]),
|
||||
JoltPhysics::convert(rotations[i]),
|
||||
shapes[i].GetPtr());
|
||||
settings.AddShape(
|
||||
JoltPhysics::convert<JPH::Vec3>(positions[i]),
|
||||
JoltPhysics::convert(rotations[i]),
|
||||
shapes[i].GetPtr());
|
||||
JPH::ShapeSettings::ShapeResult result = settings.Create();
|
||||
OgreAssert(result.Get(), "Can not create compound shape");
|
||||
return result.Get();
|
||||
@@ -1329,7 +1334,8 @@ public:
|
||||
JPH::ShapeRefC shape)
|
||||
{
|
||||
JPH::OffsetCenterOfMassShapeSettings settings(
|
||||
JoltPhysics::convert(offset), shape.GetPtr());
|
||||
JoltPhysics::convert<JPH::Vec3>(offset),
|
||||
shape.GetPtr());
|
||||
JPH::ShapeSettings::ShapeResult result = settings.Create();
|
||||
OgreAssert(result.Get(), "Can not create com offset shape");
|
||||
return result.Get();
|
||||
@@ -1340,7 +1346,7 @@ public:
|
||||
JPH::ShapeRefC shape)
|
||||
{
|
||||
return JPH::RotatedTranslatedShapeSettings(
|
||||
JoltPhysics::convert(offset),
|
||||
JoltPhysics::convert<JPH::Vec3>(offset),
|
||||
JoltPhysics::convert(rotation), shape)
|
||||
.Create()
|
||||
.Get();
|
||||
@@ -1356,11 +1362,12 @@ public:
|
||||
JPH::BodyLockWrite lock(physics_system.GetBodyLockInterface(),
|
||||
id);
|
||||
JPH::Body &body = lock.GetBody();
|
||||
body.ApplyBuoyancyImpulse(JoltPhysics::convert(surfacePosition),
|
||||
JoltPhysics::convert(surfaceNormal),
|
||||
buoyancy, linearDrag, angularDrag,
|
||||
JoltPhysics::convert(fluidVelocity),
|
||||
JoltPhysics::convert(gravity), dt);
|
||||
body.ApplyBuoyancyImpulse(
|
||||
JoltPhysics::convert(surfacePosition),
|
||||
JoltPhysics::convert<JPH::Vec3>(surfaceNormal),
|
||||
buoyancy, linearDrag, angularDrag,
|
||||
JoltPhysics::convert<JPH::Vec3>(fluidVelocity),
|
||||
JoltPhysics::convert<JPH::Vec3>(gravity), dt);
|
||||
}
|
||||
void applyBuoyancyImpulse(JPH::BodyID id,
|
||||
const Ogre::Vector3 &surfacePosition,
|
||||
@@ -1372,11 +1379,12 @@ public:
|
||||
JPH::BodyLockWrite lock(physics_system.GetBodyLockInterface(),
|
||||
id);
|
||||
JPH::Body &body = lock.GetBody();
|
||||
body.ApplyBuoyancyImpulse(JoltPhysics::convert(surfacePosition),
|
||||
JoltPhysics::convert(surfaceNormal),
|
||||
buoyancy, linearDrag, angularDrag,
|
||||
JoltPhysics::convert(fluidVelocity),
|
||||
physics_system.GetGravity(), dt);
|
||||
body.ApplyBuoyancyImpulse(
|
||||
JoltPhysics::convert(surfacePosition),
|
||||
JoltPhysics::convert<JPH::Vec3>(surfaceNormal),
|
||||
buoyancy, linearDrag, angularDrag,
|
||||
JoltPhysics::convert<JPH::Vec3>(fluidVelocity),
|
||||
physics_system.GetGravity(), dt);
|
||||
}
|
||||
bool isActive(JPH::BodyID id)
|
||||
{
|
||||
@@ -1399,7 +1407,7 @@ public:
|
||||
void getPositionAndRotation(JPH::BodyID id, Ogre::Vector3 &position,
|
||||
Ogre::Quaternion &rotation)
|
||||
{
|
||||
JPH::Vec3 _position;
|
||||
JPH::RVec3 _position;
|
||||
JPH::Quat _rotation;
|
||||
physics_system.GetBodyInterface().GetPositionAndRotation(
|
||||
id, _position, _rotation);
|
||||
@@ -1457,11 +1465,11 @@ public:
|
||||
void broadphaseQuery(float dt, const Ogre::Vector3 &position,
|
||||
std::set<JPH::BodyID> &inWater)
|
||||
{
|
||||
JPH::Vec3 surface_point = JoltPhysics::convert(
|
||||
JPH::RVec3 surface_point = JoltPhysics::convert(
|
||||
position + Ogre::Vector3(0, -0.1f, 0));
|
||||
|
||||
MyCollector collector(&physics_system, surface_point,
|
||||
JPH::Vec3::sAxisY(), dt);
|
||||
JPH::Vec3::sAxisY(), dt);
|
||||
// Apply buoyancy to all bodies that intersect with the water
|
||||
JPH::AABox water_box(-JPH::Vec3(1000, 1000, 1000),
|
||||
JPH::Vec3(1000, 0.1f, 1000));
|
||||
@@ -1488,7 +1496,7 @@ public:
|
||||
int i;
|
||||
Ogre::Vector3 direction = endPoint - startPoint;
|
||||
JPH::RRayCast ray{ JoltPhysics::convert(startPoint),
|
||||
JoltPhysics::convert(direction) };
|
||||
JoltPhysics::convert<JPH::Vec3>(direction) };
|
||||
JPH::RayCastResult hit;
|
||||
bool hadHit = physics_system.GetNarrowPhaseQuery().CastRay(
|
||||
ray, hit, {},
|
||||
|
||||
@@ -44,8 +44,15 @@ static constexpr uint NUM_LAYERS(2);
|
||||
|
||||
namespace JoltPhysics
|
||||
{
|
||||
Ogre::Vector3 convert(const JPH::Vec3Arg &vec);
|
||||
JPH::Vec3 convert(const Ogre::Vector3 &vec);
|
||||
template<class T>
|
||||
Ogre::Vector3 convert(const T &vec)
|
||||
{
|
||||
return {vec[0], vec[1], vec[2]};
|
||||
}
|
||||
template<class T> T convert(const Ogre::Vector3 &vec)
|
||||
{
|
||||
return { vec.x, vec.y, vec.z };
|
||||
}
|
||||
Ogre::Quaternion convert(const JPH::QuatArg &rot);
|
||||
JPH::Quat convert(const Ogre::Quaternion &rot);
|
||||
struct ShapeData;
|
||||
|
||||
Reference in New Issue
Block a user