| 
									
										
										
										
											2011-02-23 10:52:22 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							| 
									
										
										
										
											2011-11-29 10:54:47 +00:00
										 |  |  |  * of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2005 Blender Foundation. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is: all of this file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): Brecht Van Lommel. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-27 20:25:53 +00:00
										 |  |  | /** \file blender/gpu/intern/gpu_buffers.c
 | 
					
						
							|  |  |  |  *  \ingroup gpu | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | #include <limits.h>
 | 
					
						
							| 
									
										
										
										
											2009-11-25 18:20:46 +00:00
										 |  |  | #include <stddef.h>
 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | #include <string.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "GL/glew.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							| 
									
										
										
										
											2009-10-05 16:48:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | #include "BLI_bitmap.h"
 | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | #include "BLI_math.h"
 | 
					
						
							| 
									
										
										
										
											2011-01-07 18:36:47 +00:00
										 |  |  | #include "BLI_utildefines.h"
 | 
					
						
							|  |  |  | #include "BLI_ghash.h"
 | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | #include "BLI_threads.h"
 | 
					
						
							| 
									
										
										
										
											2009-10-05 16:48:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "DNA_meshdata_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | #include "BKE_ccg.h"
 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | #include "BKE_DerivedMesh.h"
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | #include "BKE_paint.h"
 | 
					
						
							|  |  |  | #include "BKE_subsurf.h"
 | 
					
						
							| 
									
										
										
										
											2009-10-05 16:48:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "DNA_userdef_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-14 10:46:12 +00:00
										 |  |  | #include "GPU_buffers.h"
 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | typedef enum { | 
					
						
							|  |  |  | 	GPU_BUFFER_VERTEX_STATE = 1, | 
					
						
							|  |  |  | 	GPU_BUFFER_NORMAL_STATE = 2, | 
					
						
							|  |  |  | 	GPU_BUFFER_TEXCOORD_STATE = 4, | 
					
						
							|  |  |  | 	GPU_BUFFER_COLOR_STATE = 8, | 
					
						
							|  |  |  | 	GPU_BUFFER_ELEMENT_STATE = 16, | 
					
						
							|  |  |  | } GPUBufferState; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define MAX_GPU_ATTRIB_DATA 32
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-15 19:04:00 +00:00
										 |  |  | /* material number is an 16-bit short and the range of short is from -16383 to 16383 (assume material number is non-negative) */ | 
					
						
							|  |  |  | #define MAX_MATERIALS 16384
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | /* -1 - undefined, 0 - vertex arrays, 1 - VBOs */ | 
					
						
							| 
									
										
										
										
											2011-02-13 14:16:36 +00:00
										 |  |  | static int useVBOs = -1; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static GPUBufferState GLStates = 0; | 
					
						
							| 
									
										
										
										
											2011-02-13 14:16:36 +00:00
										 |  |  | static GPUAttrib attribData[MAX_GPU_ATTRIB_DATA] = { { -1, 0, 0 } }; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* stores recently-deleted buffers so that new buffers won't have to
 | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  |  * be recreated as often | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * only one instance of this pool is created, stored in | 
					
						
							|  |  |  |  * gpu_buffer_pool | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * note that the number of buffers in the pool is usually limited to | 
					
						
							|  |  |  |  * MAX_FREE_GPU_BUFFERS, but this limit may be exceeded temporarily | 
					
						
							|  |  |  |  * when a GPUBuffer is released outside the main thread; due to OpenGL | 
					
						
							|  |  |  |  * restrictions it cannot be immediately released | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | typedef struct GPUBufferPool { | 
					
						
							|  |  |  | 	/* number of allocated buffers stored */ | 
					
						
							|  |  |  | 	int totbuf; | 
					
						
							|  |  |  | 	/* actual allocated length of the array */ | 
					
						
							|  |  |  | 	int maxsize; | 
					
						
							|  |  |  | 	GPUBuffer **buffers; | 
					
						
							|  |  |  | } GPUBufferPool; | 
					
						
							|  |  |  | #define MAX_FREE_GPU_BUFFERS 8
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* create a new GPUBufferPool */ | 
					
						
							|  |  |  | static GPUBufferPool *gpu_buffer_pool_new(void) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	GPUBufferPool *pool; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* enable VBOs if supported */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs == -1) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		useVBOs = (GLEW_ARB_vertex_buffer_object ? 1 : 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-22 17:33:58 +00:00
										 |  |  | 	pool = MEM_callocN(sizeof(GPUBufferPool), "GPUBuffer_Pool"); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 	pool->maxsize = MAX_FREE_GPU_BUFFERS; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	pool->buffers = MEM_callocN(sizeof(GPUBuffer *) * pool->maxsize, | 
					
						
							|  |  |  | 	                            "GPUBuffer.buffers"); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return pool; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* remove a GPUBuffer from the pool (does not free the GPUBuffer) */ | 
					
						
							|  |  |  | static void gpu_buffer_pool_remove_index(GPUBufferPool *pool, int index) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!pool || index < 0 || index >= pool->totbuf) | 
					
						
							| 
									
										
										
										
											2010-02-17 18:48:02 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* shift entries down, overwriting the buffer at `index' */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = index; i < pool->totbuf - 1; i++) | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		pool->buffers[i] = pool->buffers[i + 1]; | 
					
						
							| 
									
										
										
										
											2010-02-15 19:09:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* clear the last entry */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (pool->totbuf > 0) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		pool->buffers[pool->totbuf - 1] = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pool->totbuf--; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* delete the last entry in the pool */ | 
					
						
							|  |  |  | static void gpu_buffer_pool_delete_last(GPUBufferPool *pool) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GPUBuffer *last; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (pool->totbuf <= 0) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* get the last entry */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!(last = pool->buffers[pool->totbuf - 1])) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* delete the buffer's data */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glDeleteBuffersARB(1, &last->id); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		MEM_freeN(last->pointer); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* delete the buffer and remove from pool */ | 
					
						
							|  |  |  | 	MEM_freeN(last); | 
					
						
							|  |  |  | 	pool->totbuf--; | 
					
						
							|  |  |  | 	pool->buffers[pool->totbuf] = NULL; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* free a GPUBufferPool; also frees the data in the pool's
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * GPUBuffers */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static void gpu_buffer_pool_free(GPUBufferPool *pool) | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!pool) | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 	while (pool->totbuf) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		gpu_buffer_pool_delete_last(pool); | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	MEM_freeN(pool->buffers); | 
					
						
							|  |  |  | 	MEM_freeN(pool); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static GPUBufferPool *gpu_buffer_pool = NULL; | 
					
						
							|  |  |  | static GPUBufferPool *gpu_get_global_buffer_pool(void) | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* initialize the pool */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_pool) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		gpu_buffer_pool = gpu_buffer_pool_new(); | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	return gpu_buffer_pool; | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_global_buffer_pool_free(void) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	gpu_buffer_pool_free(gpu_buffer_pool); | 
					
						
							|  |  |  | 	gpu_buffer_pool = NULL; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* get a GPUBuffer of at least `size' bytes; uses one from the buffer
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * pool if possible, otherwise creates a new one */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | GPUBuffer *GPU_buffer_alloc(int size) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	GPUBufferPool *pool; | 
					
						
							|  |  |  | 	GPUBuffer *buf; | 
					
						
							|  |  |  | 	int i, bufsize, bestfit = -1; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-22 17:33:58 +00:00
										 |  |  | 	/* bad case, leads to leak of buf since buf->pointer will allocate
 | 
					
						
							|  |  |  | 	 * NULL, leading to return without cleanup. In any case better detect early | 
					
						
							|  |  |  | 	 * psy-fi */ | 
					
						
							| 
									
										
										
										
											2012-05-22 22:03:41 +00:00
										 |  |  | 	if (size == 0) | 
					
						
							| 
									
										
										
										
											2012-05-22 17:33:58 +00:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	pool = gpu_get_global_buffer_pool(); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* not sure if this buffer pool code has been profiled much,
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 	 * seems to me that the graphics driver and system memory | 
					
						
							|  |  |  | 	 * management might do this stuff anyway. --nicholas | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* check the global buffer pool for a recently-deleted buffer
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 	 * that is at least as big as the request, but not more than | 
					
						
							|  |  |  | 	 * twice as big */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < pool->totbuf; i++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		bufsize = pool->buffers[i]->size; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* check for an exact size match */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (bufsize == size) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			bestfit = i; | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* smaller buffers won't fit data and buffers at least
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 		 * twice as big are a waste of memory */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		else if (bufsize > size && size > (bufsize / 2)) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			/* is it closer to the required size than the
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 			 * last appropriate buffer found. try to save | 
					
						
							|  |  |  | 			 * memory */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (bestfit == -1 || pool->buffers[bestfit]->size > bufsize) { | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 				bestfit = i; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* if an acceptable buffer was found in the pool, remove it
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 	 * from the pool and return it */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (bestfit != -1) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		buf = pool->buffers[bestfit]; | 
					
						
							|  |  |  | 		gpu_buffer_pool_remove_index(pool, bestfit); | 
					
						
							|  |  |  | 		return buf; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* no acceptable buffer found in the pool, create a new one */ | 
					
						
							|  |  |  | 	buf = MEM_callocN(sizeof(GPUBuffer), "GPUBuffer"); | 
					
						
							|  |  |  | 	buf->size = size; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs == 1) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* create a new VBO and initialize it to the requested
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 		 * size */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glGenBuffersARB(1, &buf->id); | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, buf->id); | 
					
						
							| 
									
										
										
										
											2011-09-16 08:20:21 +00:00
										 |  |  | 		glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		buf->pointer = MEM_mallocN(size, "GPUBuffer.pointer"); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		/* purpose of this seems to be dealing with
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 		 * out-of-memory errors? looks a bit iffy to me | 
					
						
							|  |  |  | 		 * though, at least on Linux I expect malloc() would | 
					
						
							|  |  |  | 		 * just overcommit. --nicholas */ | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 		while (!buf->pointer && pool->totbuf > 0) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			gpu_buffer_pool_delete_last(pool); | 
					
						
							|  |  |  | 			buf->pointer = MEM_mallocN(size, "GPUBuffer.pointer"); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (!buf->pointer) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			return NULL; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return buf; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* release a GPUBuffer; does not free the actual buffer or its data,
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * but rather moves it to the pool of recently-freed buffers for | 
					
						
							|  |  |  |  * possible re-use*/ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_buffer_free(GPUBuffer *buffer) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GPUBufferPool *pool; | 
					
						
							| 
									
										
										
										
											2010-02-17 18:48:02 +00:00
										 |  |  | 	int i; | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!buffer) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	pool = gpu_get_global_buffer_pool(); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 	/* free the last used buffer in the queue if no more space, but only
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 	 * if we are in the main thread. for e.g. rendering or baking it can | 
					
						
							|  |  |  | 	 * happen that we are in other thread and can't call OpenGL, in that | 
					
						
							|  |  |  | 	 * case cleanup will be done GPU_buffer_pool_free_unused */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (BLI_thread_is_main()) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* in main thread, safe to decrease size of pool back
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 		 * down to MAX_FREE_GPU_BUFFERS */ | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 		while (pool->totbuf >= MAX_FREE_GPU_BUFFERS) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			gpu_buffer_pool_delete_last(pool); | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* outside of main thread, can't safely delete the
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 		 * buffer, so increase pool size */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (pool->maxsize == pool->totbuf) { | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 			pool->maxsize += MAX_FREE_GPU_BUFFERS; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			pool->buffers = MEM_reallocN(pool->buffers, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			                             sizeof(GPUBuffer *) * pool->maxsize); | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* shift pool entries up by one */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = pool->totbuf; i > 0; i--) | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		pool->buffers[i] = pool->buffers[i - 1]; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* insert the buffer into the beginning of the pool */ | 
					
						
							| 
									
										
										
										
											2010-02-17 18:48:02 +00:00
										 |  |  | 	pool->buffers[0] = buffer; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	pool->totbuf++; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | typedef struct GPUVertPointLink { | 
					
						
							|  |  |  | 	struct GPUVertPointLink *next; | 
					
						
							|  |  |  | 	/* -1 means uninitialized */ | 
					
						
							|  |  |  | 	int point_index; | 
					
						
							|  |  |  | } GPUVertPointLink; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* add a new point to the list of points related to a particular
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * vertex */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static void gpu_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, int point_index) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GPUVertPointLink *lnk; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	lnk = &gdo->vert_points[vert_index]; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* if first link is in use, add a new link at the end */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (lnk->point_index != -1) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* get last link */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		for (; lnk->next; lnk = lnk->next) ; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* add a new link from the pool */ | 
					
						
							|  |  |  | 		lnk = lnk->next = &gdo->vert_points_mem[gdo->vert_points_usage]; | 
					
						
							|  |  |  | 		gdo->vert_points_usage++; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	lnk->point_index = point_index; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* update the vert_points and triangle_to_mface fields with a new
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * triangle */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static void gpu_drawobject_add_triangle(GPUDrawObject *gdo, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  |                                         int base_point_index, | 
					
						
							|  |  |  |                                         int face_index, | 
					
						
							|  |  |  |                                         int v1, int v2, int v3) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int i, v[3] = {v1, v2, v3}; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < 3; i++) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		gpu_drawobject_add_vert_point(gdo, v[i], base_point_index + i); | 
					
						
							|  |  |  | 	gdo->triangle_to_mface[base_point_index / 3] = face_index; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* for each vertex, build a list of points related to it; these lists
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * are stored in an array sized to the number of vertices */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int totface) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	GPUBufferMaterial *mat; | 
					
						
							|  |  |  | 	int i, mat_orig_to_new[MAX_MATERIALS]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* allocate the array and space for links */ | 
					
						
							|  |  |  | 	gdo->vert_points = MEM_callocN(sizeof(GPUVertPointLink) * gdo->totvert, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	                               "GPUDrawObject.vert_points"); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	gdo->vert_points_mem = MEM_callocN(sizeof(GPUVertPointLink) * gdo->tot_triangle_point, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	                                   "GPUDrawObject.vert_points_mem"); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	gdo->vert_points_usage = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* build a map from the original material indices to the new
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 	 * GPUBufferMaterial indices */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < gdo->totmaterial; i++) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		mat_orig_to_new[gdo->materials[i].mat_nr] = i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* -1 indicates the link is not yet used */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < gdo->totvert; i++) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		gdo->vert_points[i].point_index = -1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < totface; i++, f++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		mat = &gdo->materials[mat_orig_to_new[f->mat_nr]]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* add triangle */ | 
					
						
							|  |  |  | 		gpu_drawobject_add_triangle(gdo, mat->start + mat->totpoint, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		                            i, f->v1, f->v2, f->v3); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		mat->totpoint += 3; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* add second triangle for quads */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (f->v4) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			gpu_drawobject_add_triangle(gdo, mat->start + mat->totpoint, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			                            i, f->v3, f->v4, f->v1); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			mat->totpoint += 3; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* map any unused vertices to loose points */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < gdo->totvert; i++) { | 
					
						
							|  |  |  | 		if (gdo->vert_points[i].point_index == -1) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			gdo->vert_points[i].point_index = gdo->tot_triangle_point + gdo->tot_loose_point; | 
					
						
							|  |  |  | 			gdo->tot_loose_point++; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* see GPUDrawObject's structure definition for a description of the
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * data being initialized here */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | GPUDrawObject *GPU_drawobject_new(DerivedMesh *dm) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	GPUDrawObject *gdo; | 
					
						
							|  |  |  | 	MFace *mface; | 
					
						
							|  |  |  | 	int points_per_mat[MAX_MATERIALS]; | 
					
						
							|  |  |  | 	int i, curmat, curpoint, totface; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-26 03:00:55 +00:00
										 |  |  | 	mface = dm->getTessFaceArray(dm); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	totface = dm->getNumTessFaces(dm); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* get the number of points used by each material, treating
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 	 * each quad as two triangles */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	memset(points_per_mat, 0, sizeof(int) * MAX_MATERIALS); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < totface; i++) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		points_per_mat[mface[i].mat_nr] += mface[i].v4 ? 6 : 3; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* create the GPUDrawObject */ | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 	gdo = MEM_callocN(sizeof(GPUDrawObject), "GPUDrawObject"); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	gdo->totvert = dm->getNumVerts(dm); | 
					
						
							|  |  |  | 	gdo->totedge = dm->getNumEdges(dm); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* count the number of materials used by this DerivedMesh */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < MAX_MATERIALS; i++) { | 
					
						
							|  |  |  | 		if (points_per_mat[i] > 0) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			gdo->totmaterial++; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* allocate an array of materials used by this DerivedMesh */ | 
					
						
							|  |  |  | 	gdo->materials = MEM_mallocN(sizeof(GPUBufferMaterial) * gdo->totmaterial, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	                             "GPUDrawObject.materials"); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* initialize the materials array */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0, curmat = 0, curpoint = 0; i < MAX_MATERIALS; i++) { | 
					
						
							|  |  |  | 		if (points_per_mat[i] > 0) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			gdo->materials[curmat].start = curpoint; | 
					
						
							|  |  |  | 			gdo->materials[curmat].totpoint = 0; | 
					
						
							|  |  |  | 			gdo->materials[curmat].mat_nr = i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			curpoint += points_per_mat[i]; | 
					
						
							|  |  |  | 			curmat++; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* store total number of points used for triangles */ | 
					
						
							|  |  |  | 	gdo->tot_triangle_point = curpoint; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	gdo->triangle_to_mface = MEM_mallocN(sizeof(int) * (gdo->tot_triangle_point / 3), | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	                                     "GPUDrawObject.triangle_to_mface"); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	gpu_drawobject_init_vert_points(gdo, mface, totface); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return gdo; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_drawobject_free(DerivedMesh *dm) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GPUDrawObject *gdo; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!dm || !(gdo = dm->drawObject)) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	MEM_freeN(gdo->materials); | 
					
						
							|  |  |  | 	MEM_freeN(gdo->triangle_to_mface); | 
					
						
							|  |  |  | 	MEM_freeN(gdo->vert_points); | 
					
						
							|  |  |  | 	MEM_freeN(gdo->vert_points_mem); | 
					
						
							|  |  |  | 	GPU_buffer_free(gdo->points); | 
					
						
							|  |  |  | 	GPU_buffer_free(gdo->normals); | 
					
						
							|  |  |  | 	GPU_buffer_free(gdo->uv); | 
					
						
							|  |  |  | 	GPU_buffer_free(gdo->colors); | 
					
						
							|  |  |  | 	GPU_buffer_free(gdo->edges); | 
					
						
							|  |  |  | 	GPU_buffer_free(gdo->uvedges); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	MEM_freeN(gdo); | 
					
						
							|  |  |  | 	dm->drawObject = NULL; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | typedef void (*GPUBufferCopyFunc)(DerivedMesh *dm, float *varray, int *index, | 
					
						
							| 
									
										
										
										
											2011-11-11 13:09:14 +00:00
										 |  |  |                                   int *mat_orig_to_new, void *user_data); | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, | 
					
						
							| 
									
										
										
										
											2011-11-11 13:09:14 +00:00
										 |  |  |                                    int vector_size, int size, GLenum target, | 
					
						
							|  |  |  |                                    void *user, GPUBufferCopyFunc copy_f) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	GPUBufferPool *pool; | 
					
						
							|  |  |  | 	GPUBuffer *buffer; | 
					
						
							|  |  |  | 	float *varray; | 
					
						
							|  |  |  | 	int mat_orig_to_new[MAX_MATERIALS]; | 
					
						
							|  |  |  | 	int *cur_index_per_mat; | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 	int success; | 
					
						
							|  |  |  | 	GLboolean uploaded; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	pool = gpu_get_global_buffer_pool(); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* alloc a GPUBuffer; fall back to legacy mode on failure */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!(buffer = GPU_buffer_alloc(size))) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		dm->drawObject->legacy = 1; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* nothing to do for legacy mode */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (dm->drawObject->legacy) | 
					
						
							| 
									
										
										
										
											2011-09-16 08:20:21 +00:00
										 |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	cur_index_per_mat = MEM_mallocN(sizeof(int) * object->totmaterial, | 
					
						
							|  |  |  | 	                                "GPU_buffer_setup.cur_index_per_mat"); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < object->totmaterial; i++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* for each material, the current index to copy data to */ | 
					
						
							|  |  |  | 		cur_index_per_mat[i] = object->materials[i].start * vector_size; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* map from original material index to new
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 		 * GPUBufferMaterial index */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		mat_orig_to_new[object->materials[i].mat_nr] = i; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		success = 0; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 		while (!success) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			/* bind the buffer and discard previous data,
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 			 * avoids stalling gpu */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glBindBufferARB(target, buffer->id); | 
					
						
							| 
									
										
										
										
											2011-09-16 08:20:21 +00:00
										 |  |  | 			glBufferDataARB(target, buffer->size, NULL, GL_STATIC_DRAW_ARB); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			/* attempt to map the buffer */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (!(varray = glMapBufferARB(target, GL_WRITE_ONLY_ARB))) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 				/* failed to map the buffer; delete it */ | 
					
						
							|  |  |  | 				GPU_buffer_free(buffer); | 
					
						
							|  |  |  | 				gpu_buffer_pool_delete_last(pool); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				buffer = NULL; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				/* try freeing an entry from the pool
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 				 * and reallocating the buffer */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (pool->totbuf > 0) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 					gpu_buffer_pool_delete_last(pool); | 
					
						
							|  |  |  | 					buffer = GPU_buffer_alloc(size); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				/* allocation still failed; fall back
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 				 * to legacy mode */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (!buffer) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 					dm->drawObject->legacy = 1; | 
					
						
							|  |  |  | 					success = 1; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							|  |  |  | 				success = 1; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* check legacy fallback didn't happen */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (dm->drawObject->legacy == 0) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			uploaded = GL_FALSE; | 
					
						
							|  |  |  | 			/* attempt to upload the data to the VBO */ | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 			while (uploaded == GL_FALSE) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 				(*copy_f)(dm, varray, cur_index_per_mat, mat_orig_to_new, user); | 
					
						
							|  |  |  | 				/* glUnmapBuffer returns GL_FALSE if
 | 
					
						
							| 
									
										
										
										
											2011-11-11 13:09:14 +00:00
										 |  |  | 				 * the data store is corrupted; retry | 
					
						
							|  |  |  | 				 * in that case */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 				uploaded = glUnmapBufferARB(target); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		glBindBufferARB(target, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		/* VBO not supported, use vertex array fallback */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (buffer->pointer) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			varray = buffer->pointer; | 
					
						
							|  |  |  | 			(*copy_f)(dm, varray, cur_index_per_mat, mat_orig_to_new, user); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			dm->drawObject->legacy = 1; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	MEM_freeN(cur_index_per_mat); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return buffer; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static void GPU_buffer_copy_vertex(DerivedMesh *dm, float *varray, int *index, int *mat_orig_to_new, void *UNUSED(user)) | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	MVert *mvert; | 
					
						
							|  |  |  | 	MFace *f; | 
					
						
							|  |  |  | 	int i, j, start, totface; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	mvert = dm->getVertArray(dm); | 
					
						
							| 
									
										
										
										
											2011-07-26 03:00:55 +00:00
										 |  |  | 	f = dm->getTessFaceArray(dm); | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	totface = dm->getNumTessFaces(dm); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < totface; i++, f++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		start = index[mat_orig_to_new[f->mat_nr]]; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* v1 v2 v3 */ | 
					
						
							|  |  |  | 		copy_v3_v3(&varray[start], mvert[f->v1].co); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		copy_v3_v3(&varray[start + 3], mvert[f->v2].co); | 
					
						
							|  |  |  | 		copy_v3_v3(&varray[start + 6], mvert[f->v3].co); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		index[mat_orig_to_new[f->mat_nr]] += 9; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (f->v4) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			/* v3 v4 v1 */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			copy_v3_v3(&varray[start + 9], mvert[f->v3].co); | 
					
						
							|  |  |  | 			copy_v3_v3(&varray[start + 12], mvert[f->v4].co); | 
					
						
							|  |  |  | 			copy_v3_v3(&varray[start + 15], mvert[f->v1].co); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			index[mat_orig_to_new[f->mat_nr]] += 9; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-11-02 13:12:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* copy loose points */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	j = dm->drawObject->tot_triangle_point * 3; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < dm->drawObject->totvert; i++) { | 
					
						
							|  |  |  | 		if (dm->drawObject->vert_points[i].point_index >= dm->drawObject->tot_triangle_point) { | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 			copy_v3_v3(&varray[j], mvert[i].co); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			j += 3; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, int *mat_orig_to_new, void *UNUSED(user)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i, totface; | 
					
						
							|  |  |  | 	int start; | 
					
						
							|  |  |  | 	float f_no[3]; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	MVert *mvert = dm->getVertArray(dm); | 
					
						
							| 
									
										
										
										
											2011-07-26 03:00:55 +00:00
										 |  |  | 	MFace *f = dm->getTessFaceArray(dm); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	totface = dm->getNumTessFaces(dm); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < totface; i++, f++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		const int smoothnormal = (f->flag & ME_SMOOTH); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		start = index[mat_orig_to_new[f->mat_nr]]; | 
					
						
							|  |  |  | 		index[mat_orig_to_new[f->mat_nr]] += f->v4 ? 18 : 9; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (smoothnormal) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			/* copy vertex normal */ | 
					
						
							|  |  |  | 			normal_short_to_float_v3(&varray[start], mvert[f->v1].no); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			normal_short_to_float_v3(&varray[start + 3], mvert[f->v2].no); | 
					
						
							|  |  |  | 			normal_short_to_float_v3(&varray[start + 6], mvert[f->v3].no); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (f->v4) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				normal_short_to_float_v3(&varray[start + 9], mvert[f->v3].no); | 
					
						
							|  |  |  | 				normal_short_to_float_v3(&varray[start + 12], mvert[f->v4].no); | 
					
						
							|  |  |  | 				normal_short_to_float_v3(&varray[start + 15], mvert[f->v1].no); | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		else if (nors) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			/* copy cached face normal */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			copy_v3_v3(&varray[start], &nors[i * 3]); | 
					
						
							|  |  |  | 			copy_v3_v3(&varray[start + 3], &nors[i * 3]); | 
					
						
							|  |  |  | 			copy_v3_v3(&varray[start + 6], &nors[i * 3]); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (f->v4) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				copy_v3_v3(&varray[start + 9], &nors[i * 3]); | 
					
						
							|  |  |  | 				copy_v3_v3(&varray[start + 12], &nors[i * 3]); | 
					
						
							|  |  |  | 				copy_v3_v3(&varray[start + 15], &nors[i * 3]); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		else { | 
					
						
							|  |  |  | 			/* calculate face normal */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (f->v4) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 				normal_quad_v3(f_no, mvert[f->v1].co, mvert[f->v2].co, mvert[f->v3].co, mvert[f->v4].co); | 
					
						
							|  |  |  | 			else | 
					
						
							|  |  |  | 				normal_tri_v3(f_no, mvert[f->v1].co, mvert[f->v2].co, mvert[f->v3].co); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			copy_v3_v3(&varray[start], f_no); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			copy_v3_v3(&varray[start + 3], f_no); | 
					
						
							|  |  |  | 			copy_v3_v3(&varray[start + 6], f_no); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (f->v4) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				copy_v3_v3(&varray[start + 9], f_no); | 
					
						
							|  |  |  | 				copy_v3_v3(&varray[start + 12], f_no); | 
					
						
							|  |  |  | 				copy_v3_v3(&varray[start + 15], f_no); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static void GPU_buffer_copy_uv(DerivedMesh *dm, float *varray, int *index, int *mat_orig_to_new, void *UNUSED(user)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int start; | 
					
						
							|  |  |  | 	int i, totface; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	MTFace *mtface; | 
					
						
							|  |  |  | 	MFace *f; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!(mtface = DM_get_tessface_data_layer(dm, CD_MTFACE))) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2011-07-26 03:00:55 +00:00
										 |  |  | 	f = dm->getTessFaceArray(dm); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		 | 
					
						
							| 
									
										
										
										
											2011-07-26 03:00:55 +00:00
										 |  |  | 	totface = dm->getNumTessFaces(dm); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < totface; i++, f++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		start = index[mat_orig_to_new[f->mat_nr]]; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* v1 v2 v3 */ | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 		copy_v2_v2(&varray[start], mtface[i].uv[0]); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		copy_v2_v2(&varray[start + 2], mtface[i].uv[1]); | 
					
						
							|  |  |  | 		copy_v2_v2(&varray[start + 4], mtface[i].uv[2]); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		index[mat_orig_to_new[f->mat_nr]] += 6; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (f->v4) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			/* v3 v4 v1 */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			copy_v2_v2(&varray[start + 6], mtface[i].uv[2]); | 
					
						
							|  |  |  | 			copy_v2_v2(&varray[start + 8], mtface[i].uv[3]); | 
					
						
							|  |  |  | 			copy_v2_v2(&varray[start + 10], mtface[i].uv[0]); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			index[mat_orig_to_new[f->mat_nr]] += 6; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static void GPU_buffer_copy_color3(DerivedMesh *dm, float *varray_, int *index, int *mat_orig_to_new, void *user) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i, totface; | 
					
						
							| 
									
										
										
										
											2011-11-07 09:02:10 +00:00
										 |  |  | 	char *varray = (char *)varray_; | 
					
						
							|  |  |  | 	char *mcol = (char *)user; | 
					
						
							| 
									
										
										
										
											2011-07-26 03:00:55 +00:00
										 |  |  | 	MFace *f = dm->getTessFaceArray(dm); | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	totface = dm->getNumTessFaces(dm); | 
					
						
							|  |  |  | 	for (i = 0; i < totface; i++, f++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		int start = index[mat_orig_to_new[f->mat_nr]]; | 
					
						
							| 
									
										
										
										
											2010-03-22 17:17:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* v1 v2 v3 */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		copy_v3_v3_char(&varray[start], &mcol[i * 12]); | 
					
						
							|  |  |  | 		copy_v3_v3_char(&varray[start + 3], &mcol[i * 12 + 3]); | 
					
						
							|  |  |  | 		copy_v3_v3_char(&varray[start + 6], &mcol[i * 12 + 6]); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		index[mat_orig_to_new[f->mat_nr]] += 9; | 
					
						
							| 
									
										
										
										
											2010-03-22 17:17:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (f->v4) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			/* v3 v4 v1 */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			copy_v3_v3_char(&varray[start + 9], &mcol[i * 12 + 6]); | 
					
						
							|  |  |  | 			copy_v3_v3_char(&varray[start + 12], &mcol[i * 12 + 9]); | 
					
						
							|  |  |  | 			copy_v3_v3_char(&varray[start + 15], &mcol[i * 12]); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			index[mat_orig_to_new[f->mat_nr]] += 9; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static void copy_mcol_uc3(unsigned char *v, unsigned char *col) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	v[0] = col[3]; | 
					
						
							|  |  |  | 	v[1] = col[2]; | 
					
						
							|  |  |  | 	v[2] = col[1]; | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* treat varray_ as an array of MCol, four MCol's per face */ | 
					
						
							|  |  |  | static void GPU_buffer_copy_mcol(DerivedMesh *dm, float *varray_, int *index, int *mat_orig_to_new, void *user) | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	int i, totface; | 
					
						
							|  |  |  | 	unsigned char *varray = (unsigned char *)varray_; | 
					
						
							|  |  |  | 	unsigned char *mcol = (unsigned char *)user; | 
					
						
							| 
									
										
										
										
											2011-07-26 03:00:55 +00:00
										 |  |  | 	MFace *f = dm->getTessFaceArray(dm); | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	totface = dm->getNumTessFaces(dm); | 
					
						
							|  |  |  | 	for (i = 0; i < totface; i++, f++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		int start = index[mat_orig_to_new[f->mat_nr]]; | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* v1 v2 v3 */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		copy_mcol_uc3(&varray[start], &mcol[i * 16]); | 
					
						
							|  |  |  | 		copy_mcol_uc3(&varray[start + 3], &mcol[i * 16 + 4]); | 
					
						
							|  |  |  | 		copy_mcol_uc3(&varray[start + 6], &mcol[i * 16 + 8]); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		index[mat_orig_to_new[f->mat_nr]] += 9; | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (f->v4) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			/* v3 v4 v1 */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			copy_mcol_uc3(&varray[start + 9], &mcol[i * 16 + 8]); | 
					
						
							|  |  |  | 			copy_mcol_uc3(&varray[start + 12], &mcol[i * 16 + 12]); | 
					
						
							|  |  |  | 			copy_mcol_uc3(&varray[start + 15], &mcol[i * 16]); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			index[mat_orig_to_new[f->mat_nr]] += 9; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-11 14:16:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static void GPU_buffer_copy_edge(DerivedMesh *dm, float *varray_, int *UNUSED(index), int *UNUSED(mat_orig_to_new), void *UNUSED(user)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	MEdge *medge; | 
					
						
							|  |  |  | 	unsigned int *varray = (unsigned int *)varray_; | 
					
						
							|  |  |  | 	int i, totedge; | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | 	medge = dm->getEdgeArray(dm); | 
					
						
							|  |  |  | 	totedge = dm->getNumEdges(dm); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < totedge; i++, medge++) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		varray[i * 2] = dm->drawObject->vert_points[medge->v1].point_index; | 
					
						
							|  |  |  | 		varray[i * 2 + 1] = dm->drawObject->vert_points[medge->v2].point_index; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static void GPU_buffer_copy_uvedge(DerivedMesh *dm, float *varray, int *UNUSED(index), int *UNUSED(mat_orig_to_new), void *UNUSED(user)) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-11-24 22:40:43 +00:00
										 |  |  | 	MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	int i, j = 0; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!tf) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < dm->numTessFaceData; i++, tf++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		MFace mf; | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 		dm->getTessFace(dm, i, &mf); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-29 15:47:02 +00:00
										 |  |  | 		copy_v2_v2(&varray[j], tf->uv[0]); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		copy_v2_v2(&varray[j + 2], tf->uv[1]); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		copy_v2_v2(&varray[j + 4], tf->uv[1]); | 
					
						
							|  |  |  | 		copy_v2_v2(&varray[j + 6], tf->uv[2]); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (!mf.v4) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			copy_v2_v2(&varray[j + 8], tf->uv[2]); | 
					
						
							|  |  |  | 			copy_v2_v2(&varray[j + 10], tf->uv[0]); | 
					
						
							|  |  |  | 			j += 12; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			copy_v2_v2(&varray[j + 8], tf->uv[2]); | 
					
						
							|  |  |  | 			copy_v2_v2(&varray[j + 10], tf->uv[3]); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			copy_v2_v2(&varray[j + 12], tf->uv[3]); | 
					
						
							|  |  |  | 			copy_v2_v2(&varray[j + 14], tf->uv[0]); | 
					
						
							|  |  |  | 			j += 16; | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* get the DerivedMesh's MCols; choose (in decreasing order of
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * preference) from CD_ID_MCOL, CD_PREVIEW_MCOL, or CD_MCOL */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static MCol *gpu_buffer_color_type(DerivedMesh *dm) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	MCol *c; | 
					
						
							|  |  |  | 	int type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	type = CD_ID_MCOL; | 
					
						
							| 
									
										
										
										
											2011-11-24 22:40:43 +00:00
										 |  |  | 	c = DM_get_tessface_data_layer(dm, type); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!c) { | 
					
						
							| 
									
										
										
										
											2012-03-22 08:41:50 +00:00
										 |  |  | 		type = CD_PREVIEW_MCOL; | 
					
						
							| 
									
										
										
										
											2011-11-24 22:40:43 +00:00
										 |  |  | 		c = DM_get_tessface_data_layer(dm, type); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (!c) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			type = CD_MCOL; | 
					
						
							| 
									
										
										
										
											2011-11-24 22:40:43 +00:00
										 |  |  | 			c = DM_get_tessface_data_layer(dm, type); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	dm->drawObject->colType = type; | 
					
						
							|  |  |  | 	return c; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | typedef enum { | 
					
						
							|  |  |  | 	GPU_BUFFER_VERTEX = 0, | 
					
						
							|  |  |  | 	GPU_BUFFER_NORMAL, | 
					
						
							|  |  |  | 	GPU_BUFFER_COLOR, | 
					
						
							|  |  |  | 	GPU_BUFFER_UV, | 
					
						
							|  |  |  | 	GPU_BUFFER_EDGE, | 
					
						
							|  |  |  | 	GPU_BUFFER_UVEDGE, | 
					
						
							|  |  |  | } GPUBufferType; | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | typedef struct { | 
					
						
							|  |  |  | 	GPUBufferCopyFunc copy; | 
					
						
							|  |  |  | 	GLenum gl_buffer_type; | 
					
						
							|  |  |  | 	int vector_size; | 
					
						
							|  |  |  | } GPUBufferTypeSettings; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const GPUBufferTypeSettings gpu_buffer_type_settings[] = { | 
					
						
							|  |  |  | 	{GPU_buffer_copy_vertex, GL_ARRAY_BUFFER_ARB, 3}, | 
					
						
							|  |  |  | 	{GPU_buffer_copy_normal, GL_ARRAY_BUFFER_ARB, 3}, | 
					
						
							|  |  |  | 	{GPU_buffer_copy_mcol, GL_ARRAY_BUFFER_ARB, 3}, | 
					
						
							|  |  |  | 	{GPU_buffer_copy_uv, GL_ARRAY_BUFFER_ARB, 2}, | 
					
						
							|  |  |  | 	{GPU_buffer_copy_edge, GL_ELEMENT_ARRAY_BUFFER_ARB, 2}, | 
					
						
							|  |  |  | 	{GPU_buffer_copy_uvedge, GL_ELEMENT_ARRAY_BUFFER_ARB, 4} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* get the GPUDrawObject buffer associated with a type */ | 
					
						
							|  |  |  | static GPUBuffer **gpu_drawobject_buffer_from_type(GPUDrawObject *gdo, GPUBufferType type) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-28 06:31:57 +00:00
										 |  |  | 	switch (type) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		case GPU_BUFFER_VERTEX: | 
					
						
							|  |  |  | 			return &gdo->points; | 
					
						
							|  |  |  | 		case GPU_BUFFER_NORMAL: | 
					
						
							|  |  |  | 			return &gdo->normals; | 
					
						
							|  |  |  | 		case GPU_BUFFER_COLOR: | 
					
						
							|  |  |  | 			return &gdo->colors; | 
					
						
							|  |  |  | 		case GPU_BUFFER_UV: | 
					
						
							|  |  |  | 			return &gdo->uv; | 
					
						
							|  |  |  | 		case GPU_BUFFER_EDGE: | 
					
						
							|  |  |  | 			return &gdo->edges; | 
					
						
							|  |  |  | 		case GPU_BUFFER_UVEDGE: | 
					
						
							|  |  |  | 			return &gdo->uvedges; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			return NULL; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* get the amount of space to allocate for a buffer of a particular type */ | 
					
						
							|  |  |  | static int gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type) | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-28 06:31:57 +00:00
										 |  |  | 	switch (type) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		case GPU_BUFFER_VERTEX: | 
					
						
							|  |  |  | 			return sizeof(float) * 3 * (dm->drawObject->tot_triangle_point + dm->drawObject->tot_loose_point); | 
					
						
							|  |  |  | 		case GPU_BUFFER_NORMAL: | 
					
						
							|  |  |  | 			return sizeof(float) * 3 * dm->drawObject->tot_triangle_point; | 
					
						
							|  |  |  | 		case GPU_BUFFER_COLOR: | 
					
						
							|  |  |  | 			return sizeof(char) * 3 * dm->drawObject->tot_triangle_point; | 
					
						
							|  |  |  | 		case GPU_BUFFER_UV: | 
					
						
							|  |  |  | 			return sizeof(float) * 2 * dm->drawObject->tot_triangle_point; | 
					
						
							|  |  |  | 		case GPU_BUFFER_EDGE: | 
					
						
							|  |  |  | 			return sizeof(int) * 2 * dm->drawObject->totedge; | 
					
						
							|  |  |  | 		case GPU_BUFFER_UVEDGE: | 
					
						
							|  |  |  | 			/* each face gets 3 points, 3 edges per triangle, and
 | 
					
						
							|  |  |  | 			 * each edge has its own, non-shared coords, so each | 
					
						
							|  |  |  | 			 * tri corner needs minimum of 4 floats, quads used | 
					
						
							|  |  |  | 			 * less so here we can over allocate and assume all | 
					
						
							|  |  |  | 			 * tris. */ | 
					
						
							|  |  |  | 			return sizeof(float) * 4 * dm->drawObject->tot_triangle_point; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			return -1; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* call gpu_buffer_setup with settings for a particular type of buffer */ | 
					
						
							|  |  |  | static GPUBuffer *gpu_buffer_setup_type(DerivedMesh *dm, GPUBufferType type) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	const GPUBufferTypeSettings *ts; | 
					
						
							|  |  |  | 	void *user_data = NULL; | 
					
						
							|  |  |  | 	GPUBuffer *buf; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	ts = &gpu_buffer_type_settings[type]; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* special handling for MCol and UV buffers */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (type == GPU_BUFFER_COLOR) { | 
					
						
							|  |  |  | 		if (!(user_data = gpu_buffer_color_type(dm))) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			return NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (type == GPU_BUFFER_UV) { | 
					
						
							|  |  |  | 		if (!DM_get_tessface_data_layer(dm, CD_MTFACE)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			return NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	buf = gpu_buffer_setup(dm, dm->drawObject, ts->vector_size, | 
					
						
							| 
									
										
										
										
											2011-11-11 13:09:14 +00:00
										 |  |  | 	                       gpu_buffer_size_from_type(dm, type), | 
					
						
							|  |  |  | 	                       ts->gl_buffer_type, user_data, ts->copy); | 
					
						
							| 
									
										
										
										
											2010-01-31 15:06:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	return buf; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* get the buffer of `type', initializing the GPUDrawObject and
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * buffer if needed */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static GPUBuffer *gpu_buffer_setup_common(DerivedMesh *dm, GPUBufferType type) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	GPUBuffer **buf; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!dm->drawObject) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		dm->drawObject = GPU_drawobject_new(dm); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	buf = gpu_drawobject_buffer_from_type(dm->drawObject, type); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!(*buf)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		*buf = gpu_buffer_setup_type(dm, type); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	return *buf; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_vertex_setup(DerivedMesh *dm) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	glEnableClientState(GL_VERTEX_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->points->id); | 
					
						
							|  |  |  | 		glVertexPointer(3, GL_FLOAT, 0, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		glVertexPointer(3, GL_FLOAT, 0, dm->drawObject->points->pointer); | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	GLStates |= GPU_BUFFER_VERTEX_STATE; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_normal_setup(DerivedMesh *dm) | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_NORMAL)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	glEnableClientState(GL_NORMAL_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->normals->id); | 
					
						
							|  |  |  | 		glNormalPointer(GL_FLOAT, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	else { | 
					
						
							|  |  |  | 		glNormalPointer(GL_FLOAT, 0, dm->drawObject->normals->pointer); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	GLStates |= GPU_BUFFER_NORMAL_STATE; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_uv_setup(DerivedMesh *dm) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UV)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->uv->id); | 
					
						
							|  |  |  | 		glTexCoordPointer(2, GL_FLOAT, 0, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		glTexCoordPointer(2, GL_FLOAT, 0, dm->drawObject->uv->pointer); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GLStates |= GPU_BUFFER_TEXCOORD_STATE; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_color_setup(DerivedMesh *dm) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_COLOR)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	glEnableClientState(GL_COLOR_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->colors->id); | 
					
						
							|  |  |  | 		glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	else { | 
					
						
							|  |  |  | 		glColorPointer(3, GL_UNSIGNED_BYTE, 0, dm->drawObject->colors->pointer); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GLStates |= GPU_BUFFER_COLOR_STATE; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_edge_setup(DerivedMesh *dm) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_EDGE)) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX)) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	glEnableClientState(GL_VERTEX_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->points->id); | 
					
						
							|  |  |  | 		glVertexPointer(3, GL_FLOAT, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glVertexPointer(3, GL_FLOAT, 0, dm->drawObject->points->pointer); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	GLStates |= GPU_BUFFER_VERTEX_STATE; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, dm->drawObject->edges->id); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	GLStates |= GPU_BUFFER_ELEMENT_STATE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_uvedge_setup(DerivedMesh *dm) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UVEDGE)) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	glEnableClientState(GL_VERTEX_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->uvedges->id); | 
					
						
							|  |  |  | 		glVertexPointer(2, GL_FLOAT, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glVertexPointer(2, GL_FLOAT, 0, dm->drawObject->uvedges->pointer); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	GLStates |= GPU_BUFFER_VERTEX_STATE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-28 05:53:40 +00:00
										 |  |  | static int GPU_typesize(int type) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-28 06:31:57 +00:00
										 |  |  | 	switch (type) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		case GL_FLOAT: | 
					
						
							|  |  |  | 			return sizeof(float); | 
					
						
							|  |  |  | 		case GL_INT: | 
					
						
							|  |  |  | 			return sizeof(int); | 
					
						
							|  |  |  | 		case GL_UNSIGNED_INT: | 
					
						
							|  |  |  | 			return sizeof(unsigned int); | 
					
						
							|  |  |  | 		case GL_BYTE: | 
					
						
							|  |  |  | 			return sizeof(char); | 
					
						
							|  |  |  | 		case GL_UNSIGNED_BYTE: | 
					
						
							|  |  |  | 			return sizeof(unsigned char); | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			return 0; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-28 05:53:40 +00:00
										 |  |  | int GPU_attrib_element_size(GPUAttrib data[], int numdata) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	int i, elementsize = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < numdata; i++) { | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		int typesize = GPU_typesize(data[i].type); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (typesize != 0) | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			elementsize += typesize * data[i].size; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return elementsize; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-28 05:53:40 +00:00
										 |  |  | void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numdata) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	int i; | 
					
						
							|  |  |  | 	int elementsize; | 
					
						
							| 
									
										
										
										
											2009-10-05 16:48:52 +00:00
										 |  |  | 	intptr_t offset = 0; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) { | 
					
						
							|  |  |  | 		if (attribData[i].index != -1) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glDisableVertexAttribArrayARB(attribData[i].index); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	elementsize = GPU_attrib_element_size(data, numdata); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer->id); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		for (i = 0; i < numdata; i++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glEnableVertexAttribArrayARB(data[i].index); | 
					
						
							|  |  |  | 			glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			                         GL_FALSE, elementsize, (void *)offset); | 
					
						
							|  |  |  | 			offset += data[i].size * GPU_typesize(data[i].type); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			attribData[i].index = data[i].index; | 
					
						
							|  |  |  | 			attribData[i].size = data[i].size; | 
					
						
							|  |  |  | 			attribData[i].type = data[i].type; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		attribData[numdata].index = -1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		for (i = 0; i < numdata; i++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glEnableVertexAttribArrayARB(data[i].index); | 
					
						
							|  |  |  | 			glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			                         GL_FALSE, elementsize, (char *)buffer->pointer + offset); | 
					
						
							|  |  |  | 			offset += data[i].size * GPU_typesize(data[i].type); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-13 15:02:21 +00:00
										 |  |  | void GPU_buffer_unbind(void) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int i; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (GLStates & GPU_BUFFER_VERTEX_STATE) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glDisableClientState(GL_VERTEX_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (GLStates & GPU_BUFFER_NORMAL_STATE) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glDisableClientState(GL_NORMAL_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (GLStates & GPU_BUFFER_TEXCOORD_STATE) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glDisableClientState(GL_TEXTURE_COORD_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (GLStates & GPU_BUFFER_COLOR_STATE) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glDisableClientState(GL_COLOR_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (GLStates & GPU_BUFFER_ELEMENT_STATE) { | 
					
						
							|  |  |  | 		if (useVBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-06-05 08:41:53 +00:00
										 |  |  | 	GLStates &= ~(GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_NORMAL_STATE | | 
					
						
							| 
									
										
										
										
											2011-11-11 13:09:14 +00:00
										 |  |  | 	              GPU_BUFFER_TEXCOORD_STATE | GPU_BUFFER_COLOR_STATE | | 
					
						
							|  |  |  | 	              GPU_BUFFER_ELEMENT_STATE); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) { | 
					
						
							|  |  |  | 		if (attribData[i].index != -1) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glDisableVertexAttribArrayARB(attribData[i].index); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* confusion: code in cdderivedmesh calls both GPU_color_setup and
 | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  |  * GPU_color3_upload; both of these set the `colors' buffer, so seems | 
					
						
							|  |  |  |  * like it will just needlessly overwrite? --nicholas */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_color3_upload(DerivedMesh *dm, unsigned char *data) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (dm->drawObject == 0) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		dm->drawObject = GPU_drawobject_new(dm); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GPU_buffer_free(dm->drawObject->colors); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dm->drawObject->colors = gpu_buffer_setup(dm, dm->drawObject, 3, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	                                          sizeof(char) * 3 * dm->drawObject->tot_triangle_point, | 
					
						
							|  |  |  | 	                                          GL_ARRAY_BUFFER_ARB, data, GPU_buffer_copy_color3); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | void GPU_color_switch(int mode) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (mode) { | 
					
						
							|  |  |  | 		if (!(GLStates & GPU_BUFFER_COLOR_STATE)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glEnableClientState(GL_COLOR_ARRAY); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		GLStates |= GPU_BUFFER_COLOR_STATE; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (GLStates & GPU_BUFFER_COLOR_STATE) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glDisableClientState(GL_COLOR_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-06-05 08:41:53 +00:00
										 |  |  | 		GLStates &= ~GPU_BUFFER_COLOR_STATE; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* return 1 if drawing should be done using old immediate-mode
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * code, 0 otherwise */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | int GPU_buffer_legacy(DerivedMesh *dm) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	int test = (U.gameflags & USER_DISABLE_VBO); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (test) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return 1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (dm->drawObject == 0) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		dm->drawObject = GPU_drawobject_new(dm); | 
					
						
							|  |  |  | 	return dm->drawObject->legacy; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void *GPU_buffer_lock(GPUBuffer *buffer) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	float *varray; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!buffer) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer->id); | 
					
						
							|  |  |  | 		varray = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return varray; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		return buffer->pointer; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void *GPU_buffer_lock_stream(GPUBuffer *buffer) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	float *varray; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!buffer) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer->id); | 
					
						
							|  |  |  | 		/* discard previous data, avoid stalling gpu */ | 
					
						
							|  |  |  | 		glBufferDataARB(GL_ARRAY_BUFFER_ARB, buffer->size, 0, GL_STREAM_DRAW_ARB); | 
					
						
							|  |  |  | 		varray = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return varray; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		return buffer->pointer; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_buffer_unlock(GPUBuffer *buffer) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (useVBOs) { | 
					
						
							|  |  |  | 		if (buffer) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			/* note: this operation can fail, could return
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 			 * an error code from this function? */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* used for drawing edges */ | 
					
						
							|  |  |  | void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start, int count) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	glDrawElements(mode, count, GL_UNSIGNED_INT, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	               (useVBOs ? | 
					
						
							|  |  |  | 	                (void *)(start * sizeof(unsigned int)) : | 
					
						
							|  |  |  | 	                ((int *)elements->pointer) + start)); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* XXX: the rest of the code in this file is used for optimized PBVH
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * drawing and doesn't interact at all with the buffer code above */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Convenience struct for building the VBO. */ | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  | 	float co[3]; | 
					
						
							|  |  |  | 	short no[3]; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* inserting this to align the 'color' field to a four-byte
 | 
					
						
							| 
									
										
										
										
											2012-05-16 23:37:23 +00:00
										 |  |  | 	 * boundary; drastically increases viewport performance on my | 
					
						
							|  |  |  | 	 * drivers (Gallium/Radeon) --nicholasbishop */ | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 	char pad[2]; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	unsigned char color[3]; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | } VertexBufferFormat; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 03:29:37 +00:00
										 |  |  | struct GPU_Buffers { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* opengl buffer handles */ | 
					
						
							|  |  |  | 	GLuint vert_buf, index_buf; | 
					
						
							|  |  |  | 	GLenum index_type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* mesh pointers in case buffer allocation fails */ | 
					
						
							|  |  |  | 	MFace *mface; | 
					
						
							|  |  |  | 	MVert *mvert; | 
					
						
							|  |  |  | 	int *face_indices; | 
					
						
							|  |  |  | 	int totface; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 	const float *vmask; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* grid pointers */ | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 	CCGKey gridkey; | 
					
						
							|  |  |  | 	CCGElem **grids; | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 	const DMFlagMat *grid_flag_mats; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	const BLI_bitmap *grid_hidden; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	int *grid_indices; | 
					
						
							|  |  |  | 	int totgrid; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	int has_hidden; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	unsigned int tot_tri, tot_quad; | 
					
						
							| 
									
										
										
										
											2011-11-05 03:29:37 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | typedef enum { | 
					
						
							|  |  |  | 	VBO_ENABLED, | 
					
						
							|  |  |  | 	VBO_DISABLED | 
					
						
							|  |  |  | } VBO_State; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void gpu_colors_enable(VBO_State vbo_state) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); | 
					
						
							|  |  |  | 	glEnable(GL_COLOR_MATERIAL); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	if (vbo_state == VBO_ENABLED) | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 		glEnableClientState(GL_COLOR_ARRAY); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void gpu_colors_disable(VBO_State vbo_state) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	glDisable(GL_COLOR_MATERIAL); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	if (vbo_state == VBO_ENABLED) | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 		glDisableClientState(GL_COLOR_ARRAY); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static float gpu_color_from_mask(float mask) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return (1.0f - mask) * 0.5f + 0.25f; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void gpu_color_from_mask_copy(float mask, unsigned char out[3]) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	unsigned char color; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	color = gpu_color_from_mask(mask) * 255.0f; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	out[0] = color; | 
					
						
							|  |  |  | 	out[1] = color; | 
					
						
							|  |  |  | 	out[2] = color; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void gpu_color_from_mask_set(float mask) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float color = gpu_color_from_mask(mask); | 
					
						
							|  |  |  | 	glColor3f(color, color, color); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static float gpu_color_from_mask_quad(const CCGKey *key, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  |                                       CCGElem *a, CCGElem *b, | 
					
						
							|  |  |  |                                       CCGElem *c, CCGElem *d) | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	return gpu_color_from_mask((*CCG_elem_mask(key, a) + | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	                            *CCG_elem_mask(key, b) + | 
					
						
							|  |  |  | 	                            *CCG_elem_mask(key, c) + | 
					
						
							|  |  |  | 	                            *CCG_elem_mask(key, d)) * 0.25f); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void gpu_color_from_mask_quad_copy(const CCGKey *key, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  |                                           CCGElem *a, CCGElem *b, | 
					
						
							|  |  |  |                                           CCGElem *c, CCGElem *d, | 
					
						
							|  |  |  |                                           unsigned char out[3]) | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	unsigned char color = | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	    gpu_color_from_mask((*CCG_elem_mask(key, a) + | 
					
						
							|  |  |  | 	                         *CCG_elem_mask(key, b) + | 
					
						
							|  |  |  | 	                         *CCG_elem_mask(key, c) + | 
					
						
							|  |  |  | 	                         *CCG_elem_mask(key, d)) * 0.25f) * 255.0f; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	out[0] = color; | 
					
						
							|  |  |  | 	out[1] = color; | 
					
						
							|  |  |  | 	out[2] = color; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void gpu_color_from_mask_quad_set(const CCGKey *key, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  |                                          CCGElem *a, CCGElem *b, | 
					
						
							|  |  |  |                                          CCGElem *c, CCGElem *d) | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	float color = gpu_color_from_mask_quad(key, a, b, c, d); | 
					
						
							|  |  |  | 	glColor3f(color, color, color); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-02 19:01:16 +00:00
										 |  |  | void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  |                              int *vert_indices, int totvert, const float *vmask) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	VertexBufferFormat *vert_data; | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 	buffers->vmask = vmask; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffers->vert_buf) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* Build VBO */ | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); | 
					
						
							|  |  |  | 		glBufferDataARB(GL_ARRAY_BUFFER_ARB, | 
					
						
							| 
									
										
										
										
											2011-11-11 13:09:14 +00:00
										 |  |  | 		                sizeof(VertexBufferFormat) * totvert, | 
					
						
							|  |  |  | 		                NULL, GL_STATIC_DRAW_ARB); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		vert_data = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (vert_data) { | 
					
						
							|  |  |  | 			for (i = 0; i < totvert; ++i) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 				MVert *v = mvert + vert_indices[i]; | 
					
						
							|  |  |  | 				VertexBufferFormat *out = vert_data + i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				copy_v3_v3(out->co, v->co); | 
					
						
							|  |  |  | 				memcpy(out->no, v->no, sizeof(short) * 3); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 				gpu_color_from_mask_copy(vmask[vert_indices[i]], | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				                         out->color); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			glDeleteBuffersARB(1, &buffers->vert_buf); | 
					
						
							|  |  |  | 			buffers->vert_buf = 0; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	buffers->mvert = mvert; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 22:48:34 +00:00
										 |  |  | GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  |                                     MFace *mface, MVert *mvert, | 
					
						
							|  |  |  |                                     int *face_indices, | 
					
						
							|  |  |  |                                     int totface) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	GPU_Buffers *buffers; | 
					
						
							|  |  |  | 	unsigned short *tri_data; | 
					
						
							|  |  |  | 	int i, j, k, tottri; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	buffers = MEM_callocN(sizeof(GPU_Buffers), "GPU_Buffers"); | 
					
						
							|  |  |  | 	buffers->index_type = GL_UNSIGNED_SHORT; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	/* Count the number of visible triangles */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0, tottri = 0; i < totface; ++i) { | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 		const MFace *f = &mface[face_indices[i]]; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (!paint_is_face_hidden(f, mvert)) | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 			tottri += f->v4 ? 2 : 1; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (GLEW_ARB_vertex_buffer_object && !(U.gameflags & USER_DISABLE_VBO)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glGenBuffersARB(1, &buffers->index_buf); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffers->index_buf) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* Generate index buffer object */ | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf); | 
					
						
							|  |  |  | 		glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, | 
					
						
							| 
									
										
										
										
											2011-11-11 13:09:14 +00:00
										 |  |  | 		                sizeof(unsigned short) * tottri * 3, NULL, GL_STATIC_DRAW_ARB); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* Fill the triangle buffer */ | 
					
						
							|  |  |  | 		tri_data = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (tri_data) { | 
					
						
							|  |  |  | 			for (i = 0; i < totface; ++i) { | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 				const MFace *f = mface + face_indices[i]; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 				int v[3]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 				/* Skip hidden faces */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (paint_is_face_hidden(f, mvert)) | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 					continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				v[0] = 0; | 
					
						
							|  |  |  | 				v[1] = 1; | 
					
						
							|  |  |  | 				v[2] = 2; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				for (j = 0; j < (f->v4 ? 2 : 1); ++j) { | 
					
						
							|  |  |  | 					for (k = 0; k < 3; ++k) { | 
					
						
							| 
									
										
										
										
											2012-02-22 22:48:34 +00:00
										 |  |  | 						*tri_data = face_vert_indices[i][v[k]]; | 
					
						
							| 
									
										
										
										
											2012-05-09 09:24:15 +00:00
										 |  |  | 						tri_data++; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2012-02-22 22:48:34 +00:00
										 |  |  | 					v[0] = 3; | 
					
						
							|  |  |  | 					v[1] = 0; | 
					
						
							|  |  |  | 					v[2] = 2; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			glDeleteBuffersARB(1, &buffers->index_buf); | 
					
						
							|  |  |  | 			buffers->index_buf = 0; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffers->index_buf) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glGenBuffersARB(1, &buffers->vert_buf); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	buffers->tot_tri = tottri; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	buffers->mface = mface; | 
					
						
							|  |  |  | 	buffers->face_indices = face_indices; | 
					
						
							|  |  |  | 	buffers->totface = totface; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return buffers; | 
					
						
							| 
									
										
										
										
											2009-10-05 16:48:52 +00:00
										 |  |  | } | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  |                              const DMFlagMat *grid_flag_mats, int *grid_indices, | 
					
						
							|  |  |  |                              int totgrid, const CCGKey *key) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 	VertexBufferFormat *vert_data; | 
					
						
							|  |  |  | 	int i, j, k, x, y; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Build VBO */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffers->vert_buf) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 		int totvert = key->grid_area * totgrid; | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 		int smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); | 
					
						
							|  |  |  | 		glBufferDataARB(GL_ARRAY_BUFFER_ARB, | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 		                sizeof(VertexBufferFormat) * totvert, | 
					
						
							| 
									
										
										
										
											2011-11-11 13:09:14 +00:00
										 |  |  | 		                NULL, GL_STATIC_DRAW_ARB); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		vert_data = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (vert_data) { | 
					
						
							|  |  |  | 			for (i = 0; i < totgrid; ++i) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 				VertexBufferFormat *vd = vert_data; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				CCGElem *grid = grids[grid_indices[i]]; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 				for (y = 0; y < key->grid_size; y++) { | 
					
						
							|  |  |  | 					for (x = 0; x < key->grid_size; x++) { | 
					
						
							|  |  |  | 						CCGElem *elem = CCG_grid_elem(key, grid, x, y); | 
					
						
							|  |  |  | 						 | 
					
						
							|  |  |  | 						copy_v3_v3(vd->co, CCG_elem_co(key, elem)); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 						if (smooth) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 							normal_float_to_short_v3(vd->no, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 							                         CCG_elem_no(key, elem)); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 							gpu_color_from_mask_copy(*CCG_elem_mask(key, elem), | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 							                         vd->color); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 						} | 
					
						
							|  |  |  | 						vd++; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (!smooth) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 					/* for flat shading, recalc normals and set the last vertex of
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 					 * each quad in the index buffer to have the flat normal as | 
					
						
							|  |  |  | 					 * that is what opengl will use */ | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 					for (j = 0; j < key->grid_size - 1; j++) { | 
					
						
							|  |  |  | 						for (k = 0; k < key->grid_size - 1; k++) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 							CCGElem *elems[4] = { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 								CCG_grid_elem(key, grid, k, j + 1), | 
					
						
							|  |  |  | 								CCG_grid_elem(key, grid, k + 1, j + 1), | 
					
						
							|  |  |  | 								CCG_grid_elem(key, grid, k + 1, j), | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 								CCG_grid_elem(key, grid, k, j) | 
					
						
							|  |  |  | 							}; | 
					
						
							| 
									
										
										
										
											2012-02-28 05:00:28 +00:00
										 |  |  | 							float fno[3]; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-28 05:00:28 +00:00
										 |  |  | 							normal_quad_v3(fno, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 							               CCG_elem_co(key, elems[0]), | 
					
						
							|  |  |  | 							               CCG_elem_co(key, elems[1]), | 
					
						
							|  |  |  | 							               CCG_elem_co(key, elems[2]), | 
					
						
							|  |  |  | 							               CCG_elem_co(key, elems[3])); | 
					
						
							| 
									
										
										
										
											2012-02-28 05:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 							vd = vert_data + (j + 1) * key->grid_size + (k + 1); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 							normal_float_to_short_v3(vd->no, fno); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 							gpu_color_from_mask_quad_copy(key, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 							                              elems[0], | 
					
						
							|  |  |  | 							                              elems[1], | 
					
						
							|  |  |  | 							                              elems[2], | 
					
						
							|  |  |  | 							                              elems[3], | 
					
						
							|  |  |  | 							                              vd->color); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 				vert_data += key->grid_area; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			glDeleteBuffersARB(1, &buffers->vert_buf); | 
					
						
							|  |  |  | 			buffers->vert_buf = 0; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	buffers->grids = grids; | 
					
						
							|  |  |  | 	buffers->grid_indices = grid_indices; | 
					
						
							|  |  |  | 	buffers->totgrid = totgrid; | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 	buffers->grid_flag_mats = grid_flag_mats; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 	buffers->gridkey = *key; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-02 19:01:16 +00:00
										 |  |  | 	//printf("node updated %p\n", buffers);
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | /* Returns the number of visible quads in the nodes' grids. */ | 
					
						
							|  |  |  | static int gpu_count_grid_quads(BLI_bitmap *grid_hidden, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  |                                 int *grid_indices, int totgrid, | 
					
						
							|  |  |  |                                 int gridsize) | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	int gridarea = (gridsize - 1) * (gridsize - 1); | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	int i, x, y, totquad; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* grid hidden layer is present, so have to check each grid for
 | 
					
						
							| 
									
										
										
										
											2012-07-16 23:23:33 +00:00
										 |  |  | 	 * visibility */ | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0, totquad = 0; i < totgrid; i++) { | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 		const BLI_bitmap gh = grid_hidden[grid_indices[i]]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (gh) { | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 			/* grid hidden are present, have to check each element */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			for (y = 0; y < gridsize - 1; y++) { | 
					
						
							|  |  |  | 				for (x = 0; x < gridsize - 1; x++) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 					if (!paint_is_grid_face_hidden(gh, gridsize, x, y)) | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 						totquad++; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			totquad += gridarea; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return totquad; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 23:30:56 +00:00
										 |  |  | /* Build the element array buffer of grid indices using either
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * unsigned shorts or unsigned ints. */ | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | #define FILL_QUAD_BUFFER(type_, tot_quad_, buffer_)                     \
 | 
					
						
							| 
									
										
										
										
											2012-02-22 23:30:56 +00:00
										 |  |  | 	{                                                                   \ | 
					
						
							|  |  |  | 		type_ *quad_data;                                               \ | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 		int offset = 0;                                                 \ | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 		int i, j, k;                                                    \ | 
					
						
							|  |  |  | 		                                                                \ | 
					
						
							| 
									
										
										
										
											2012-02-22 23:30:56 +00:00
										 |  |  | 		glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,                    \ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		                sizeof(type_) * (tot_quad_) * 4, NULL,          \ | 
					
						
							|  |  |  | 		                GL_STATIC_DRAW_ARB);                            \ | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 		                                                                \ | 
					
						
							| 
									
										
										
										
											2012-02-22 23:30:56 +00:00
										 |  |  | 		/* Fill the quad buffer */                                      \ | 
					
						
							|  |  |  | 		quad_data = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,         \ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		                           GL_WRITE_ONLY_ARB);                  \ | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 		if (quad_data) {                                                \ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			for (i = 0; i < totgrid; ++i) {                             \ | 
					
						
							|  |  |  | 				BLI_bitmap gh = NULL;                                   \ | 
					
						
							|  |  |  | 				if (grid_hidden)                                        \ | 
					
						
							|  |  |  | 					gh = grid_hidden[(grid_indices)[i]];                \ | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 																		\ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				for (j = 0; j < gridsize - 1; ++j) {                    \ | 
					
						
							|  |  |  | 					for (k = 0; k < gridsize - 1; ++k) {                \ | 
					
						
							|  |  |  | 						/* Skip hidden grid face */                     \ | 
					
						
							|  |  |  | 						if (gh &&                                       \ | 
					
						
							|  |  |  | 						    paint_is_grid_face_hidden(gh,               \ | 
					
						
							|  |  |  | 						                              gridsize, k, j))  \ | 
					
						
							|  |  |  | 							continue;                                   \ | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 																		\ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 						*(quad_data++) = offset + j * gridsize + k + 1; \ | 
					
						
							|  |  |  | 						*(quad_data++) = offset + j * gridsize + k;     \ | 
					
						
							|  |  |  | 						*(quad_data++) = offset + (j + 1) * gridsize + k; \ | 
					
						
							|  |  |  | 						*(quad_data++) = offset + (j + 1) * gridsize + k + 1; \ | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 					}                                                   \ | 
					
						
							| 
									
										
										
										
											2012-02-22 23:30:56 +00:00
										 |  |  | 				}                                                       \ | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 																		\ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				offset += gridsize * gridsize;                          \ | 
					
						
							| 
									
										
										
										
											2012-02-22 23:30:56 +00:00
										 |  |  | 			}                                                           \ | 
					
						
							|  |  |  | 			glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);              \ | 
					
						
							|  |  |  | 		}                                                               \ | 
					
						
							|  |  |  | 		else {                                                          \ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			glDeleteBuffersARB(1, &(buffer_));                          \ | 
					
						
							|  |  |  | 			(buffer_) = 0;                                              \ | 
					
						
							| 
									
										
										
										
											2012-02-22 23:30:56 +00:00
										 |  |  | 		}                                                               \ | 
					
						
							| 
									
										
										
										
											2012-05-27 20:13:59 +00:00
										 |  |  | 	} (void)0 | 
					
						
							| 
									
										
										
										
											2012-02-22 23:30:56 +00:00
										 |  |  | /* end FILL_QUAD_BUFFER */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *totquad) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 	static int prev_gridsize = -1; | 
					
						
							|  |  |  | 	static GLenum prev_index_type = 0; | 
					
						
							|  |  |  | 	static GLuint buffer = 0; | 
					
						
							|  |  |  | 	static unsigned prev_totquad; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	/* used in the FILL_QUAD_BUFFER macro */ | 
					
						
							|  |  |  | 	const BLI_bitmap *grid_hidden = NULL; | 
					
						
							|  |  |  | 	int *grid_indices = NULL; | 
					
						
							|  |  |  | 	int totgrid = 1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 	/* VBO is disabled; delete the previous buffer (if it exists) and
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 	 * return an invalid handle */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!GLEW_ARB_vertex_buffer_object || (U.gameflags & USER_DISABLE_VBO)) { | 
					
						
							|  |  |  | 		if (buffer) | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 			glDeleteBuffersARB(1, &buffer); | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 	/* VBO is already built */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffer && prev_gridsize == gridsize) { | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 		*index_type = prev_index_type; | 
					
						
							|  |  |  | 		*totquad = prev_totquad; | 
					
						
							|  |  |  | 		return buffer; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 	/* Build new VBO */ | 
					
						
							|  |  |  | 	glGenBuffersARB(1, &buffer); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffer) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		*totquad = (gridsize - 1) * (gridsize - 1); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffer); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (gridsize * gridsize < USHRT_MAX) { | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 			*index_type = GL_UNSIGNED_SHORT; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 			FILL_QUAD_BUFFER(unsigned short, *totquad, buffer); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 			*index_type = GL_UNSIGNED_INT; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 			FILL_QUAD_BUFFER(unsigned int, *totquad, buffer); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 	prev_gridsize = gridsize; | 
					
						
							|  |  |  | 	prev_index_type = *index_type; | 
					
						
							|  |  |  | 	prev_totquad = *totquad; | 
					
						
							|  |  |  | 	return buffer; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  |                                     BLI_bitmap *grid_hidden, int gridsize) | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	GPU_Buffers *buffers; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	int totquad; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	int fully_visible_totquad = (gridsize - 1) * (gridsize - 1) * totgrid; | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	buffers = MEM_callocN(sizeof(GPU_Buffers), "GPU_Buffers"); | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	buffers->grid_hidden = grid_hidden; | 
					
						
							|  |  |  | 	buffers->totgrid = totgrid; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Count the number of quads */ | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	totquad = gpu_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize); | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (totquad == fully_visible_totquad) { | 
					
						
							| 
									
										
										
										
											2012-03-16 04:11:35 +00:00
										 |  |  | 		buffers->index_buf = gpu_get_grid_buffer(gridsize, &buffers->index_type, &buffers->tot_quad); | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 		buffers->has_hidden = 0; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (GLEW_ARB_vertex_buffer_object && !(U.gameflags & USER_DISABLE_VBO)) { | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 		/* Build new VBO */ | 
					
						
							|  |  |  | 		glGenBuffersARB(1, &buffers->index_buf); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (buffers->index_buf) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			buffers->tot_quad = totquad; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (totgrid * gridsize * gridsize < USHRT_MAX) { | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 				buffers->index_type = GL_UNSIGNED_SHORT; | 
					
						
							|  |  |  | 				FILL_QUAD_BUFFER(unsigned short, totquad, buffers->index_buf); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							|  |  |  | 				buffers->index_type = GL_UNSIGNED_INT; | 
					
						
							|  |  |  | 				FILL_QUAD_BUFFER(unsigned int, totquad, buffers->index_buf); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		buffers->has_hidden = 1; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Build coord/normal VBO */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffers->index_buf) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glGenBuffersARB(1, &buffers->vert_buf); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return buffers; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 23:30:56 +00:00
										 |  |  | #undef FILL_QUAD_BUFFER
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-21 04:24:30 +00:00
										 |  |  | 	const MVert *mvert = buffers->mvert; | 
					
						
							|  |  |  | 	int i, j; | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 	gpu_colors_enable(VBO_DISABLED); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < buffers->totface; ++i) { | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 		MFace *f = buffers->mface + buffers->face_indices[i]; | 
					
						
							| 
									
										
										
										
											2012-02-21 04:24:30 +00:00
										 |  |  | 		int S = f->v4 ? 4 : 3; | 
					
						
							|  |  |  | 		unsigned int *fv = &f->v1; | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (paint_is_face_hidden(f, buffers->mvert)) | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		glBegin((f->v4) ? GL_QUADS : GL_TRIANGLES); | 
					
						
							| 
									
										
										
										
											2012-02-21 04:24:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (smooth) { | 
					
						
							|  |  |  | 			for (j = 0; j < S; j++) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 				gpu_color_from_mask_set(buffers->vmask[fv[j]]); | 
					
						
							| 
									
										
										
										
											2012-02-21 04:24:30 +00:00
										 |  |  | 				glNormal3sv(mvert[fv[j]].no); | 
					
						
							|  |  |  | 				glVertex3fv(mvert[fv[j]].co); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-02-21 04:24:30 +00:00
										 |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 			float fmask, fno[3]; | 
					
						
							| 
									
										
										
										
											2012-02-21 04:24:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			/* calculate face normal */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (f->v4) { | 
					
						
							| 
									
										
										
										
											2012-02-21 04:24:30 +00:00
										 |  |  | 				normal_quad_v3(fno, mvert[fv[0]].co, mvert[fv[1]].co, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				               mvert[fv[2]].co, mvert[fv[3]].co); | 
					
						
							| 
									
										
										
										
											2012-02-21 04:24:30 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			else | 
					
						
							|  |  |  | 				normal_tri_v3(fno, mvert[fv[0]].co, mvert[fv[1]].co, mvert[fv[2]].co); | 
					
						
							|  |  |  | 			glNormal3fv(fno); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			/* calculate face mask color */ | 
					
						
							|  |  |  | 			fmask = (buffers->vmask[fv[0]] + | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			         buffers->vmask[fv[1]] + | 
					
						
							|  |  |  | 			         buffers->vmask[fv[2]]); | 
					
						
							|  |  |  | 			if (f->v4) | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 				fmask = (fmask + buffers->vmask[fv[3]]) * 0.25; | 
					
						
							|  |  |  | 			else | 
					
						
							|  |  |  | 				fmask /= 3.0f; | 
					
						
							|  |  |  | 			gpu_color_from_mask_set(fmask); | 
					
						
							| 
									
										
										
										
											2012-02-21 04:24:30 +00:00
										 |  |  | 			 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			for (j = 0; j < S; j++) | 
					
						
							| 
									
										
										
										
											2012-02-21 04:24:30 +00:00
										 |  |  | 				glVertex3fv(mvert[fv[j]].co); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 		glEnd(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	gpu_colors_disable(VBO_DISABLED); | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 	const CCGKey *key = &buffers->gridkey; | 
					
						
							|  |  |  | 	int i, j, x, y, gridsize = buffers->gridkey.grid_size; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 	gpu_colors_enable(VBO_DISABLED); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < buffers->totgrid; ++i) { | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 		int g = buffers->grid_indices[i]; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 		CCGElem *grid = buffers->grids[g]; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 		BLI_bitmap gh = buffers->grid_hidden[g]; | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 		/* TODO: could use strips with hiding as well */ | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (gh) { | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 			glBegin(GL_QUADS); | 
					
						
							|  |  |  | 			 | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			for (y = 0; y < gridsize - 1; y++) { | 
					
						
							|  |  |  | 				for (x = 0; x < gridsize - 1; x++) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 					CCGElem *e[4] = { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 						CCG_grid_elem(key, grid, x + 1, y + 1), | 
					
						
							|  |  |  | 						CCG_grid_elem(key, grid, x + 1, y), | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 						CCG_grid_elem(key, grid, x, y), | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 						CCG_grid_elem(key, grid, x, y + 1) | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 					}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					/* skip face if any of its corners are hidden */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 					if (paint_is_grid_face_hidden(gh, gridsize, x, y)) | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 						continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 					if (smooth) { | 
					
						
							|  |  |  | 						for (j = 0; j < 4; j++) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 							gpu_color_from_mask_set(*CCG_elem_mask(key, e[j])); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 							glNormal3fv(CCG_elem_no(key, e[j])); | 
					
						
							|  |  |  | 							glVertex3fv(CCG_elem_co(key, e[j])); | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					else { | 
					
						
							|  |  |  | 						float fno[3]; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 						normal_quad_v3(fno, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 						               CCG_elem_co(key, e[0]), | 
					
						
							|  |  |  | 						               CCG_elem_co(key, e[1]), | 
					
						
							|  |  |  | 						               CCG_elem_co(key, e[2]), | 
					
						
							|  |  |  | 						               CCG_elem_co(key, e[3])); | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 						glNormal3fv(fno); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 						gpu_color_from_mask_quad_set(key, e[0], e[1], e[2], e[3]); | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 						for (j = 0; j < 4; j++) | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 							glVertex3fv(CCG_elem_co(key, e[j])); | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			glEnd(); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		else if (smooth) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			for (y = 0; y < gridsize - 1; y++) { | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 				glBegin(GL_QUAD_STRIP); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				for (x = 0; x < gridsize; x++) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 					CCGElem *a = CCG_grid_elem(key, grid, x, y); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 					CCGElem *b = CCG_grid_elem(key, grid, x, y + 1); | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 					gpu_color_from_mask_set(*CCG_elem_mask(key, a)); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 					glNormal3fv(CCG_elem_no(key, a)); | 
					
						
							|  |  |  | 					glVertex3fv(CCG_elem_co(key, a)); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 					gpu_color_from_mask_set(*CCG_elem_mask(key, b)); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 					glNormal3fv(CCG_elem_no(key, b)); | 
					
						
							|  |  |  | 					glVertex3fv(CCG_elem_co(key, b)); | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 				glEnd(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			for (y = 0; y < gridsize - 1; y++) { | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 				glBegin(GL_QUAD_STRIP); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				for (x = 0; x < gridsize; x++) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 					CCGElem *a = CCG_grid_elem(key, grid, x, y); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 					CCGElem *b = CCG_grid_elem(key, grid, x, y + 1); | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 					if (x > 0) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 						CCGElem *c = CCG_grid_elem(key, grid, x - 1, y); | 
					
						
							|  |  |  | 						CCGElem *d = CCG_grid_elem(key, grid, x - 1, y + 1); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 						float fno[3]; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 						normal_quad_v3(fno, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 						               CCG_elem_co(key, d), | 
					
						
							|  |  |  | 						               CCG_elem_co(key, b), | 
					
						
							|  |  |  | 						               CCG_elem_co(key, a), | 
					
						
							|  |  |  | 						               CCG_elem_co(key, c)); | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 						glNormal3fv(fno); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 						gpu_color_from_mask_quad_set(key, a, b, c, d); | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 					glVertex3fv(CCG_elem_co(key, a)); | 
					
						
							|  |  |  | 					glVertex3fv(CCG_elem_co(key, b)); | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 				glEnd(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	gpu_colors_disable(VBO_DISABLED); | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-07 04:41:14 +00:00
										 |  |  | void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 	int smooth = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffers->totface) { | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 		const MFace *f = &buffers->mface[buffers->face_indices[0]]; | 
					
						
							| 
									
										
										
										
											2012-04-02 22:26:00 +00:00
										 |  |  | 		if (!setMaterial(f->mat_nr + 1, NULL)) | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 			return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		smooth = f->flag & ME_SMOOTH; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		glShadeModel(smooth ? GL_SMOOTH : GL_FLAT); | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (buffers->totgrid) { | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 		const DMFlagMat *f = &buffers->grid_flag_mats[buffers->grid_indices[0]]; | 
					
						
							| 
									
										
										
										
											2012-04-02 22:26:00 +00:00
										 |  |  | 		if (!setMaterial(f->mat_nr + 1, NULL)) | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 			return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		smooth = f->flag & ME_SMOOTH; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		glShadeModel(smooth ? GL_SMOOTH : GL_FLAT); | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffers->vert_buf && buffers->index_buf) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glEnableClientState(GL_VERTEX_ARRAY); | 
					
						
							|  |  |  | 		glEnableClientState(GL_NORMAL_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 		gpu_colors_enable(VBO_ENABLED); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (buffers->tot_quad) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 			char *offset = 0; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 			int i, last = buffers->has_hidden ? 1 : buffers->totgrid; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			for (i = 0; i < last; i++) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 				glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				                offset + offsetof(VertexBufferFormat, co)); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 				glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				                offset + offsetof(VertexBufferFormat, no)); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 				glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				               offset + offsetof(VertexBufferFormat, color)); | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 				 | 
					
						
							|  |  |  | 				glDrawElements(GL_QUADS, buffers->tot_quad * 4, buffers->index_type, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 				offset += buffers->gridkey.grid_area * sizeof(VertexBufferFormat); | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 			glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			                (void *)offsetof(VertexBufferFormat, co)); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 			glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			                (void *)offsetof(VertexBufferFormat, no)); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 			glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			               (void *)offsetof(VertexBufferFormat, color)); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			glDrawElements(GL_TRIANGLES, buffers->tot_tri * 3, buffers->index_type, 0); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		glDisableClientState(GL_VERTEX_ARRAY); | 
					
						
							|  |  |  | 		glDisableClientState(GL_NORMAL_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 		gpu_colors_disable(VBO_ENABLED); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-02-20 21:25:24 +00:00
										 |  |  | 	/* fallbacks if we are out of memory or VBO is disabled */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (buffers->totface) { | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 		gpu_draw_buffers_legacy_mesh(buffers, smooth); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (buffers->totgrid) { | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 		gpu_draw_buffers_legacy_grids(buffers, smooth); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-02 19:01:16 +00:00
										 |  |  | void GPU_free_buffers(GPU_Buffers *buffers) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffers) { | 
					
						
							|  |  |  | 		if (buffers->vert_buf) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glDeleteBuffersARB(1, &buffers->vert_buf); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (buffers->index_buf && (buffers->tot_tri || buffers->has_hidden)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glDeleteBuffersARB(1, &buffers->index_buf); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		MEM_freeN(buffers); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |