Просмотр исходного кода

Convenience methods for dirtying mesh arrays, disabled non-working reliable data in Peer

Ivan Safrin 13 лет назад
Родитель
Сommit
87be8d27f2

+ 10 - 8
Bindings/Scripts/create_lua_library/create_lua_library.py

@@ -67,7 +67,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 	cppRegisterOut += "using namespace Polycode;\n\n"
 	cppRegisterOut += "using namespace Polycode;\n\n"
 	cppRegisterOut += "int luaopen_%s(lua_State *L) {\n" % (prefix)
 	cppRegisterOut += "int luaopen_%s(lua_State *L) {\n" % (prefix)
 	if prefix != "Polycode":
 	if prefix != "Polycode":
-		cppRegisterOut += "CoreServices *inst = (CoreServices*) *((void**)lua_topointer(L, 1));\n"
+		cppRegisterOut += "CoreServices *inst = (CoreServices*) *((void**)lua_touserdata(L, 1));\n"
 		cppRegisterOut += "CoreServices::setInstance(inst);\n"
 		cppRegisterOut += "CoreServices::setInstance(inst);\n"
 	cppRegisterOut += "\tstatic const struct luaL_reg %sLib [] = {" % (libSmallName)
 	cppRegisterOut += "\tstatic const struct luaL_reg %sLib [] = {" % (libSmallName)
 	
 	
@@ -238,7 +238,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 							cppRegisterOut += "\t\t{\"%s_get_%s\", %s_%s_get_%s},\n" % (ckey, pp["name"], libName, ckey, pp["name"])
 							cppRegisterOut += "\t\t{\"%s_get_%s\", %s_%s_get_%s},\n" % (ckey, pp["name"], libName, ckey, pp["name"])
 							wrappersHeaderOut += "static int %s_%s_get_%s(lua_State *L) {\n" % (libName, ckey, pp["name"])
 							wrappersHeaderOut += "static int %s_%s_get_%s(lua_State *L) {\n" % (libName, ckey, pp["name"])
 							wrappersHeaderOut += "\tluaL_checktype(L, 1, LUA_TUSERDATA);\n"
 							wrappersHeaderOut += "\tluaL_checktype(L, 1, LUA_TUSERDATA);\n"
-							wrappersHeaderOut += "\t%s *inst = (%s*) *((void**)lua_topointer(L, 1));\n" % (ckey, ckey)
+							wrappersHeaderOut += "\t%s *inst = (%s*) *((void**)lua_touserdata(L, 1));\n" % (ckey, ckey)
 
 
 							outfunc = "this_shouldnt_happen"
 							outfunc = "this_shouldnt_happen"
 							retFunc = ""
 							retFunc = ""
@@ -291,7 +291,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 							cppRegisterOut += "\t\t{\"%s_set_%s\", %s_%s_set_%s},\n" % (ckey, pp["name"], libName, ckey, pp["name"])
 							cppRegisterOut += "\t\t{\"%s_set_%s\", %s_%s_set_%s},\n" % (ckey, pp["name"], libName, ckey, pp["name"])
 							wrappersHeaderOut += "static int %s_%s_set_%s(lua_State *L) {\n" % (libName, ckey, pp["name"])
 							wrappersHeaderOut += "static int %s_%s_set_%s(lua_State *L) {\n" % (libName, ckey, pp["name"])
 							wrappersHeaderOut += "\tluaL_checktype(L, 1, LUA_TUSERDATA);\n"
 							wrappersHeaderOut += "\tluaL_checktype(L, 1, LUA_TUSERDATA);\n"
-							wrappersHeaderOut += "\t%s *inst = (%s*) *((void**)lua_topointer(L, 1));\n" % (ckey, ckey)
+							wrappersHeaderOut += "\t%s *inst = (%s*) *((void**)lua_touserdata(L, 1));\n" % (ckey, ckey)
 
 
 							outfunc = "this_shouldnt_happen"
 							outfunc = "this_shouldnt_happen"
 							if pp["type"] == "Number":
 							if pp["type"] == "Number":
@@ -356,7 +356,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 						# Skip static methods (TODO: Figure out, why is this being done here?). # FIXME
 						# Skip static methods (TODO: Figure out, why is this being done here?). # FIXME
 						if pm["rtnType"].find("static ") == -1:
 						if pm["rtnType"].find("static ") == -1:
 							wrappersHeaderOut += "\tluaL_checktype(L, 1, LUA_TUSERDATA);\n"
 							wrappersHeaderOut += "\tluaL_checktype(L, 1, LUA_TUSERDATA);\n"
-							wrappersHeaderOut += "\t%s *inst = (%s*) *((void**)lua_topointer(L, 1));\n" % (ckey, ckey)
+							wrappersHeaderOut += "\t%s *inst = (%s*) *((void**)lua_touserdata(L, 1));\n" % (ckey, ckey)
 							idx = 2
 							idx = 2
 						else:
 						else:
 							idx = 1
 							idx = 1
@@ -380,11 +380,11 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 								luatype = "LUA_TUSERDATA"
 								luatype = "LUA_TUSERDATA"
 								checkfunc = "lua_isuserdata"
 								checkfunc = "lua_isuserdata"
 								if param["type"].find("*") > -1:
 								if param["type"].find("*") > -1:
-									luafunc = "(%s) *((void**)lua_topointer" % (param["type"].replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
+									luafunc = "(%s) *((void**)lua_touserdata" % (param["type"].replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
 								elif param["type"].find("&") > -1:
 								elif param["type"].find("&") > -1:
-									luafunc = "*(%s*) *((void**)lua_topointer" % (param["type"].replace("const", "").replace("&", "").replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
+									luafunc = "*(%s*) *((void**)lua_touserdata" % (param["type"].replace("const", "").replace("&", "").replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
 								else:
 								else:
-									luafunc = "*(%s*) *((void**)lua_topointer" % (param["type"].replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
+									luafunc = "*(%s*) *((void**)lua_touserdata" % (param["type"].replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
 								lend = ".__ptr"
 								lend = ".__ptr"
 								luafuncsuffix = ")"
 								luafuncsuffix = ")"
 								if param["type"] == "int" or param["type"] == "unsigned int" or param["type"] == "short":
 								if param["type"] == "int" or param["type"] == "unsigned int" or param["type"] == "short":
@@ -600,11 +600,13 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 					cppLoaderOut += "\tlua_pushcfunction(L, %s_delete_%s);\n" % (libName, ckey)
 					cppLoaderOut += "\tlua_pushcfunction(L, %s_delete_%s);\n" % (libName, ckey)
 					cppLoaderOut += "\tlua_settable(L, -3);\n"
 					cppLoaderOut += "\tlua_settable(L, -3);\n"
 				
 				
+	
+
 				# Delete method (C++ side)
 				# Delete method (C++ side)
 				cppRegisterOut += "\t\t{\"delete_%s\", %s_delete_%s},\n" % (ckey, libName, ckey)
 				cppRegisterOut += "\t\t{\"delete_%s\", %s_delete_%s},\n" % (ckey, libName, ckey)
 				wrappersHeaderOut += "static int %s_delete_%s(lua_State *L) {\n" % (libName, ckey)
 				wrappersHeaderOut += "static int %s_delete_%s(lua_State *L) {\n" % (libName, ckey)
 				wrappersHeaderOut += "\tluaL_checktype(L, 1, LUA_TUSERDATA);\n"
 				wrappersHeaderOut += "\tluaL_checktype(L, 1, LUA_TUSERDATA);\n"
-				wrappersHeaderOut += "\t%s *inst = (%s*) *((void**)lua_topointer(L, 1));\n" % (ckey, ckey)
+				wrappersHeaderOut += "\t%s *inst = (%s*) *((void**)lua_touserdata(L, 1));\n" % (ckey, ckey)
 				wrappersHeaderOut += "\tdelete inst;\n"
 				wrappersHeaderOut += "\tdelete inst;\n"
 				wrappersHeaderOut += "\treturn 0;\n"
 				wrappersHeaderOut += "\treturn 0;\n"
 				wrappersHeaderOut += "}\n\n"
 				wrappersHeaderOut += "}\n\n"

+ 4 - 0
Core/Contents/Include/PolyMesh.h

@@ -288,6 +288,9 @@ namespace Polycode {
 			*/ 
 			*/ 
 			void setMeshType(int newType);
 			void setMeshType(int newType);
 
 
+			void dirtyArray(unsigned int arrayIndex);
+			void dirtyArrays();
+
 			/**
 			/**
 			* Calculates the mesh bounding box.
 			* Calculates the mesh bounding box.
 			*/
 			*/
@@ -352,6 +355,7 @@ namespace Polycode {
 			* If set to true, the renderer will use the vertex colors instead of entity color transform to render this mesh.
 			* If set to true, the renderer will use the vertex colors instead of entity color transform to render this mesh.
 			*/
 			*/
 			bool useVertexColors;
 			bool useVertexColors;
+			
 		
 		
 		protected:
 		protected:
 					
 					

+ 11 - 6
Core/Contents/Include/PolyScreenMesh.h

@@ -37,20 +37,25 @@ namespace Polycode {
 	class _PolyExport ScreenMesh : public ScreenEntity {
 	class _PolyExport ScreenMesh : public ScreenEntity {
 		public:
 		public:
 		
 		
-			/**
-			* Creates the screen mesh from existing Mesh.
-			*/
-			ScreenMesh(Mesh *mesh);
-			
 			/**
 			/**
 			* Creates the screen mesh and loads a mesh from a file name.
 			* Creates the screen mesh and loads a mesh from a file name.
 			*/
 			*/
 			ScreenMesh(const String& fileName);
 			ScreenMesh(const String& fileName);
-			
+		
+			/**
+			* Creates the screen mesh from existing Mesh.
+			*/
+			ScreenMesh(Mesh *mesh);
+						
 			/**
 			/**
 			* Create an empty screen mesh of specified type. See Mesh for available mesh types.
 			* Create an empty screen mesh of specified type. See Mesh for available mesh types.
 			*/
 			*/
 			ScreenMesh(int meshType);
 			ScreenMesh(int meshType);
+			
+			// Static constructor wrappers for bindings
+			static ScreenMesh *ScreenMeshWithType(int meshType);
+			static ScreenMesh *ScreenMeshWithMesh(Mesh *mesh);
+						
 			virtual ~ScreenMesh();
 			virtual ~ScreenMesh();
 			
 			
 			void Render();
 			void Render();

+ 0 - 7
Core/Contents/Source/PolyGLVertexBuffer.cpp

@@ -48,13 +48,6 @@ extern PFNGLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB;
 #endif
 #endif
 
 
 OpenGLVertexBuffer::OpenGLVertexBuffer(Mesh *mesh) : VertexBuffer() {
 OpenGLVertexBuffer::OpenGLVertexBuffer(Mesh *mesh) : VertexBuffer() {
-	if(mesh->getMeshType() == Mesh::QUAD_MESH) {
-		verticesPerFace = 4;		
-	} else {
-		verticesPerFace = 3;				
-	}
-	meshType = mesh->getMeshType();
-	
 	glGenBuffersARB(1, &vertexBufferID);
 	glGenBuffersARB(1, &vertexBufferID);
 	glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBufferID);
 	glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBufferID);
 	
 	

+ 12 - 0
Core/Contents/Source/PolyMesh.cpp

@@ -715,6 +715,18 @@ namespace Polycode {
 		arrayDirtyMap[RenderDataArray::TANGENT_DATA_ARRAY] = true;									
 		arrayDirtyMap[RenderDataArray::TANGENT_DATA_ARRAY] = true;									
 	}
 	}
 	
 	
+	void Mesh::dirtyArray(unsigned int arrayIndex) {
+		if(arrayIndex < 16)
+			arrayDirtyMap[arrayIndex] = true;				
+	}
+	
+	void Mesh::dirtyArrays() {
+		for(int i=0; i < 16; i++) {
+			arrayDirtyMap[i] = true;
+		}
+	}
+	
+	
 	void Mesh::useVertexNormals(bool val) {
 	void Mesh::useVertexNormals(bool val) {
 		for(int i =0; i < polygons.size(); i++) {
 		for(int i =0; i < polygons.size(); i++) {
 			polygons[i]->useVertexNormals = val;
 			polygons[i]->useVertexNormals = val;

+ 1 - 1
Core/Contents/Source/PolyPeer.cpp

@@ -113,7 +113,7 @@ void Peer::sendReliableData(const Address &target, char *data, unsigned int size
 	SentPacketEntry entry;
 	SentPacketEntry entry;
 	entry.packet = packet;
 	entry.packet = packet;
 	entry.timestamp = CoreServices::getInstance()->getCore()->getTicks();
 	entry.timestamp = CoreServices::getInstance()->getCore()->getTicks();
-	connection->reliablePacketQueue.push_back(entry);
+//	connection->reliablePacketQueue.push_back(entry);
 
 
 }
 }
 
 

+ 7 - 0
Core/Contents/Source/PolyScreenMesh.cpp

@@ -50,6 +50,13 @@ ScreenMesh::ScreenMesh(int meshType) : ScreenEntity(), texture(NULL) {
 	
 	
 }
 }
 
 
+ScreenMesh *ScreenMesh::ScreenMeshWithMesh(Mesh *mesh) {
+	return new ScreenMesh(mesh);
+}
+
+ScreenMesh *ScreenMesh::ScreenMeshWithType(int meshType) {
+	return new ScreenMesh(meshType);
+}
 
 
 ScreenMesh::~ScreenMesh() {
 ScreenMesh::~ScreenMesh() {
 	if(ownsMesh) {
 	if(ownsMesh) {

+ 2 - 1
IDE/Contents/Source/PolycodeConsole.cpp

@@ -233,9 +233,10 @@ void PolycodeConsole::_clearBacktraces() {
 }
 }
 
 
 
 
-void PolycodeConsole::_print(String msg) {
+void PolycodeConsole::_print(String msg) {	
 	debugTextInput->setText(debugTextInput->getText()+msg);
 	debugTextInput->setText(debugTextInput->getText()+msg);
 	debugTextInput->getScrollContainer()->setScrollValue(0, 1.0);
 	debugTextInput->getScrollContainer()->setScrollValue(0, 1.0);
+	printf("%s", msg.c_str());
 }
 }
 
 
 void PolycodeConsole::Resize(Number width, Number height) {
 void PolycodeConsole::Resize(Number width, Number height) {