Compile Time Changes

Added: private int mhPointXYZPosSort(point a, point b, Object env) {
Added: public int mhSnapperRootXYZPosSort(Snapper a, Snapper b, Object env) {
Added: public int mhSnapperFuncRunOrderSort(Snapper a, Snapper b, Object env) {
Added: public int mhEntryRootXYZPosSort(MhEngineEntry a, MhEngineEntry b, Object env) {
Added: public int mhEntryFuncRunOrderSort(MhEngineEntry a, MhEngineEntry b, Object env) {
Removed: public (Snapper{}) getAllChildrenIntersecting(Snapper snapper, Snapper targetSnapper, Snapper{} exceptTo=null) {
Old: public (Snapper{}) getAllChildrenIntersecting2(Snapper snapper, Snapper targetSnapper, bool trueIntersects=false, Snapper{} exceptTo=null) {
New: public (Snapper{}) getAllChildrenIntersecting(Snapper snapper, Snapper targetSnapper, bool trueIntersects=false, Snapper{} exceptTo=null) {

public class MhConfigManager : unstreamable {
- Old: extend public void removeConfig(MhConfigRef config, MhSnapper z) {
- New: extend public void removeSnapper(MhConfigRef config, MhSnapper z) {
- Removed: extend public void removeSnapper(MhSnapper z, symbol key, bool tempConfig) : deprecated {
- Removed: extend public bool setNewName(MhConfigRef config) : deprecated {
- Removed: extend public bool isConfigNameTaken(str name) {

public class MhSystemConfiguration extends CoreObject {
- Old: extend public void load(RobustFormatter formatter) {
- New: extend public bool load(RobustFormatter formatter) {

public class MhDebugSpaceViewerDialog extends DialogWindow {
- Old: extend public void build(Space space, bool in3D) {
- New: extend public void build(Space space, bool in3D, symbol main) {

public class MhEngineManager extends CoreObject {
- Removed: public void runEngine(MhEngine engine, MhRunEngineEnv runEnv=null)

public class MhSystemEngineEnvironment extends CxEnvironment {
- Old: repairLink(MhEngine engine, MhEngineEntry entry)
- New: shouldRepairLink(MhEngine engine, MhEngineEntry entry)

public class MhConfigBehavior extends MhBehavior : abstract {
- Removed: extend public bool autoAssignConfigName(MhConfigRef config) : deprecated {

public class MhLevelParentEngineBehavior extends MhEngineBehavior {
- Removed: extend public bool addFloorLevel(MhSnapper snapper) {

public class MhSnapperShape extends CorePropObj {
- Added: extend public void buildGeometries(MhSnapperGeometry[] geos) {

Adding more control when calculating shape bound.

- Old: public box shapeBoundWithChildren(MhSnapper owner, symbol[] symbols)
- New: public box shapeBoundWithChildren(MhSnapper owner, symbol[] symbols, SnapperFilter filter=null)  

MhConfigManager changes

The method removeConfig(MhConfigRef config, MhSnapper z) has been renamed to removeSnapper(MhConfigRef config, MhSnapper z) which is a more accurate name representing the logic of the method.

- Old: extend public void removeConfig(MhConfigRef config, MhSnapper z) {
- New: extend public void removeSnapper(MhConfigRef config, MhSnapper z) {

The method removeSnapper(MhSnapper z, symbol key, bool tempConfig) has been removed. Use either removeSnapper(MhConfigRef config, MhSnapper z) or removeSnapper(MhSnapper z, symbol key) instead.

- Removed: extend public void removeSnapper(MhSnapper z, symbol key, bool tempConfig) : deprecated {

The method setNewName(MhConfigRef config) has been removed. Use initialiseConfig(MhConfigRef config) instead.

- Removed: extend public bool setNewName(MhConfigRef config) : deprecated {

The method isConfigNameTaken(str name) has been removed as it was unused.

- Removed: extend public bool isConfigNameTaken(str name) {

MhSystemConfiguration changes

The method load(RobustFormatter formatter) now returns a bool value to allow for returning false when loading fails.

- Old: extend public void load(RobustFormatter formatter) {
- New: extend public bool load(RobustFormatter formatter) {

MhDebugSpaceViewerDialog changes

The build(Space space, bool in3D) method no longer takes in a symbol main argument, instead main is now stored as a field.

- Old: extend public void build(Space space, bool in3D) {
- New: extend public void build(Space space, bool in3D, symbol main) {
- New: public symbol main;

MhSnapper changes

Added filter to childrenShapeBound function so that we can choose what children we want to include.

public class MhSnapper extends Snapper {
- Old: extend public box childrenShapeBound(symbol[] symbols=null) {
- New: extend public box childrenShapeBound(symbol[] symbols=null, SnapperFilter filter=null) {

MhBayEditor and MhStorageConfigurator close dialog methods renamed

Rename function so its more specific to mh.

- Old: public void closeBayConfigurationDialog() {
- New: public void mhCloseBayConfigurationDialog() {
- Old: public void closeConfigurationDialog(symbol pkg=null) {
- New: public void mhCloseConfigurationDialog(symbol pkg=null) {

MhEngineCollisionEntry changes

Move few functions up to MhEngineEntryBase.

- Moved: extend public void ensureCollisionPrimitive() {
- Moved: extend public CollisionPrimitive getPrim() {
- Moved: extend public CollisionPrimitive setPrim(CollisionPrimitive v) {

Sorting of MhSnapper and MhEngineEntry

The sorting functionalities of collections of MhSnapper and MhEngineEntry of varying children and sibling relationships have been consolidated and modularised allowing for a deterministic engine operation (e.g. sorting of engine run functions) using the sorting piorities as follows:

  1. Presence of snapper.
  2. Descending child depth.
  3. Root parent position relative to space.
  4. Local position relative to root parent.
Added: private int mhPointXYZPosSort(point a, point b, Object env) {
Added: public int mhSnapperRootXYZPosSort(Snapper a, Snapper b, Object env) {
Added: public int mhSnapperFuncRunOrderSort(Snapper a, Snapper b, Object env) {
Added: public int mhEntryRootXYZPosSort(MhEngineEntry a, MhEngineEntry b, Object env) {
Added: public int mhEntryFuncRunOrderSort(MhEngineEntry a, MhEngineEntry b, Object env) {

MhConfigBehavior changes

The method autoAssignConfigName(MhConfigRef config) has been removed as it was not in use.

- Removed: extend public bool autoAssignConfigName(MhConfigRef config) : deprecated {

getAllChildrenIntersecting function changes

The function getAllChildrenIntersecting(Snapper snapper, Snapper targetSnapper, Snapper{} exceptTo=null) has been removed as it was redundant. Additionally, getAllChildrenIntersecting2(Snapper snapper, Snapper targetSnapper, bool trueIntersects=false, Snapper{} exceptTo=null) has been renamed to getAllChildrenIntersecting(Snapper snapper, Snapper targetSnapper, bool trueIntersects=false, Snapper{} exceptTo=null).

- Removed: public (Snapper{}) getAllChildrenIntersecting(Snapper snapper, Snapper targetSnapper, Snapper{} exceptTo=null) {
- Old: public (Snapper{}) getAllChildrenIntersecting2(Snapper snapper, Snapper targetSnapper, bool trueIntersects=false, Snapper{} exceptTo=null) {
- New: public (Snapper{}) getAllChildrenIntersecting(Snapper snapper, Snapper targetSnapper, bool trueIntersects=false, Snapper{} exceptTo=null) {

MhLevelParentEngineBehavior changes

The method addFloorLevel(MhSnapper snapper) has been removed.

public class MhLevelParentEngineBehavior extends MhEngineBehavior {
- Removed: extend public bool addFloorLevel(MhSnapper snapper) {

It was only used in the child class MhBayEngineBehavior. This functionality has been replaced to be looked up from the MhSnapperChangedEnv object passed in as an argument to engineFunctionArgs(MhSnapper snapper, MhEngineFunctionRun func, symbol event="", MhPreprocessArgsEnv preprocessArgs=null, Object env=null).

public class MhBayEngineBehavior extends MhLevelParentEngineBehavior {

Old:
    public str->Object engineFunctionArgs(MhSnapper snapper, MhEngineFunctionRun func, symbol event="", MhPreprocessArgsEnv preprocessArgs=null, Object env=null) {
        switch (func.name) {
          case "levelConstruction" : {
              return props { ...
                    addFloorLevel=addFloorLevel(snapper),
                    ...};
          }
    }

New:
    public str->Object engineFunctionArgs(MhSnapper snapper, MhEngineFunctionRun func, symbol event="", MhPreprocessArgsEnv preprocessArgs=null, Object env=null) {
        switch (func.name) {
          case "levelConstruction" : {
              MhSnapperChangedEnv changedEnv = env.MhSnapperChangedEnv;
              ?str->Object v = changedEnv.?value;
              ?Int levelCount = v.?get("noOfLevels");
              ?bool addFloorLevel = v.?get("addFloorLevel");
              
              return props { ...
                    addFloorLevel=addFloorLevel,
                    ...};
          }
    }

This allows the addFloorLevel value to be passed in from outside the engine behavior. One example of how to do this can be seen below.

public class MhBayInsertToolAnimation extends MhSnapperInsertToolAnimation {

    /**
     * Init
     */
    public void init(Snapper snapper) {
        ...
        bool addFloorLevel = false;
        Int levelCount = null;
        if (?MhStorageConfiguration config = main.?configuration) {
            addFloorLevel = config.addFloorLevel();
            if (Number n = config.noOfLevels()) levelCount = n.int;
        }

        MhSnapperChangedEnv changeEnv = main.snapperChangedEnv("bayInsert", v=props{addFloorLevel=addFloorLevel, noOfLevels=levelCount});
        main.validateBehaviors(sInitInsertAnimation, changeEnv);
        mhRunEngines(MhRunEngineEnv(blockImport=true, blockExport=true));
    }
}

Runtime/Behavior Changes

MhAfterEngineInitialExportBehavior changes

Change sorting of snapper from locally defined snapper child depth sorting to use newly added mhSnapperFuncRunOrderSort(Snapper a, Snapper b, Object env).

MhEngineRun changes

Change sorting of snapper from locally defined snapper child depth sorting to use newly added mhSnapperFuncRunOrderSort(Snapper a, Snapper b, Object env) during export.

MhRemoverExecuteVessel changes

Change sorting of snapper from locally defined snapper child depth sorting to use newly added mhSnapperFuncRunOrderSort(Snapper a, Snapper b, Object env).

MhSnapperShape changes

Implement sorting of snapper children to use newly added mhSnapperRootXYZPosSort(Snapper a, Snapper b, Object env) during property change.

MhEngineManager

Split run functions into multiple functions for clarity. This means that runFunctions will be a stand alone function and no longer call post engine run and finalize engine run.

        int i;
        while (i <= list.lastIndex) {
            if (MhEngineRun r = list[i]) {
                currentRun = r;
                
                r.beforeEngineRun(e, runEnv);
                
                r.mainRunFunctions(e, runEnv);
                r.postRunFunctions(e, runEnv);
                r.finalizeRunFunctions(e, runEnv);
                
                r.afterEngineRun(e, runEnv);
                
                currentRun = null;
            }

            i++;
        }

For function that called runFunctions outside of engine manager, this will have to change as below.

Example: 

Old:  {
    run.runFunctions(runEngine, env);
}

New: { 
    run.mainRunFunctions(runEngine, env);
    run.postRunFunctions(runEngine, env);
}

Temporary MhConfigRef copy changes

The function mhConfigTempCopy(MhConfigRef ref) will now also set the field id = 0 of MhConfigRef objects where their field isCustom = true.

Old:
public MhConfigRef mhConfigTempCopy(MhConfigRef ref) {
    MhConfigRef cRef = copy(ref);
    cRef.gid = guid();
    
    if (ref.isCustom) {
        if (developMode) if (cRef.id != -1) ptrace("Expected ID to be -1 for custom!".eAngry);
    } else {
        cRef.id = 0;
        cRef.name = "";
    }
    return cRef;
}

New:
public MhConfigRef mhConfigTempCopy(MhConfigRef ref) {
    if (!ref) return null;
    MhConfigRef cRef = copy(ref);
    cRef.gid = guid();
    cRef.id = 0;
    if (!ref.isCustom) cRef.name = "";
    return cRef;
}

This is because MhConfigRef objects are only considered temporary if id == 0.

public class MhConfigRef {

    /**
     * Temp.
     */
    final public bool temp() { return id == 0; }
}

Without resetting the id field back to 0, they will not be treated as temporary config refs by MhConfigManager, stopping those instances from being merged with identical config refs in the MhConfigManager.configs container field.

MhLevelConstructionalPopulateFunction changes

A new field public Int noOfLevels has been added to MhLevelConstructionalPopulateFunction. When a noOfLevels value is passed in from your engine behavior, this function will only populate loads up to the noOfLevels value instead of using the parent bound and populating as much as possible up to the bound height.