Skip to content

Commit

Permalink
--set stage ID to 0;
Browse files Browse the repository at this point in the history
  • Loading branch information
jturner65 committed Feb 8, 2024
1 parent 378d24d commit 772bc70
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion examples/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ def mouse_press_event(self, event: Application.MouseEvent) -> None:
hit_object, ao_link = -1, -1
hit_info = raycast_results.hits[0]

if hit_info.object_id >= 0:
if hit_info.object_id >= 1:
# we hit an non-staged collision object
ro_mngr = self.sim.get_rigid_object_manager()
ao_mngr = self.sim.get_articulated_object_manager()
Expand Down
2 changes: 1 addition & 1 deletion src/esp/physics/RigidStage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace physics {

RigidStage::RigidStage(scene::SceneNode* rigidBodyNode,
const assets::ResourceManager& resMgr)
: RigidBase(rigidBodyNode, ID_UNDEFINED, resMgr) {}
: RigidBase(rigidBodyNode, 0, resMgr) {}

bool RigidStage::initialize(
metadata::attributes::AbstractObjectAttributes::ptr initAttributes) {
Expand Down
6 changes: 3 additions & 3 deletions src/esp/physics/bullet/BulletPhysicsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ void BulletPhysicsManager::lookUpObjectIdAndLinkId(

*linkId = -1;
// If the lookup fails, default to the stage. TODO: better error-handling.
*objectId = -1;
*objectId = 0;
auto rawColObjIdIter = collisionObjToObjIds_->find(colObj);
if (rawColObjIdIter != collisionObjToObjIds_->end()) {
int rawObjectId = rawColObjIdIter->second;
Expand Down Expand Up @@ -558,8 +558,8 @@ std::vector<ContactPointData> BulletPhysicsManager::getContactPoints() const {
const btPersistentManifold* manifold =
dispatcher->getInternalManifoldPointer()[i];

int objectIdA = -2; // stage is -1
int objectIdB = -2;
int objectIdA = -1; // stage is 0
int objectIdB = -1;
int linkIndexA = -1; // -1 if not a multibody
int linkIndexB = -1;

Expand Down
8 changes: 4 additions & 4 deletions src/tests/PhysicsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ void PhysicsTest::testNumActiveContactPoints() {
CORRADE_COMPARE(physicsManager_->getNumActiveOverlappingPairs(), 2);
CORRADE_COMPARE(
physicsManager_->getStepCollisionSummary(),
"[RigidObject, cubeSolid, id 0] vs [Stage, subpart 6], 4 points\n");
"[RigidObject, cubeSolid, id 1] vs [Stage, subpart 6], 4 points\n");

float totalNormalForce = 0;
for (auto& cp : allContactPoints) {
Expand All @@ -736,9 +736,9 @@ void PhysicsTest::testNumActiveContactPoints() {
CORRADE_COMPARE_AS(
(cp.contactNormalOnBInWS - Magnum::Vector3{0.0, 1.0, 0.0}).length(),
1.0e-4, Cr::TestSuite::Compare::LessOrEqual);
// one object is the cube (0), other is the stage (-1)
CORRADE_COMPARE(cp.objectIdA, 0);
CORRADE_COMPARE(cp.objectIdB, -1);
// one object is the cube (1), other is the stage (0)
CORRADE_COMPARE(cp.objectIdA, 1);
CORRADE_COMPARE(cp.objectIdB, 0);
// accumulate the normal force
totalNormalForce += cp.normalForce;
// solver should keep the cube at the contact boundary (~0 penetration)
Expand Down
10 changes: 6 additions & 4 deletions tests/test_physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ def test_raycast():
atol=0.07,
)
assert abs(raycast_results.hits[0].ray_distance - 6.831) < 0.001
assert raycast_results.hits[0].object_id == -1
# hit stage
assert raycast_results.hits[0].object_id == 0

# add a primitive object to the world and test a ray away from the origin
cube_prim_handle = obj_template_mgr.get_template_handles("cube")[0]
Expand Down Expand Up @@ -906,7 +907,7 @@ def test_articulated_object_add_remove():
robot = art_obj_mgr.add_articulated_object_from_urdf(filepath=robot_file)
assert robot
assert robot.is_alive
assert robot.object_id == 0 # first robot added
assert robot.object_id == 1 # first robot added

# add a second robot
robot2 = art_obj_mgr.add_articulated_object_from_urdf(
Expand Down Expand Up @@ -1859,7 +1860,8 @@ def test_rigid_constraints():
assert robot.translation[1] < -3

# hang AO from the world with P2P
constraint_settings_2.object_id_b = -1
# object_id_b is stage
constraint_settings_2.object_id_b = 0
constraint_settings_2.constraint_type = (
habitat_sim.physics.RigidConstraintType.PointToPoint
)
Expand Down Expand Up @@ -2032,7 +2034,7 @@ def test_bullet_collision_helper():
assert sim.get_physics_num_active_overlapping_pairs() == 1
assert (
sim.get_physics_step_collision_summary()
== "[RigidObject, cubeSolid, id 0] vs [Stage, subpart 0], 4 points\n"
== "[RigidObject, cubeSolid, id 1] vs [Stage, subpart 0], 4 points\n"
)

sim.step_physics(3.0)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def test_object_template_editing():

# test adding a new object
obj = rigid_obj_mgr.add_object_by_template_id(template_ids[0])
assert obj.object_id != -1
assert obj.object_id != 0

# test getting initialization templates
stage_init_template = sim.get_stage_initialization_template()
Expand Down

0 comments on commit 772bc70

Please sign in to comment.