Class SceneGraphThreadWarden

java.lang.Object
com.jme3.scene.threadwarden.SceneGraphThreadWarden

public class SceneGraphThreadWarden extends Object
Thread warden keeps track of mutations to the scene graph and ensures that they are only done on the main thread. IF the parent node is marked as being reserved for the main thread (which basically means it's connected to the root node)

Only has an effect if asserts are on

  • Field Details

    • THREAD_WARDEN_ENABLED

      public static boolean THREAD_WARDEN_ENABLED
      If THREAD_WARDEN_ENABLED is true AND asserts are on the checks are made. This parameter is here to allow asserts to run without thread warden checks (by setting this parameter to false)
    • ASSERTS_ENABLED

      public static boolean ASSERTS_ENABLED
    • mainThread

      public static Thread mainThread
    • spatialsThatAreMainThreadReserved

      public static final Set<Spatial> spatialsThatAreMainThreadReserved
  • Constructor Details

    • SceneGraphThreadWarden

      public SceneGraphThreadWarden()
  • Method Details

    • setup

      public static boolean setup(Node rootNode)
      Marks the given node as being reserved for the main thread. Additionally, sets the current thread as the main thread (if it hasn't already been set)
      Parameters:
      rootNode - the root node of the scene graph. This is used to determine if a spatial is a child of the root node. (Can add multiple "root" nodes, e.g. gui nodes or overlay nodes)
    • disableChecks

      public static void disableChecks()
      Disables the thread warden checks (even when other asserts are on).

      Alternatively can be disabled by adding the -Dnothreadwarden=true parameter

    • updateRequirement

      public static boolean updateRequirement(Spatial spatial, Node newParent)
    • reset

      public static boolean reset()
    • assertOnCorrectThread

      public static boolean assertOnCorrectThread(Spatial spatial)
    • getTurnOnAssertsPrompt

      public static String getTurnOnAssertsPrompt()