BGE: Logic Brick clean up

Authored by Jorge Bernal (lordloki) on Jun 30 2014, 2:30 AM.



This proposal borns from to have the logic bricks properly encapsulated and organized and to allow (at last) that the logic system won't be dependent on logic brick code.

At this moment I have completed Step 1 of the proposal which includes the following:
Step 1. All Logic bricks should be put into their own folder (GameLogic)

1.1 Move the following sensors and actuators from Ketsji to Gamelogic folder: (Done)

  • Armature Sensor (Done)
  • Near Sensor (Done)
  • NetworkMessage Sensor (Done)
  • Radar Sensor (Done)
  • Ray Sensor (Done)
  • Touch Sensor (Done)
  • MouseFocus Sensor (Done)
  • Camera Actuator (Done)
  • Constraint Actuator (Done)
  • EditObject Actuators (AddObject, EndObject, ReplaceMesh, Dynamic and TrackTo) (Done)
  • Game Actuator (Done)
  • Ipo Actuator (Done)
  • Mouse Actuator (Done)
  • NetworkMessage Actuator (Done)
  • Object Actuator (Done)
  • Parent Actuator (Done)
  • Scene Actuator (Done)
  • Sound Actuator (Done)
  • State Actuator (Done)
  • Steering Actuator (Done)
  • Visibility Actuator (Done)

1.2 Move the following actuators from Converter to Gamelogic folder: (Done)

  • Action Actuator (Done)
  • Armature Actuator (Done)
  • ShapeAction Actuator (Done)

1.3 Rename filenames from KX_ and KX_SCA_ to SCA_ (Done)
1.4 Rename classes names from KX_ to SCA_ (Done)
1.5 Make everything compile. At this point, several new dependencies should be added to GameLogic CMakeList.txt (i.e. Audaspace, Physics, Ketsji, blenkernel, etc) (Done)
1.6 To update the documentation associated (rst) (Done)
1.7 Due to the ammount of code modified, to upload the diff to to check possible errors. (Done)

When this part is Ok for everybody I will proceed with the Step 2.

Diff Detail

rB Blender
Mitchell Stokes (moguri) requested changes to this revision.Jul 7 2014, 3:16 PM

Some of the docs still need their titles renamed. For example, SCA_ArmatureActuator.rst's title still says BL_ArmatureActuator. These renames could potentially break scripts (in the rare case that someone was actually checking types), so we'll need to make a note in the wiki. This would probably also be a good time to rename the "ObjectActuator" to it's more well-known name of "MotionActuator," but this can be done as a separate commit to keep things organized. You should also avoid too many style changes in this patch (e.g., SCA_VisibilityActuator.h).

There is still a dependency that I know of in KX_GameObject, which is leveraged by a number of places (ConvertPythonToGameObject)
Line 3673 "(KX_GameObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String( _PyUnicode_AsString(value) ));"

I ran into this when I removed the logic bricks evaluation. One function which uses this is scene.addObject, which should not rely on Logic bricks for scene -operations.

Simple fix, just ask for the this->GetScene()->GetLogicManager() or something like that, which hides it behind an interface. I'm aware that this isn't a fault with your patch, but this would be a good place to include it, I believe.

@Angus Hollands (agoose77) Those sorts of cleanups are included as part two of the linked proposal. @Jorge Bernal (lordloki), when you get to those changes, make sure to submit them in chunks to code review. I'd rather not try to do code review on all of part two at once.

Jorge Bernal (lordloki) updated this revision to Diff 2923.EditedNov 23 2014, 12:31 AM
  • Some of the docs still need their titles renamed.
  • Revert the style changes to facilitate the review process
  • Update to current master and fixes to compile

Closing. I will follow after UPBGE merge.
Thanks for reviewing