Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into python-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mtheall committed Feb 8, 2024
2 parents 86460b4 + 5c27db0 commit b40b743
Show file tree
Hide file tree
Showing 64 changed files with 717 additions and 476 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ This means RocketSim is accurate enough to:
- *Train machine learning bots*
- *Simulate different shots on the ball at different angles to find the best input combination*
- *Simulate air control to find the optimal orientation input*
- *Simulate ground and floor pinches*

However, RocketSim is NOT accurate enough to:
- *Simulate entire games from inputs alone*
- *Accurately determine the outcome of powerful pinches*
- *Perfectly simulate long sequences of jumps and landings*

## Installation
- Clone this repo and build it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1208,5 +1208,7 @@ void btCollisionWorld::contactPairTest(btCollisionObject* colObjA, btCollisionOb
bool btCollisionWorld::RayResultCallback::needsCollision(btBroadphaseProxy* proxy0) const {
bool collides = (proxy0->m_collisionFilterGroup & m_collisionFilterMask) != 0
&& (m_collisionFilterGroup & proxy0->m_collisionFilterMask);
if (proxy0->m_clientObject == m_ignoreObj)
return false;
return collides;
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class btCollisionWorld
{
btScalar m_closestHitFraction;
const btCollisionObject* m_collisionObject;
const btCollisionObject* m_ignoreObj;
int m_collisionFilterGroup;
int m_collisionFilterMask;
//@BP Mod - Custom flags, currently used to enable backface culling on tri-meshes, see btRaycastCallback.h. Apply any of the EFlags defined there on m_flags here to invoke.
Expand All @@ -195,6 +196,7 @@ class btCollisionWorld
m_collisionObject(0),
m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter),
m_collisionFilterMask(btBroadphaseProxy::AllFilter),
m_ignoreObj(0),
//@BP Mod
m_flags(0)
{
Expand All @@ -208,10 +210,11 @@ class btCollisionWorld

struct ClosestRayResultCallback : public RayResultCallback
{
ClosestRayResultCallback(const btVector3& rayFromWorld, const btVector3& rayToWorld)
ClosestRayResultCallback(const btVector3& rayFromWorld, const btVector3& rayToWorld, const btCollisionObject* ignoreObj)
: m_rayFromWorld(rayFromWorld),
m_rayToWorld(rayToWorld)
{
this->m_ignoreObj = ignoreObj;
}

btVector3 m_rayFromWorld; //used to calculate hitPointWorld from hitFraction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ btRigidBody& btActionInterface::getFixedBody()
return s_fixed;
}

void* btDefaultVehicleRaycaster::castRay(const btVector3& from, const btVector3& to, btVehicleRaycasterResult& result)
void* btDefaultVehicleRaycaster::castRay(const btVector3& from, const btVector3& to, const btCollisionObject* ignoreObj, btVehicleRaycasterResult& result)
{
// RayResultCallback& resultCallback;

btCollisionWorld::ClosestRayResultCallback rayCallback(from, to);
btCollisionWorld::ClosestRayResultCallback rayCallback(from, to, ignoreObj);
rayCallback.m_collisionFilterGroup = btBroadphaseProxy::CharacterFilter;
rayCallback.m_collisionFilterMask = btBroadphaseProxy::AllFilter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class btDefaultVehicleRaycaster : public btVehicleRaycaster
{
}

virtual void* castRay(const btVector3& from, const btVector3& to, btVehicleRaycasterResult& result);
virtual void* castRay(const btVector3& from, const btVector3& to, const btCollisionObject* ignoreObj, btVehicleRaycasterResult& result);
};

#endif //BT_RAYCASTVEHICLE_H
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct btVehicleRaycaster
btScalar m_distFraction;
};

virtual void* castRay(const btVector3& from, const btVector3& to, btVehicleRaycasterResult& result) = 0;
virtual void* castRay(const btVector3& from, const btVector3& to, const btCollisionObject* ignoreObj, btVehicleRaycasterResult& result) = 0;
};

#endif //BT_VEHICLE_RAYCASTER_H
2 changes: 1 addition & 1 deletion libsrc/bullet3-3.24/LinearMath/btHashMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class btHashKey
template <class Key, class Value>
class btHashMap
{
protected:
public:
btAlignedObjectArray<int> m_hashTable;
btAlignedObjectArray<int> m_next;

Expand Down
24 changes: 12 additions & 12 deletions python-mtheall/Angle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ PyTypeObject *Angle::Type = nullptr;

PyMemberDef Angle::Members[] = {
{.name = "yaw",
.type = TypeHelper<decltype (::Angle::yaw)>::type,
.offset = offsetof (Angle, angle) + offsetof (::Angle, yaw),
.type = TypeHelper<decltype (RocketSim::Angle::yaw)>::type,
.offset = offsetof (Angle, angle) + offsetof (RocketSim::Angle, yaw),
.flags = 0,
.doc = "Yaw component"},
{.name = "pitch",
.type = TypeHelper<decltype (::Angle::pitch)>::type,
.offset = offsetof (Angle, angle) + offsetof (::Angle, pitch),
.type = TypeHelper<decltype (RocketSim::Angle::pitch)>::type,
.offset = offsetof (Angle, angle) + offsetof (RocketSim::Angle, pitch),
.flags = 0,
.doc = "Pitch component"},
{.name = "roll",
.type = TypeHelper<decltype (::Angle::roll)>::type,
.offset = offsetof (Angle, angle) + offsetof (::Angle, roll),
.type = TypeHelper<decltype (RocketSim::Angle::roll)>::type,
.offset = offsetof (Angle, angle) + offsetof (RocketSim::Angle, roll),
.flags = 0,
.doc = "Roll component"},
{.name = nullptr, .type = 0, .offset = 0, .flags = 0, .doc = nullptr},
Expand Down Expand Up @@ -82,7 +82,7 @@ PyType_Spec Angle::Spec = {
.slots = Angle::Slots,
};

PyRef<Angle> Angle::NewFromAngle (::Angle const &angle_) noexcept
PyRef<Angle> Angle::NewFromAngle (RocketSim::Angle const &angle_) noexcept
{
auto const self = PyRef<Angle>::stealObject (Angle::New (Angle::Type, nullptr, nullptr));
if (!self || !InitFromAngle (self.borrow (), angle_))
Expand All @@ -91,13 +91,13 @@ PyRef<Angle> Angle::NewFromAngle (::Angle const &angle_) noexcept
return self;
}

bool Angle::InitFromAngle (Angle *const self_, ::Angle const &angle_) noexcept
bool Angle::InitFromAngle (Angle *const self_, RocketSim::Angle const &angle_) noexcept
{
self_->angle = angle_;
return true;
}

::Angle Angle::ToAngle (Angle *self_) noexcept
RocketSim::Angle Angle::ToAngle (Angle *self_) noexcept
{
return self_->angle;
}
Expand All @@ -110,7 +110,7 @@ PyObject *Angle::New (PyTypeObject *subtype_, PyObject *args_, PyObject *kwds_)
if (!self)
return nullptr;

new (&self->angle)::Angle{};
new (&self->angle) RocketSim::Angle{};

return self.giftObject ();
}
Expand All @@ -123,7 +123,7 @@ int Angle::Init (Angle *self_, PyObject *args_, PyObject *kwds_) noexcept

static char *dict[] = {yawKwd, pitchKwd, rollKwd, nullptr};

::Angle angle{};
RocketSim::Angle angle{};
if (!PyArg_ParseTupleAndKeywords (args_, kwds_, "|fff", dict, &angle.yaw, &angle.pitch, &angle.roll))
return -1;

Expand Down Expand Up @@ -193,7 +193,7 @@ PyObject *Angle::Pickle (Angle *self_) noexcept
if (!dict)
return nullptr;

::Angle const model{};
RocketSim::Angle const model{};
auto const angle = ToAngle (self_);

if (angle.yaw != model.yaw && !DictSetValue (dict.borrow (), "yaw", PyFloat_FromDouble (angle.yaw)))
Expand Down
Loading

0 comments on commit b40b743

Please sign in to comment.