[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32727] branches/bmesh/blender: ad-hoc test sys that can handle paint stuff.
Joseph Eagar
joeedh at gmail.com
Wed Oct 27 04:22:56 CEST 2010
Revision: 32727
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32727
Author: joeedh
Date: 2010-10-27 04:22:55 +0200 (Wed, 27 Oct 2010)
Log Message:
-----------
ad-hoc test sys that can handle paint stuff. temporary.
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/BKE_context.h
branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h
branches/bmesh/blender/source/blender/blenkernel/intern/context.c
branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
branches/bmesh/blender/source/blender/editors/space_view3d/view3d_intern.h
branches/bmesh/blender/source/blender/editors/space_view3d/view3d_ops.c
branches/bmesh/blender/source/blender/editors/space_view3d/view3d_toolbar.c
branches/bmesh/blender/source/blender/makesdna/DNA_windowmanager_types.h
branches/bmesh/blender/source/blender/makesrna/intern/rna_mesh.c
branches/bmesh/blender/source/blender/makesrna/intern/rna_mesh_api.c
branches/bmesh/blender/source/blender/windowmanager/WM_types.h
branches/bmesh/blender/source/blender/windowmanager/intern/wm_event_system.c
branches/bmesh/blender/source/blender/windowmanager/intern/wm_window.c
branches/bmesh/blender/source/creator/creator.c
Added Paths:
-----------
branches/bmesh/blender/test/
branches/bmesh/blender/test/eventlog.txt
branches/bmesh/blender/test/test_default.blend
branches/bmesh/blender/test/test_default.blend1
branches/bmesh/blender/test/test_vcol.blend
branches/bmesh/blender/test/test_vcol.blend1
branches/bmesh/blender/test/test_vcol.events
branches/bmesh/blender/test/test_vcol_final.blend
branches/bmesh/blender/test/tester.py
Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_context.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_context.h 2010-10-27 02:18:24 UTC (rev 32726)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_context.h 2010-10-27 02:22:55 UTC (rev 32727)
@@ -261,6 +261,9 @@
int CTX_data_selected_pose_bones(const bContext *C, ListBase *list);
int CTX_data_visible_pose_bones(const bContext *C, ListBase *list);
+//stupid compiler flag isn't working
+//remember to undef this later
+#define EVENT_RECORDER
#ifdef EVENT_RECORDER
#include <stdio.h>
@@ -268,6 +271,8 @@
FILE *CTX_rec_file(bContext *C);
int CTX_set_events_path(bContext *C, char *path);
int CTX_play_events(bContext *C, char **playpath);
+int CTX_rec_events_set(bContext *C, int state);
+double CTX_rec_lasttime(bContext *C, double newtime);
#endif
Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h 2010-10-27 02:18:24 UTC (rev 32726)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h 2010-10-27 02:22:55 UTC (rev 32727)
@@ -112,6 +112,12 @@
void mesh_delete_material_index(struct Mesh *me, int index);
void mesh_set_smooth_flag(struct Object *meshOb, int enableSmooth);
+/*used for unit testing; compares two meshes, checking only
+ differences we care about. should be usable with leaf's
+ testing framework I get RNA work done, will use hackish
+ testing code for now.*/
+char *mesh_cmp(struct Mesh *me1, struct Mesh *me2, float thresh);
+
struct BoundBox *mesh_get_bb(struct Object *ob);
void mesh_get_texspace(struct Mesh *me, float *loc_r, float *rot_r, float *size_r);
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/context.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/context.c 2010-10-27 02:18:24 UTC (rev 32726)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/context.c 2010-10-27 02:22:55 UTC (rev 32727)
@@ -41,6 +41,7 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
+#include "PIL_time.h"
#include "BKE_context.h"
#include "BKE_main.h"
@@ -84,6 +85,7 @@
#ifdef EVENT_RECORDER
int evtrec, evtplay;
char evtplaypath[300];
+ double evtlasttime;
#endif
};
@@ -111,6 +113,13 @@
return C->evtrec;
}
+int CTX_rec_events_set(bContext *C, int state)
+{
+ C->evtrec = state;
+
+ return 1;
+}
+
FILE *CTX_rec_file(bContext *C)
{
static FILE *f = NULL;
@@ -119,15 +128,34 @@
return f;
}
+double CTX_rec_lasttime(bContext *C, double newtime)
+{
+ double ret;
+
+ if (C->evtlasttime == 0.0) {
+ ret = newtime;
+ } else ret = C->evtlasttime;
+
+ C->evtlasttime = newtime;
+
+ return ret;
+}
+
int CTX_set_events_path(bContext *C, char *path)
{
if (!path)
C->evtplaypath[0] = 0;
+ else
+ strcpy(C->evtplaypath, path);
+
+ return 1;
}
+extern int erec_playing;
int CTX_play_events(bContext *C, char **playpath)
{
- *playpath = C->evtplaypath[0] ? C->evtplaypath : NULL;
+ if (playpath)
+ *playpath = C->evtplaypath[0] ? C->evtplaypath : NULL;
return C->evtplaypath[0];
}
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2010-10-27 02:18:24 UTC (rev 32726)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2010-10-27 02:22:55 UTC (rev 32727)
@@ -42,9 +42,11 @@
#include "DNA_key_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_ipo_types.h"
+#include "DNA_customdata_types.h"
#include "BKE_animsys.h"
#include "BKE_main.h"
+#include "BKE_customdata.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
#include "BKE_mesh.h"
@@ -58,6 +60,7 @@
#include "BKE_object.h"
#include "BKE_utildefines.h"
#include "BKE_tessmesh.h"
+#include "BLI_edgehash.h"
#include "BLI_blenlib.h"
#include "BLI_editVert.h"
@@ -68,6 +71,230 @@
#include "bmesh.h"
+enum {
+ MESHCMP_DVERT_WEIGHTMISMATCH = 1,
+ MESHCMP_DVERT_GROUPMISMATCH,
+ MESHCMP_DVERT_TOTGROUPMISMATCH,
+ MESHCMP_LOOPCOLMISMATCH,
+ MESHCMP_LOOPUVMISMATCH,
+ MESHCMP_LOOPMISMATCH,
+ MESHCMP_POLYVERTMISMATCH,
+ MESHCMP_POLYMISMATCH,
+ MESHCMP_EDGEUNKNOWN,
+ MESHCMP_VERTCOMISMATCH,
+ MESHCMP_CDLAYERS_MISMATCH,
+};
+
+static char *cmpcode_to_str(int code)
+{
+ switch (code) {
+ case MESHCMP_DVERT_WEIGHTMISMATCH:
+ return "Vertex Weight Mismatch";
+ case MESHCMP_DVERT_GROUPMISMATCH:
+ return "Vertex Group Mismatch";
+ case MESHCMP_DVERT_TOTGROUPMISMATCH:
+ return "Vertex Doesn't Belong To Same Number Of Groups";
+ case MESHCMP_LOOPCOLMISMATCH:
+ return "Vertex Color Mismatch";
+ case MESHCMP_LOOPUVMISMATCH:
+ return "UV Mismatch";
+ case MESHCMP_LOOPMISMATCH:
+ return "Loop Mismatch";
+ case MESHCMP_POLYVERTMISMATCH:
+ return "Loop Vert Mismatch In Poly Test";
+ case MESHCMP_POLYMISMATCH:
+ return "Loop Vert Mismatch";
+ case MESHCMP_EDGEUNKNOWN:
+ return "Edge Mismatch";
+ case MESHCMP_VERTCOMISMATCH:
+ return "Vertex Coordinate Mismatch";
+ case MESHCMP_CDLAYERS_MISMATCH:
+ "CustomData Layer Count Mismatch";
+ default:
+ return "Mesh Comparison Code Unknown";
+ }
+}
+
+/*thresh is threshold for comparing vertices, uvs, vertex colors,
+ weights, etc.*/
+int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2, float thresh)
+{
+ CustomDataLayer *l1, *l2;
+ int i, i1=0, i2=0, tot, j;
+
+ for (i=0; i<c1->totlayer; i++) {
+ if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
+ CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
+ i1++;
+ }
+
+ for (i=0; i<c2->totlayer; i++) {
+ if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY,
+ CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
+ i2++;
+ }
+
+ if (i1 != i2)
+ return MESHCMP_CDLAYERS_MISMATCH;
+
+ l1 = c1->layers; l2 = c2->layers;
+ tot = i1;
+ i1 = 0; i2 = 0;
+ for (i=0; i < tot; i++) {
+ while (i1 < c1->totlayer && !ELEM7(l1->type, CD_MVERT, CD_MEDGE, CD_MPOLY,
+ CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
+ i1++, l1++;
+
+ while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY,
+ CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT))
+ i2++, l2++;
+
+ if (l1->type == CD_MVERT) {
+ MVert *v1 = l1->data;
+ MVert *v2 = l2->data;
+ int vtot = m1->totvert;
+
+ for (j=0; j<vtot; j++, v1++, v2++) {
+ if (len_v3v3(v1->co, v2->co) > thresh)
+ return MESHCMP_VERTCOMISMATCH;
+ /*I don't care about normals, let's just do coodinates*/
+ }
+ }
+
+ /*we're order-agnostic for edges here*/
+ if (l1->type == CD_MEDGE) {
+ MEdge *e1 = l1->data;
+ MEdge *e2 = l2->data;
+ EdgeHash *eh = BLI_edgehash_new();
+ int etot = m1->totedge;
+
+ for (j=0; j<etot; j++, e1++) {
+ BLI_edgehash_insert(eh, e1->v1, e1->v2, e1);
+ }
+
+ for (j=0; j<etot; j++, e2++) {
+ if (!BLI_edgehash_lookup(eh, e2->v1, e2->v2))
+ return MESHCMP_EDGEUNKNOWN;
+ }
+ BLI_edgehash_free(eh, NULL);
+ }
+
+ if (l1->type == CD_MPOLY) {
+ MPoly *p1 = l1->data;
+ MPoly *p2 = l2->data;
+ int ptot = m1->totpoly;
+
+ for (j=0; j<ptot; j++, p1++, p2++) {
+ MLoop *lp1, *lp2;
+ int k;
+
+ if (p1->totloop != p2->totloop)
+ return MESHCMP_POLYMISMATCH;
+
+ lp1 = m1->mloop + p1->loopstart;
+ lp2 = m2->mloop + p2->loopstart;
+
+ for (k=0; k<p1->totloop; k++, lp1++, lp2++) {
+ if (lp1->v != lp2->v)
+ return MESHCMP_POLYVERTMISMATCH;
+ }
+ }
+ }
+ if (l1->type == CD_MLOOP) {
+ MLoop *lp1 = l1->data;
+ MLoop *lp2 = l2->data;
+ int ltot = m1->totloop;
+
+ for (j=0; j<ltot; j++, lp1++, lp2++) {
+ if (lp1->v != lp2->v)
+ return MESHCMP_LOOPMISMATCH;
+ }
+ }
+ if (l1->type == CD_MLOOPUV) {
+ MLoopUV *lp1 = l1->data;
+ MLoopUV *lp2 = l2->data;
+ int ltot = m1->totloop;
+
+ for (j=0; j<ltot; j++, lp1++, lp2++) {
+ if (len_v2v2(lp1->uv, lp2->uv) > thresh)
+ return MESHCMP_LOOPUVMISMATCH;
+ }
+ }
+
+ if (l1->type == CD_MLOOPCOL) {
+ MLoopCol *lp1 = l1->data;
+ MLoopCol *lp2 = l2->data;
+ int ltot = m1->totloop;
+
+ for (j=0; j<ltot; j++, lp1++, lp2++) {
+ if (ABS(lp1->r - lp2->r) > thresh ||
+ ABS(lp1->g - lp2->g) > thresh ||
+ ABS(lp1->b - lp2->b) > thresh ||
+ ABS(lp1->a - lp2->a) > thresh)
+ {
+ return MESHCMP_LOOPCOLMISMATCH;
+ }
+ }
+ }
+
+ if (l1->type == CD_MDEFORMVERT) {
+ MDeformVert *dv1 = l1->data;
+ MDeformVert *dv2 = l2->data;
+ int dvtot = m1->totvert;
+
+ for (j=0; j<dvtot; j++, dv1++, dv2++) {
+ int k;
+ MDeformWeight *dw1 = dv1->dw, *dw2=dv2->dw;
+
+ if (dv1->totweight != dv2->totweight)
+ return MESHCMP_DVERT_TOTGROUPMISMATCH;
+
+ for (k=0; k<dv1->totweight; k++, dw1++, dw2++) {
+ if (dw1->def_nr != dw2->def_nr)
+ return MESHCMP_DVERT_GROUPMISMATCH;
+ if (ABS(dw1->weight - dw2->weight) > thresh)
+ return MESHCMP_DVERT_WEIGHTMISMATCH;
+ }
+ }
+ }
+ }
+}
+
+/*used for testing. returns an error string the two meshes don't match*/
+char *mesh_cmp(Mesh *me1, Mesh *me2, float thresh)
+{
+ int c;
+
+ if (!me1 || !me2)
+ return "Requires two input meshes";
+
+ if (me1->totvert != me2->totvert)
+ return "Number of verts don't match";
+
+ if (me1->totedge != me2->totedge)
+ return "Number of edges don't match";
+
+ if (me1->totpoly != me2->totpoly)
+ return "Number of faces don't match";
+
+ if (me1->totloop !=me2->totloop)
+ return "Number of loops don't match";
+
+ if ((c = customdata_compare(&me1->vdata, &me2->vdata, me1, me2, thresh)))
+ return cmpcode_to_str(c);
+
+ if ((c = customdata_compare(&me1->edata, &me2->edata, me1, me2, thresh)))
+ return cmpcode_to_str(c);
+
+ if ((c = customdata_compare(&me1->ldata, &me2->ldata, me1, me2, thresh)))
+ return cmpcode_to_str(c);
+
+ if ((c = customdata_compare(&me1->pdata, &me2->pdata, me1, me2, thresh)))
+ return cmpcode_to_str(c);
+
+ return NULL;
+}
+
static void mesh_ensure_tesselation_customdata(Mesh *me)
{
int tottex, totcol;
Modified: branches/bmesh/blender/source/blender/editors/space_view3d/view3d_intern.h
===================================================================
--- branches/bmesh/blender/source/blender/editors/space_view3d/view3d_intern.h 2010-10-27 02:18:24 UTC (rev 32726)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list