[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31053] branches/soc-2010-nicolasbishop: = = Ptex ==

Nicholas Bishop nicholasbishop at gmail.com
Thu Aug 5 02:53:03 CEST 2010


Revision: 31053
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31053
Author:   nicholasbishop
Date:     2010-08-05 02:53:02 +0200 (Thu, 05 Aug 2010)

Log Message:
-----------
== Ptex ==

initial ptex integration

* added the ptex C++ library to extern

* wrote a small C api for the library; just the functions I've used so
  far are in the C api, but easy to add more

* added a new CustomData type (face data), stored as struct MPtex

* added RNA for CD_MPTEX

* each MPtex stores:
** the U- and V-resolution (always a power of two)
** the number of color channels (e.g. RGB or RGBA)
** the data type (can be bytes, shorts, or floats)
** the number of subfaces (for triangles now, will work also for ngons)

* for drawing ptex, one power of two texture is assigned to each face
** for quads, the texture is mapped normally across the full face
** for triangles, the face is split into four quads for drawing, and each
   subface gets an equal-sized portion of the texture
** the texture is created with the same internal format as the ptex layer

* added an operator for loading ptex files

* added an operator for creating ptex layers; takes data type, number of
  channels, and texel density as inputs. has some hackish code to allocate
  texels based on a faces catmull-clark limit surface area

* added a simple ptex UI, shows ptex layers in the mesh data panel

* modified vpaint to paint on ptex instead of mcols


partial todo list:
* VBO drawing (make sure to turn VBO off before testing ptex for now)
* ptex saving
* better texel allocation
* upsampling/downsampling faces
* UI for setting individual faces' resolutions

Modified Paths:
--------------
    branches/soc-2010-nicolasbishop/extern/CMakeLists.txt
    branches/soc-2010-nicolasbishop/release/scripts/ui/properties_data_mesh.py
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/customdata.c
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h
    branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
    branches/soc-2010-nicolasbishop/source/blender/blenloader/CMakeLists.txt
    branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/readfile.c
    branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/writefile.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/CMakeLists.txt
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ops.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/pbvh_undo.c
    branches/soc-2010-nicolasbishop/source/blender/gpu/CMakeLists.txt
    branches/soc-2010-nicolasbishop/source/blender/gpu/GPU_buffers.h
    branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c
    branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_customdata_types.h
    branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_meshdata_types.h
    branches/soc-2010-nicolasbishop/source/blender/makesrna/RNA_access.h
    branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_mesh.c
    branches/soc-2010-nicolasbishop/source/creator/CMakeLists.txt

Added Paths:
-----------
    branches/soc-2010-nicolasbishop/extern/ptex/
    branches/soc-2010-nicolasbishop/extern/ptex/CMakeLists.txt
    branches/soc-2010-nicolasbishop/extern/ptex/ptex.h
    branches/soc-2010-nicolasbishop/extern/ptex/ptex_C_api.cpp
    branches/soc-2010-nicolasbishop/extern/ptex/src/
    branches/soc-2010-nicolasbishop/extern/ptex/src/Makefile
    branches/soc-2010-nicolasbishop/extern/ptex/src/doc/
    branches/soc-2010-nicolasbishop/extern/ptex/src/doc/Doxyfile
    branches/soc-2010-nicolasbishop/extern/ptex/src/doc/Doxyfile_API_only
    branches/soc-2010-nicolasbishop/extern/ptex/src/doc/FilterFootprint.html
    branches/soc-2010-nicolasbishop/extern/ptex/src/doc/License.txt
    branches/soc-2010-nicolasbishop/extern/ptex/src/doc/Makefile
    branches/soc-2010-nicolasbishop/extern/ptex/src/doc/README
    branches/soc-2010-nicolasbishop/extern/ptex/src/doc/apiintro.txt
    branches/soc-2010-nicolasbishop/extern/ptex/src/doc/main.txt
    branches/soc-2010-nicolasbishop/extern/ptex/src/doc/uvellipse.png
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/Makefile
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/Makefile.deps
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexCache.cpp
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexCache.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexDict.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexFilters.cpp
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexHalf.cpp
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexHalf.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexHashMap.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexIO.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexInt.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexMutex.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexPlatform.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexReader.cpp
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexReader.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexSeparableFilter.cpp
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexSeparableFilter.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexSeparableKernel.cpp
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexSeparableKernel.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexTriangleFilter.cpp
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexTriangleFilter.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexTriangleKernel.cpp
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexTriangleKernel.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexUtils.cpp
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexUtils.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexWriter.cpp
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/PtexWriter.h
    branches/soc-2010-nicolasbishop/extern/ptex/src/ptex/Ptexture.h
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/ptex.c

Modified: branches/soc-2010-nicolasbishop/extern/CMakeLists.txt
===================================================================
--- branches/soc-2010-nicolasbishop/extern/CMakeLists.txt	2010-08-05 00:06:05 UTC (rev 31052)
+++ branches/soc-2010-nicolasbishop/extern/CMakeLists.txt	2010-08-05 00:53:02 UTC (rev 31053)
@@ -45,3 +45,5 @@
 IF(WITH_LZMA)
 	ADD_SUBDIRECTORY(lzma)
 ENDIF(WITH_LZMA)
+
+ADD_SUBDIRECTORY(ptex)
\ No newline at end of file

Added: branches/soc-2010-nicolasbishop/extern/ptex/CMakeLists.txt
===================================================================
--- branches/soc-2010-nicolasbishop/extern/ptex/CMakeLists.txt	                        (rev 0)
+++ branches/soc-2010-nicolasbishop/extern/ptex/CMakeLists.txt	2010-08-05 00:53:02 UTC (rev 31053)
@@ -0,0 +1,18 @@
+SET(INC src .)
+
+SET(SRC
+	src/ptex/PtexCache.cpp
+	src/ptex/PtexFilters.cpp
+	src/ptex/PtexHalf.cpp
+	src/ptex/PtexReader.cpp
+	src/ptex/PtexSeparableFilter.cpp
+	src/ptex/PtexSeparableKernel.cpp
+	src/ptex/PtexTriangleFilter.cpp
+	src/ptex/PtexTriangleKernel.cpp
+	src/ptex/PtexUtils.cpp
+	src/ptex/PtexWriter.cpp
+	ptex_C_api.cpp
+)
+
+BLENDERLIB(extern_ptex "${SRC}" "${INC}")
+

Added: branches/soc-2010-nicolasbishop/extern/ptex/ptex.h
===================================================================
--- branches/soc-2010-nicolasbishop/extern/ptex/ptex.h	                        (rev 0)
+++ branches/soc-2010-nicolasbishop/extern/ptex/ptex.h	2010-08-05 00:53:02 UTC (rev 31053)
@@ -0,0 +1,45 @@
+#ifndef PTEX_H
+#define PTEX_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef void* PtexTextureHandle;
+typedef void* PtexFaceInfoHandle;
+typedef void* PtexResHandle;
+
+typedef enum {
+	PTEX_DT_UINT8,
+	PTEX_DT_UINT16,
+	PTEX_DT_FLOAT,
+	PTEX_DT_UNSUPPORTED
+} PtexDataType;
+
+/* PtexTexture class */
+extern PtexTextureHandle ptex_open(const char *path, int print_error, int premultiply);
+extern void ptex_texture_release(PtexTextureHandle ptex_texture_handle);
+extern PtexDataType ptex_texture_data_type(PtexTextureHandle ptex_texture_handle);
+extern int ptex_texture_num_channels(PtexTextureHandle ptex_texture_handle);
+extern PtexFaceInfoHandle ptex_texture_get_face_info(PtexTextureHandle ptex_texture_handle, int faceid);
+extern void ptex_texture_get_data(PtexTextureHandle ptex_texture_handle, int faceid, void *buffer, int stride, PtexResHandle res_handle);
+extern void ptex_texture_get_pixel(PtexTextureHandle ptex_texture_handle, int faceid, int u, int v, float *result, int firstchan, int nchannels, PtexResHandle res_handle);
+
+/* FaceInfo struct */
+extern PtexResHandle ptex_face_get_res(PtexFaceInfoHandle face_info_handle);
+extern int ptex_face_info_is_subface(PtexFaceInfoHandle face_info_handle);
+
+/* Res struct */
+extern int ptex_res_u(PtexResHandle ptex_res_handle);
+extern int ptex_res_v(PtexResHandle ptex_res_handle);
+
+/* Utils */
+int ptex_data_size(PtexDataType type);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Added: branches/soc-2010-nicolasbishop/extern/ptex/ptex_C_api.cpp
===================================================================
--- branches/soc-2010-nicolasbishop/extern/ptex/ptex_C_api.cpp	                        (rev 0)
+++ branches/soc-2010-nicolasbishop/extern/ptex/ptex_C_api.cpp	2010-08-05 00:53:02 UTC (rev 31053)
@@ -0,0 +1,100 @@
+#include "ptex.h"
+#include "src/ptex/Ptexture.h"
+#include <iostream>
+
+/**** PtexTexture class ****/
+PtexTextureHandle ptex_open(const char *path, int print_error, int premultiply)
+{
+	PtexTextureHandle ptex_texture_handle;
+
+	Ptex::String error_string;
+
+	ptex_texture_handle = (PtexTextureHandle)PtexTexture::open(path, error_string, premultiply);
+
+	if(!ptex_texture_handle && print_error)
+		std::cout << "Ptex error: " << error_string << std::endl;
+
+	return ptex_texture_handle;
+}
+
+void ptex_texture_release(PtexTextureHandle ptex_texture_handle)
+{
+	((PtexTexture*)ptex_texture_handle)->release();
+}
+
+PtexDataType ptex_texture_data_type(PtexTextureHandle ptex_texture_handle)
+{
+	Ptex::DataType type = ((PtexTexture*)ptex_texture_handle)->dataType();
+
+	switch(type) {
+	case Ptex::dt_uint8:
+		return PTEX_DT_UINT8;
+	case Ptex::dt_uint16:
+		return PTEX_DT_UINT16;
+	case Ptex::dt_float:
+		return PTEX_DT_FLOAT;
+	default:
+		return PTEX_DT_UNSUPPORTED;
+	}
+}
+
+int ptex_texture_num_channels(PtexTextureHandle ptex_texture_handle)
+{
+	return ((PtexTexture*)ptex_texture_handle)->numChannels();
+}
+
+PtexFaceInfoHandle ptex_texture_get_face_info(PtexTextureHandle ptex_texture_handle, int faceid)
+{
+	return (PtexFaceInfoHandle)(&((PtexTexture*)ptex_texture_handle)->getFaceInfo(faceid));
+}
+
+void ptex_texture_get_data(PtexTextureHandle ptex_texture_handle, int faceid, void *buffer, int stride, PtexResHandle res_handle)
+{
+	((PtexTexture*)ptex_texture_handle)->getData(faceid, buffer, stride, *((Ptex::Res*)res_handle));
+}
+
+void ptex_texture_get_pixel(PtexTextureHandle ptex_texture_handle, int faceid, int u, int v, float *result, int firstchan, int nchannels, PtexResHandle res_handle)
+{
+	((PtexTexture*)ptex_texture_handle)->getPixel(faceid, u, v, result, firstchan, nchannels, *((Ptex::Res*)res_handle));
+}
+
+
+
+/**** FaceInfo struct ****/
+PtexResHandle ptex_face_get_res(PtexFaceInfoHandle face_info_handle)
+{
+	return (PtexResHandle)(&((Ptex::FaceInfo*)face_info_handle)->res);
+}
+
+int ptex_face_info_is_subface(PtexFaceInfoHandle face_info_handle)
+{
+	return ((Ptex::FaceInfo*)face_info_handle)->isSubface();
+}
+
+
+
+/**** Res struct ****/
+int ptex_res_u(PtexResHandle ptex_res_handle)
+{
+	return ((Ptex::Res*)ptex_res_handle)->u();
+}
+
+int ptex_res_v(PtexResHandle ptex_res_handle)
+{
+	return ((Ptex::Res*)ptex_res_handle)->v();
+}
+
+/**** Utils ****/
+int ptex_data_size(PtexDataType type)
+{
+	switch(type) {
+	case PTEX_DT_UINT8:
+		return 1;
+	case PTEX_DT_UINT16:
+		return 2;
+	case PTEX_DT_FLOAT:
+		return 4;
+	default:
+		return 0;
+	}
+}

Added: branches/soc-2010-nicolasbishop/extern/ptex/src/Makefile
===================================================================
--- branches/soc-2010-nicolasbishop/extern/ptex/src/Makefile	                        (rev 0)
+++ branches/soc-2010-nicolasbishop/extern/ptex/src/Makefile	2010-08-05 00:53:02 UTC (rev 31053)
@@ -0,0 +1,13 @@
+SUBDIRS = ptex utils tests
+
+.PHONY: subdirs $(SUBDIRS)
+
+subdirs: $(SUBDIRS)
+
+clean:
+	for s in $(SUBDIRS); do \
+		$(MAKE) -C $$s clean; \
+	done
+
+$(SUBDIRS):
+	$(MAKE) -C $@

Added: branches/soc-2010-nicolasbishop/extern/ptex/src/doc/Doxyfile
===================================================================
--- branches/soc-2010-nicolasbishop/extern/ptex/src/doc/Doxyfile	                        (rev 0)
+++ branches/soc-2010-nicolasbishop/extern/ptex/src/doc/Doxyfile	2010-08-05 00:53:02 UTC (rev 31053)
@@ -0,0 +1,1287 @@
+# Doxyfile 1.5.2-4
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file that 
+# follow. The default is UTF-8 which is also the encoding used for all text before 
+# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into 
+# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of 
+# possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = Ptex
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = 
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = ../../install/doc
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of 
+# source files, where putting all generated files in the same directory would 
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
+# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, 
+# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, 
+# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, 
+# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list