[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31450] branches/soc-2010-nicolasbishop: = = Ptex ==
Nicholas Bishop
nicholasbishop at gmail.com
Thu Aug 19 01:59:26 CEST 2010
Revision: 31450
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31450
Author: nicholasbishop
Date: 2010-08-19 01:59:26 +0200 (Thu, 19 Aug 2010)
Log Message:
-----------
== Ptex ==
Changed the internal ptex format to always use subfaces
* Changed MPtex to references MPtexSubfaces, each of which is a quad with U and V resolution and it's own ptex data pointer.
* This format is basically the same as what triangles were already using, but now quads work the same way.
* This format is also closer to the way multires grid data was already stored.
* Ptex loading (and saving, once that's implemented) requires some extra work to convert to the internal format, but everywhere else the code is much simpler.
* Fixed undoing ptex changes on a different multires level from where they were painted.
* Ptex paint now always uses an all-quad DM (generated with one level of ccgdm simple subsurf.) This is a bit ugly, just stuck on the end of calc_mesh_modifiers. This is only done if there's no multires or subsurf modifier at the end of the stack.
* Resolution editing is disabled for now, will restore it in next commit
Modified Paths:
--------------
branches/soc-2010-nicolasbishop/extern/ptex/ptex.h
branches/soc-2010-nicolasbishop/extern/ptex/ptex_C_api.cpp
branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py
branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h
branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_customdata.h
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/DerivedMesh.c
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/intern/readfile.c
branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/writefile.c
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_mask.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/editors/sculpt_paint/sculpt.c
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_meshdata_types.h
branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_mesh.c
Added Paths:
-----------
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/ptex.c
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ptex.c
Removed Paths:
-------------
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/ptex.c
Modified: branches/soc-2010-nicolasbishop/extern/ptex/ptex.h
===================================================================
--- branches/soc-2010-nicolasbishop/extern/ptex/ptex.h 2010-08-18 22:08:45 UTC (rev 31449)
+++ branches/soc-2010-nicolasbishop/extern/ptex/ptex.h 2010-08-18 23:59:26 UTC (rev 31450)
@@ -6,9 +6,9 @@
#endif
-typedef void* PtexTextureHandle;
-typedef void* PtexFaceInfoHandle;
-typedef void* PtexResHandle;
+typedef struct PtexTextureHandle PtexTextureHandle;
+typedef struct PtexFaceInfoHandle PtexFaceInfoHandle;
+typedef struct PtexResHandle PtexResHandle;
typedef enum {
PTEX_DT_UINT8,
@@ -18,21 +18,21 @@
} 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);
+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);
+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);
+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);
Modified: branches/soc-2010-nicolasbishop/extern/ptex/ptex_C_api.cpp
===================================================================
--- branches/soc-2010-nicolasbishop/extern/ptex/ptex_C_api.cpp 2010-08-18 22:08:45 UTC (rev 31449)
+++ branches/soc-2010-nicolasbishop/extern/ptex/ptex_C_api.cpp 2010-08-18 23:59:26 UTC (rev 31450)
@@ -3,13 +3,13 @@
#include <iostream>
/**** PtexTexture class ****/
-PtexTextureHandle ptex_open(const char *path, int print_error, int premultiply)
+PtexTextureHandle *ptex_open(const char *path, int print_error, int premultiply)
{
- PtexTextureHandle ptex_texture_handle;
+ PtexTextureHandle *ptex_texture_handle;
Ptex::String error_string;
- ptex_texture_handle = (PtexTextureHandle)PtexTexture::open(path, error_string, premultiply);
+ ptex_texture_handle = (PtexTextureHandle*)PtexTexture::open(path, error_string, premultiply);
if(!ptex_texture_handle && print_error)
std::cout << "Ptex error: " << error_string << std::endl;
@@ -17,12 +17,12 @@
return ptex_texture_handle;
}
-void ptex_texture_release(PtexTextureHandle 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)
+PtexDataType ptex_texture_data_type(PtexTextureHandle *ptex_texture_handle)
{
Ptex::DataType type = ((PtexTexture*)ptex_texture_handle)->dataType();
@@ -38,22 +38,22 @@
}
}
-int ptex_texture_num_channels(PtexTextureHandle ptex_texture_handle)
+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)
+PtexFaceInfoHandle *ptex_texture_get_face_info(PtexTextureHandle *ptex_texture_handle, int faceid)
{
- return (PtexFaceInfoHandle)(&((PtexTexture*)ptex_texture_handle)->getFaceInfo(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)
+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)
+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));
}
@@ -61,12 +61,12 @@
/**** FaceInfo struct ****/
-PtexResHandle ptex_face_get_res(PtexFaceInfoHandle face_info_handle)
+PtexResHandle *ptex_face_get_res(PtexFaceInfoHandle *face_info_handle)
{
- return (PtexResHandle)(&((Ptex::FaceInfo*)face_info_handle)->res);
+ return (PtexResHandle*)(&((Ptex::FaceInfo*)face_info_handle)->res);
}
-int ptex_face_info_is_subface(PtexFaceInfoHandle face_info_handle)
+int ptex_face_info_is_subface(PtexFaceInfoHandle *face_info_handle)
{
return ((Ptex::FaceInfo*)face_info_handle)->isSubface();
}
@@ -74,12 +74,12 @@
/**** Res struct ****/
-int ptex_res_u(PtexResHandle ptex_res_handle)
+int ptex_res_u(PtexResHandle *ptex_res_handle)
{
return ((Ptex::Res*)ptex_res_handle)->u();
}
-int ptex_res_v(PtexResHandle ptex_res_handle)
+int ptex_res_v(PtexResHandle *ptex_res_handle)
{
return ((Ptex::Res*)ptex_res_handle)->v();
}
Modified: branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py 2010-08-18 22:08:45 UTC (rev 31449)
+++ branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py 2010-08-18 23:59:26 UTC (rev 31450)
@@ -1449,7 +1449,7 @@
box = layout.box()
- if ptex.subfaces == 1:
+ if len(ptex.subfaces) == 1:
box.label("Quad Resolution:")
else:
box.label("Subface Resolution:")
@@ -1458,11 +1458,11 @@
box.label(text=prefix + str(res[0]) + " x " + str(res[1]))
if ptex.subfaces == 1:
- reslbl("", ptex.resolution1)
+ reslbl("", ptex.subfaces[0].resolution)
else:
- reslbl("1: ", ptex.resolution1)
- reslbl("2: ", ptex.resolution2)
- reslbl("3: ", ptex.resolution3)
+ reslbl("1: ", ptex.subfaces[0].resolution)
+ reslbl("2: ", ptex.subfaces[1].resolution)
+ reslbl("3: ", ptex.subfaces[2].resolution)
def register():
Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h 2010-08-18 22:08:45 UTC (rev 31449)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h 2010-08-18 23:59:26 UTC (rev 31450)
@@ -173,7 +173,7 @@
DMGridAdjacency *(*getGridAdjacency)(DerivedMesh *dm);
int *(*getGridOffset)(DerivedMesh *dm);
struct GridKey *(*getGridKey)(DerivedMesh *dm);
- struct GridToFace *(*getGridFaceMap)(DerivedMesh *dm, struct Object *ob);
+ struct GridToFace *(*getGridFaceMap)(DerivedMesh *dm);
/* Iterate over each mapped vertex in the derived mesh, calling the
* given function with the original vert and the mapped vert's new
Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_customdata.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_customdata.h 2010-08-18 22:08:45 UTC (rev 31449)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_customdata.h 2010-08-18 23:59:26 UTC (rev 31450)
@@ -367,6 +367,3 @@
struct ID *id, CustomDataMask mask, int totelem);
#endif
-
-struct MPtex;
-void *mptex_grid_offset(struct MPtex *pt, int offset, int *ures, int *vres, int *rowlen);
Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/DerivedMesh.c 2010-08-18 22:08:45 UTC (rev 31449)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/DerivedMesh.c 2010-08-18 23:59:26 UTC (rev 31450)
@@ -46,11 +46,14 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_displist.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_dmgrid.h"
#include "BKE_key.h"
#include "BKE_modifier.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_paint.h"
+#include "BKE_ptex.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
@@ -1927,6 +1930,13 @@
add_weight_mcol_dm(ob, finaldm);
}
+ /* hack: for ptex paint use all quads */
+ if((ob->mode & OB_MODE_VERTEX_PAINT) && finaldm->type != DM_TYPE_CCGDM) {
+ dm = finaldm;
+ finaldm = quad_dm_create_from_derived(finaldm);
+ dm->release(dm);
+ }
+
/* add an orco layer if needed */
if(dataMask & CD_MASK_ORCO) {
add_orco_dm(ob, NULL, finaldm, orcodm, CD_ORCO);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list