lullaby/tests/physics_system_test.cc
// Test enabling and disabling physics.
Test enabling and disabling physics.
Test enabling and disabling physics .
TEST_F(PhysicsSystemTest, EnableAndDisablePhysics) {
  auto* entity_factory = registry_->Get<EntityFactory>();
  auto* physics_system = registry_->Get<PhysicsSystem>();
  const Entity entity = CreateBasicRigidBody();
  EXPECT_THAT(entity, Ne(kNullEntity));
  EXPECT_TRUE(physics_system->IsPhysicsEnabled(entity));
  physics_system->DisablePhysics(entity);
  EXPECT_FALSE(physics_system->IsPhysicsEnabled(entity));
  physics_system->EnablePhysics(entity);
  EXPECT_TRUE(physics_system->IsPhysicsEnabled(entity));
  Blueprint disabled_blueprint(512);
  {
    TransformDefT transform;
    disabled_blueprint.Write(&transform);
    RigidBodyDefT rigid_body;
    rigid_body.enable_on_create = false;
    disabled_blueprint.Write(&rigid_body);
  }
  const Entity disabled = entity_factory->Create(&disabled_blueprint);
  EXPECT_THAT(disabled, Ne(kNullEntity));
  EXPECT_FALSE(physics_system->IsPhysicsEnabled(disabled));
  Blueprint no_physics_blueprint(512);
  {
    TransformDefT transform;
    no_physics_blueprint.Write(&transform);
  }
  const Entity no_physics = entity_factory->Create(&no_physics_blueprint);
  EXPECT_THAT(no_physics, Ne(kNullEntity));
  EXPECT_FALSE(physics_system->IsPhysicsEnabled(no_physics));
  physics_system->EnablePhysics(no_physics);
  EXPECT_FALSE(physics_system->IsPhysicsEnabled(no_physics));
}
TEST_F ( PhysicsSystemTest , EnableAndDisablePhysics ) { auto * entity_factory = registry_ -> Get < EntityFactory > ( ) ; auto * physics_system = registry_ -> Get < PhysicsSystem > ( ) ; const Entity entity = CreateBasicRigidBody ( ) ; EXPECT_THAT ( entity , Ne ( kNullEntity ) ) ; EXPECT_TRUE ( physics_system -> IsPhysicsEnabled ( entity ) ) ; physics_system -> DisablePhysics ( entity ) ; EXPECT_FALSE ( physics_system -> IsPhysicsEnabled ( entity ) ) ; physics_system -> EnablePhysics ( entity ) ; EXPECT_TRUE ( physics_system -> IsPhysicsEnabled ( entity ) ) ; Blueprint disabled_blueprint ( 512 ) ; { TransformDefT transform ; disabled_blueprint . Write ( & transform ) ; RigidBodyDefT rigid_body ; rigid_body . enable_on_create = false ; disabled_blueprint . Write ( & rigid_body ) ; } const Entity disabled = entity_factory -> Create ( & disabled_blueprint ) ; EXPECT_THAT ( disabled , Ne ( kNullEntity ) ) ; EXPECT_FALSE ( physics_system -> IsPhysicsEnabled ( disabled ) ) ; Blueprint no_physics_blueprint ( 512 ) ; { TransformDefT transform ; no_physics_blueprint . Write ( & transform ) ; } const Entity no_physics = entity_factory -> Create ( & no_physics_blueprint ) ; EXPECT_THAT ( no_physics , Ne ( kNullEntity ) ) ; EXPECT_FALSE ( physics_system -> IsPhysicsEnabled ( no_physics ) ) ; physics_system -> EnablePhysics ( no_physics ) ; EXPECT_FALSE ( physics_system -> IsPhysicsEnabled ( no_physics ) ) ; }
Test enabling and disabling physics.
Test enabling and disabling physics .
// Test that physics is enabled by default. // Enable and disable physics. // Test that the enable_on_create field is respected. // Test that the an Entity with no RigidBodyDef reports physics disabled.