com.jme3.scene.Spatial.requiresUpdates()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中com.jme3.scene.Spatial.requiresUpdates()方法的一些代码示例,展示了Spatial.requiresUpdates()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spatial.requiresUpdates()方法的具体详情如下:
包路径:com.jme3.scene.Spatial
类名称:Spatial
方法名:requiresUpdates

Spatial.requiresUpdates介绍

[英]Set to true if a subclass requires updateLogicalState() even if it doesn't have any controls. Defaults to true thus implementing the legacy behavior for any subclasses not specifically turning it off. This flag should be set during construction and never changed as it's supposed to be class-specific and not runtime state.
[中]如果子类需要updateLogicalState(),即使它没有任何控件,也设置为true。默认值为true,从而实现任何子类的遗留行为,而不是专门将其关闭。这个标志应该在构造期间设置,并且永远不会更改,因为它应该是特定于类的,而不是运行时状态。

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * Add a control to the list of controls.
 * @param control The control to add.
 *
 * @see Spatial#removeControl(java.lang.Class)
 */
public void addControl(Control control) {
  boolean before = requiresUpdates();
  controls.add(control);
  control.setSpatial(this);
  boolean after = requiresUpdates();
  // If the requirement to be updated has changed
  // then we need to let the parent node know so it
  // can rebuild its update list.
  if( parent != null && before != after ) {
    parent.invalidateUpdateList();
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * Removes the given control from this spatial's controls.
 *
 * @param control The control to remove
 * @return True if the control was successfully removed. False if the
 * control is not assigned to this spatial.
 *
 * @see Spatial#addControl(com.jme3.scene.control.Control)
 */
public boolean removeControl(Control control) {
  boolean before = requiresUpdates();
  boolean result = controls.remove(control);
  if (result) {
    control.setSpatial(null);
  }
  boolean after = requiresUpdates();
  // If the requirement to be updated has changed
  // then we need to let the parent node know so it
  // can rebuild its update list.
  if( parent != null && before != after ) {
    parent.invalidateUpdateList();
  }
  return result;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * Removes the first control that is an instance of the given class.
 *
 * @see Spatial#addControl(com.jme3.scene.control.Control)
 */
public void removeControl(Class<? extends Control> controlType) {
  boolean before = requiresUpdates();
  for (int i = 0; i < controls.size(); i++) {
    if (controlType.isAssignableFrom(controls.get(i).getClass())) {
      Control control = controls.remove(i);
      control.setSpatial(null);
      break; // added to match the javadoc  -pspeed
    }
  }
  boolean after = requiresUpdates();
  // If the requirement to be updated has changed
  // then we need to let the parent node know so it
  // can rebuild its update list.
  if( parent != null && before != after ) {
    parent.invalidateUpdateList();
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

private void addUpdateChildren( SafeArrayList<Spatial> results ) {
  for( Spatial child : children.getArray() ) {
    if( child.requiresUpdates() ) {
      results.add(child);
    }
    if( child instanceof Node ) {
      ((Node)child).addUpdateChildren(results);
    }
  }
}

代码示例来源:origin: org.jmonkeyengine/jme3-core

/**
 * Add a control to the list of controls.
 * @param control The control to add.
 *
 * @see Spatial#removeControl(java.lang.Class)
 */
public void addControl(Control control) {
  boolean before = requiresUpdates();
  controls.add(control);
  control.setSpatial(this);
  boolean after = requiresUpdates();
  // If the requirement to be updated has changed
  // then we need to let the parent node know so it
  // can rebuild its update list.
  if( parent != null && before != after ) {
    parent.invalidateUpdateList();
  }
}

代码示例来源:origin: org.jmonkeyengine/jme3-core

/**
 * Removes the given control from this spatial's controls.
 *
 * @param control The control to remove
 * @return True if the control was successfully removed. False if the
 * control is not assigned to this spatial.
 *
 * @see Spatial#addControl(com.jme3.scene.control.Control)
 */
public boolean removeControl(Control control) {
  boolean before = requiresUpdates();
  boolean result = controls.remove(control);
  if (result) {
    control.setSpatial(null);
  }
  boolean after = requiresUpdates();
  // If the requirement to be updated has changed
  // then we need to let the parent node know so it
  // can rebuild its update list.
  if( parent != null && before != after ) {
    parent.invalidateUpdateList();
  }
  return result;
}

代码示例来源:origin: org.jmonkeyengine/jme3-core

/**
 * Removes the first control that is an instance of the given class.
 *
 * @see Spatial#addControl(com.jme3.scene.control.Control)
 */
public void removeControl(Class<? extends Control> controlType) {
  boolean before = requiresUpdates();
  for (int i = 0; i < controls.size(); i++) {
    if (controlType.isAssignableFrom(controls.get(i).getClass())) {
      Control control = controls.remove(i);
      control.setSpatial(null);
      break; // added to match the javadoc  -pspeed
    }
  }
  boolean after = requiresUpdates();
  // If the requirement to be updated has changed
  // then we need to let the parent node know so it
  // can rebuild its update list.
  if( parent != null && before != after ) {
    parent.invalidateUpdateList();
  }
}

代码示例来源:origin: org.jmonkeyengine/jme3-core

private void addUpdateChildren( SafeArrayList<Spatial> results ) {
  for( Spatial child : children.getArray() ) {
    if( child.requiresUpdates() ) {
      results.add(child);
    }
    if( child instanceof Node ) {
      ((Node)child).addUpdateChildren(results);
    }
  }
}

相关文章

微信公众号

最新文章

更多

Spatial类方法