Bläddra i källkod

Added a flag for an entity to render children even if invisible.

Ivan Safrin 14 år sedan
förälder
incheckning
a4af1a3f84

+ 5 - 0
Bindings/Contents/LUA/API/Polycode/Entity.lua

@@ -36,6 +36,8 @@ function Entity:__index__(name)
 		return Polycore.Entity_get_blendingMode(self.__ptr)
 	elseif name == "colorAffectsChildren" then
 		return Polycore.Entity_get_colorAffectsChildren(self.__ptr)
+	elseif name == "visibilityAffectsChildren" then
+		return Polycore.Entity_get_visibilityAffectsChildren(self.__ptr)
 	elseif name == "depthOnly" then
 		return Polycore.Entity_get_depthOnly(self.__ptr)
 	elseif name == "bBox" then
@@ -92,6 +94,9 @@ function Entity:__set_callback(name,value)
 	elseif name == "colorAffectsChildren" then
 		Polycore.Entity_set_colorAffectsChildren(self.__ptr, value)
 		return true
+	elseif name == "visibilityAffectsChildren" then
+		Polycore.Entity_set_visibilityAffectsChildren(self.__ptr, value)
+		return true
 	elseif name == "depthOnly" then
 		Polycore.Entity_set_depthOnly(self.__ptr, value)
 		return true

+ 15 - 0
Bindings/Contents/LUA/Include/PolycodeLUAWrappers.h

@@ -1903,6 +1903,13 @@ static int Polycore_Entity_get_colorAffectsChildren(lua_State *L) {
 	return 1;
 }
 
+static int Polycore_Entity_get_visibilityAffectsChildren(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	Entity *inst = (Entity*)lua_topointer(L, 1);
+	lua_pushboolean(L, inst->visibilityAffectsChildren);
+	return 1;
+}
+
 static int Polycore_Entity_get_depthOnly(lua_State *L) {
 	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
 	Entity *inst = (Entity*)lua_topointer(L, 1);
@@ -2027,6 +2034,14 @@ static int Polycore_Entity_set_colorAffectsChildren(lua_State *L) {
 	return 0;
 }
 
+static int Polycore_Entity_set_visibilityAffectsChildren(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	Entity *inst = (Entity*)lua_topointer(L, 1);
+	bool param = lua_toboolean(L, 2);
+	inst->visibilityAffectsChildren = param;
+	return 0;
+}
+
 static int Polycore_Entity_set_depthOnly(lua_State *L) {
 	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
 	Entity *inst = (Entity*)lua_topointer(L, 1);

+ 2 - 0
Bindings/Contents/LUA/Source/PolycodeLUA.cpp

@@ -206,6 +206,7 @@ int luaopen_Polycode(lua_State *L) {
 		{"Entity_get_depthTest", Polycore_Entity_get_depthTest},
 		{"Entity_get_blendingMode", Polycore_Entity_get_blendingMode},
 		{"Entity_get_colorAffectsChildren", Polycore_Entity_get_colorAffectsChildren},
+		{"Entity_get_visibilityAffectsChildren", Polycore_Entity_get_visibilityAffectsChildren},
 		{"Entity_get_depthOnly", Polycore_Entity_get_depthOnly},
 		{"Entity_get_bBox", Polycore_Entity_get_bBox},
 		{"Entity_get_ignoreParentMatrix", Polycore_Entity_get_ignoreParentMatrix},
@@ -222,6 +223,7 @@ int luaopen_Polycode(lua_State *L) {
 		{"Entity_set_depthTest", Polycore_Entity_set_depthTest},
 		{"Entity_set_blendingMode", Polycore_Entity_set_blendingMode},
 		{"Entity_set_colorAffectsChildren", Polycore_Entity_set_colorAffectsChildren},
+		{"Entity_set_visibilityAffectsChildren", Polycore_Entity_set_visibilityAffectsChildren},
 		{"Entity_set_depthOnly", Polycore_Entity_set_depthOnly},
 		{"Entity_set_ignoreParentMatrix", Polycore_Entity_set_ignoreParentMatrix},
 		{"Entity_set_isMask", Polycore_Entity_set_isMask},

+ 7 - 1
Core/Contents/Include/PolyEntity.h

@@ -529,7 +529,13 @@ namespace Polycode {
 			/**
 			* If set to false, the children of this entity will not multiply by this entity's color. Set to true by default.
 			*/ 
-			bool colorAffectsChildren;		
+			bool colorAffectsChildren;	
+
+			/**
+			* If set to false, the children will be rendered even if the entity is invisible.
+			*/ 
+			bool visibilityAffectsChildren;	
+
 			
 			/**
 			* If this flag is set to true, this entity will render only into the depth buffer. This, effectively, means that it will be invisible, but still obscuring other entities.

+ 9 - 8
Core/Contents/Source/PolyEntity.cpp

@@ -48,6 +48,7 @@ Entity::Entity() {
 	lockMatrix = false;
 	renderWireframe  = false;
 	colorAffectsChildren = true;
+	visibilityAffectsChildren = true;
 	maskEntity = NULL;
 	isMask = false;
 	hasMask = false;
@@ -323,14 +324,14 @@ void Entity::transformAndRender() {
 		renderer->setRenderMode(Renderer::RENDER_MODE_NORMAL);	
 	if(visible) {
 		Render();
-	
-	
-//	renderer->pushMatrix();
-	adjustMatrixForChildren();
-	renderChildren();	
-//	renderer->popMatrix();	
-	
-	}		
+	}
+		
+	if(visible || (!visible && !visibilityAffectsChildren)) {
+		adjustMatrixForChildren();
+		renderChildren();	
+	}
+		
+				
 	renderer->setRenderMode(mode);	
 	renderer->popMatrix();