소스 검색

Adding CulledNoSync flag

clandrin 2 년 전
부모
커밋
8983bcc792
1개의 변경된 파일11개의 추가작업 그리고 0개의 파일을 삭제
  1. 11 0
      h3d/scene/Object.hx

+ 11 - 0
h3d/scene/Object.hx

@@ -16,6 +16,7 @@ package h3d.scene;
 	public var FCullingColliderInherited = 0x1000;
 	public var FFixedPosition = 0x2000;
 	public var FFixedPositionSynced = 0x4000;
+	public var FCulledNoSync = 0x8000;
 	public inline function new(value) {
 		this = value;
 	}
@@ -157,6 +158,12 @@ class Object {
 	**/
 	public var fixedPosition(get, set) : Bool;
 
+	/**
+		When set, the object and all its children will not sync() if this root object is culled.
+		This allows to optimize cpu cost of objects having many children.
+	**/
+	public var culledNoSync(get, set) : Bool;
+
 	/**
 		When set, collider shape will be used for automatic frustum culling.
 		If `inheritCulled` is true, collider will be inherited to children unless they have their own collider set.
@@ -209,6 +216,7 @@ class Object {
 	inline function get_ignoreParentTransform() return flags.has(FIgnoreParentTransform);
 	inline function get_cullingColliderInherited() return flags.has(FCullingColliderInherited);
 	inline function get_fixedPosition() return flags.has(FFixedPosition);
+	inline function get_culledNoSync() return flags.has(FCulledNoSync);
 	inline function set_posChanged(b) return flags.set(FPosChanged, b || follow != null);
 	inline function set_culled(b) return flags.set(FCulled, b);
 	inline function set_visible(b) return flags.set(FVisible,b);
@@ -223,6 +231,7 @@ class Object {
 	inline function set_ignoreParentTransform(b) { if( b != ignoreParentTransform ) posChanged = true; return flags.set(FIgnoreParentTransform, b); }
 	inline function set_cullingColliderInherited(b) return flags.set(FCullingColliderInherited, b);
 	inline function set_fixedPosition(b) return flags.set(FFixedPosition, b);
+	inline function set_culledNoSync(b) return flags.set(FCulledNoSync, b);
 
 	/**
 		Create an animation instance bound to the object, set it as currentAnimation and play it.
@@ -707,6 +716,8 @@ class Object {
 			if( parent == null && old != null )
 				return; // if we were removed by an animation event
 		}
+		if ( culled && culledNoSync )
+			return;
 		var old = ctx.visibleFlag;
 		if( !visible || (culled && inheritCulled) )
 			ctx.visibleFlag = false;