Merging r59113 through r59129 from trunk into soc-2013-depsgraph_mt

This commit is contained in:
Sergey Sharybin
2013-08-14 07:08:59 +00:00
8 changed files with 153 additions and 114 deletions

View File

@@ -796,7 +796,7 @@ struct TranslationRotationWarp {
parameters[1] = t[1];
// Obtain the rotation via orthorgonal procrustes.
Mat2 correlation_matrix;
Mat2 correlation_matrix = Mat2::Zero();
for (int i = 0; i < 4; ++i) {
correlation_matrix += q1.CornerRelativeToCentroid(i) *
q2.CornerRelativeToCentroid(i).transpose();
@@ -864,7 +864,7 @@ struct TranslationRotationScaleWarp {
parameters[2] = 1.0 - q2.Scale() / q1.Scale();
// Obtain the rotation via orthorgonal procrustes.
Mat2 correlation_matrix;
Mat2 correlation_matrix = Mat2::Zero();
for (int i = 0; i < 4; ++i) {
correlation_matrix += q1.CornerRelativeToCentroid(i) *
q2.CornerRelativeToCentroid(i).transpose();

View File

@@ -33,14 +33,13 @@
#ifndef __OSL_CLOSURES_H__
#define __OSL_CLOSURES_H__
#include "util_types.h"
#include "kernel_types.h"
#include <OSL/oslclosure.h>
#include <OSL/oslexec.h>
#include <OSL/genclosure.h>
#include "kernel_types.h"
#include "util_types.h"
CCL_NAMESPACE_BEGIN
OSL::ClosureParam *closure_emission_params();

View File

@@ -105,11 +105,11 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
default=12,
)
mode = bpy.props.EnumProperty(
name="Torus Dimentions",
name="Torus Dimensions",
items=(("MAJOR_MINOR", "Major/Minor",
"Use the major/minor radiuses for torus dimensions"),
"Use the major/minor radii for torus dimensions"),
("EXT_INT", "Exterior/Interior",
"Use the exterior/interior radiuses for torus dimensions")),
"Use the exterior/interior radii for torus dimensions")),
update=mode_update_callback,
)
major_radius = FloatProperty(

View File

@@ -2282,15 +2282,18 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
}
}
else {
/* Need to correct quat for the last point,
/* Need to correct quat for the first/last point,
* this is so because previously it was only calculated
* using it's own direction, which might not correspond
* the twist of previous point.
* the twist of neighbor point.
*/
bevp1 = (BevPoint *)(bl + 1);
bevp0 = bevp1 + 1;
minimum_twist_between_two_points(bevp1, bevp0);
bevp2 = (BevPoint *)(bl + 1);
bevp1 = bevp2 + (bl->nr - 1);
bevp0 = bevp1 - 1;
minimum_twist_between_two_points(bevp1, bevp0);
}
}

View File

@@ -173,4 +173,14 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
MEM_freeN(arr); \
} (void)0
void _bli_array_reverse(void *arr, unsigned int arr_len, size_t arr_stride);
#define BLI_array_reverse(arr, arr_len) \
_bli_array_reverse(arr, arr_len, sizeof(*(arr)))
void _bli_array_wrap(void *arr, unsigned int arr_len, size_t arr_stride, int dir);
#define BLI_array_wrap(arr, arr_len, dir) \
_bli_array_wrap(arr, arr_len, sizeof(*(arr)), dir)
#endif /* __BLI_ARRAY_H__ */

View File

@@ -59,9 +59,14 @@
*/
#include <string.h>
#include <stdlib.h>
#include "BLI_array.h"
#include "BLI_sys_types.h"
#include "BLI_utildefines.h"
#include "BLI_alloca.h"
#include "MEM_guardedalloc.h"
/**
@@ -95,3 +100,40 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
arr_count += num;
#endif
}
void _bli_array_reverse(void *arr_v, unsigned int arr_len, size_t arr_stride)
{
const unsigned int arr_half_stride = (arr_len / 2) * arr_stride;
unsigned int i, i_end;
char *arr = arr_v;
char *buf = BLI_array_alloca(buf, arr_stride);
for (i = 0, i_end = (arr_len - 1) * arr_stride;
i < arr_half_stride;
i += arr_stride, i_end -= arr_stride)
{
memcpy(buf, &arr[i], arr_stride);
memcpy(&arr[i], &arr[i_end], arr_stride);
memcpy(&arr[i_end], buf, arr_stride);
}
}
void _bli_array_wrap(void *arr_v, unsigned int arr_len, size_t arr_stride, int dir)
{
char *arr = arr_v;
char *buf = BLI_array_alloca(buf, arr_stride);
if (dir == -1) {
memcpy(buf, arr, arr_stride);
memmove(arr, arr + arr_stride, arr_stride * (arr_len - 1));
memcpy(arr + (arr_stride * (arr_len - 1)), buf, arr_stride);
}
else if (dir == 1) {
memcpy(buf, arr + (arr_stride * (arr_len - 1)), arr_stride);
memmove(arr + arr_stride, arr, arr_stride * (arr_len - 1));
memcpy(arr, buf, arr_stride);
}
else {
BLI_assert(0);
}
}

View File

@@ -31,6 +31,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_array.h"
#include "BLI_alloca.h"
#include "BLI_smallhash.h"
#include "BLI_rand.h"
#include "BLI_heap.h"
@@ -885,27 +886,82 @@ BLI_INLINE void vote_on_winding(BMEdge *edge, EPathNode *node, unsigned int wind
winding[(test_v1 == node->v)]++;
}
static BMFace *bm_face_from_path(BMesh *bm, EPath *path,
EdgeData *edata,
const bool use_fill_check)
{
/* accumulte winding directions for each edge which has a face */
const unsigned int path_len = BLI_countlist(&path->nodes);
unsigned int winding[2] = {0, 0};
unsigned int i;
EPathNode *node;
BMVert **verts = BLI_array_alloca(verts, path_len);
BMEdge **edges = BLI_array_alloca(edges, path_len);
BMEdge *e;
BMVert *v;
for (node = path->nodes.first, i = 0; node; node = node->next, i++) {
v = node->v;
e = BM_edge_exists(v, node->next ?
node->next->v :
((EPathNode *)path->nodes.first)->v);
/* check on the winding */
if (e->l) {
if (UNLIKELY(count_edge_faces(bm, e) >= 2)) {
return NULL;
}
vote_on_winding(e, node, winding);
}
verts[i] = v;
edges[i] = e;
}
/* do after incase we bail early, above */
for (i = 0; i < path_len; i++) {
edata[BM_elem_index_get(edges[i])].ftag++;
}
/* if these are even it doesn't really matter what to do,
* with consistent geometry one will be zero, the choice is clear */
if (winding[0] > winding[1]) {
BLI_array_wrap(verts, path_len, -1);
BLI_array_reverse(verts, path_len);
BLI_array_reverse(edges, path_len);
}
if ((use_fill_check == false) ||
/* fairly expensive check - see if there are already faces filling this area */
(BM_face_exists_multi(verts, edges, path_len) == false))
{
return BM_face_create(bm, verts, edges, path_len, BM_CREATE_NO_DOUBLE);
}
else {
return NULL;
}
}
void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
{
BMIter iter;
BMOIter siter;
BMFace *f;
BMEdge *e;
BMVert **verts = NULL;
BLI_array_declare(verts);
EPath *path;
EPathNode *node;
EdgeData *edata;
VertData *vdata;
BMEdge **edges = NULL;
PathBase *pathbase;
BLI_array_declare(edges);
const bool use_restrict = BMO_slot_bool_get(op->slots_in, "use_restrict");
const bool use_fill_check = BMO_slot_bool_get(op->slots_in, "use_fill_check");
const short mat_nr = BMO_slot_int_get(op->slots_in, "mat_nr");
const bool use_smooth = BMO_slot_bool_get(op->slots_in, "use_smooth");
int i, j;
unsigned int winding[2]; /* accumulte winding directions for each edge which has a face */
int i;
BMOpSlot *slot_restrict = BMO_slot_get(op->slots_in, "restrict");
BMOpSlot *slot_face_groupmap_out = BMO_slot_get(op->slots_out, "face_groupmap.out");
@@ -978,99 +1034,28 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
edata[BM_elem_index_get(edge)].tag += 1;
path = edge_find_shortest_path(bm, op, edge, edata, vdata, pathbase, group);
if (!path)
continue;
if (path && path->nodes.first) {
BMFace *f = bm_face_from_path(bm, path, edata,
use_fill_check);
winding[0] = winding[1] = 0;
BLI_array_empty(edges);
BLI_array_empty(verts);
i = 0;
for (node = path->nodes.first; node; node = node->next) {
if (!node->next)
continue;
e = BM_edge_exists(node->v, node->next->v);
/* this should never happe */
if (!e)
break;
/* check on the winding */
if (e->l) {
vote_on_winding(e, node, winding);
}
edata[BM_elem_index_get(e)].ftag++;
BLI_array_grow_one(edges);
edges[i++] = e;
BLI_array_append(verts, node->v);
}
if (edge->l) {
vote_on_winding(edge, path->nodes.last, winding);
}
BLI_array_grow_one(edges);
edges[i++] = edge;
edata[BM_elem_index_get(edge)].ftag++;
for (j = 0; j < i; j++) {
if (count_edge_faces(bm, edges[j]) >= 2) {
edge_free_path(pathbase, path);
break;
}
}
if (j != i) {
continue;
}
if (i) {
BMVert *v1, *v2;
/* to define the winding order must select first edge,
* otherwise we could leave this as-is */
edge = edges[0];
/* if these are even it doesn't really matter what to do,
* with consistent geometry one will be zero, the choice is clear */
if (winding[0] < winding[1]) {
v1 = verts[0];
v2 = verts[1];
}
else {
v1 = verts[1];
v2 = verts[0];
}
if ((use_fill_check == false) ||
/* fairly expensive check - see if there are already faces filling this area */
(BM_face_exists_multi_edge(edges, i) == false))
{
f = BM_face_create_ngon(bm, v1, v2, edges, i, BM_CREATE_NO_DOUBLE);
if (f && !BMO_elem_flag_test(bm, f, ELE_ORIG)) {
BMO_elem_flag_enable(bm, f, FACE_NEW);
f->mat_nr = mat_nr;
if (use_smooth) {
BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
}
}
if (use_restrict) {
BMO_slot_map_int_insert(op, slot_face_groupmap_out, f, path->group);
if (f && !BMO_elem_flag_test(bm, f, ELE_ORIG)) {
BMO_elem_flag_enable(bm, f, FACE_NEW);
f->mat_nr = mat_nr;
if (use_smooth) {
BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
}
}
}
edge_free_path(pathbase, path);
if (use_restrict) {
BMO_slot_map_int_insert(op, slot_face_groupmap_out, f, path->group);
}
edge_free_path(pathbase, path);
}
}
BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_NEW);
BLI_array_free(edges);
BLI_array_free(verts);
edge_pathbase_free(pathbase);
MEM_freeN(edata);
MEM_freeN(vdata);

View File

@@ -401,21 +401,21 @@ void KX_Dome::GLDrawWarpQuads(void)
if (warp.nodes[i][j].i < 0 || warp.nodes[i+1][j].i < 0 || warp.nodes[i+1][j+1].i < 0 || warp.nodes[i][j+1].i < 0)
continue;
glColor3f(warp.nodes[i][j].i, warp.nodes[i][j].i, warp.nodes[i][j].i);
glTexCoord2f((warp.nodes[i][j].u * uv_width), (warp.nodes[i][j].v * uv_height));
glVertex3f(warp.nodes[i][j].x, warp.nodes[i][j].y,0.0);
glColor3f(warp.nodes[i+1][j].i, warp.nodes[i+1][j].i, warp.nodes[i+1][j].i);
glTexCoord2f((warp.nodes[i+1][j].u * uv_width), (warp.nodes[i+1][j].v * uv_height));
glVertex3f(warp.nodes[i+1][j].x, warp.nodes[i+1][j].y,0.0);
glColor3f(warp.nodes[i][j+1].i, warp.nodes[i][j+1].i, warp.nodes[i][j+1].i);
glTexCoord2f((warp.nodes[i][j+1].u * uv_width), (warp.nodes[i][j+1].v * uv_height));
glVertex3f(warp.nodes[i][j+1].x, warp.nodes[i][j+1].y,0.0);
glColor3f(warp.nodes[i+1][j+1].i, warp.nodes[i+1][j+1].i, warp.nodes[i+1][j+1].i);
glTexCoord2f((warp.nodes[i+1][j+1].u * uv_width), (warp.nodes[i+1][j+1].v * uv_height));
glVertex3f(warp.nodes[i+1][j+1].x, warp.nodes[i+1][j+1].y,0.0);
glColor3f(warp.nodes[i][j+1].i, warp.nodes[i][j+1].i, warp.nodes[i][j+1].i);
glTexCoord2f((warp.nodes[i][j+1].u * uv_width), (warp.nodes[i][j+1].v * uv_height));
glVertex3f(warp.nodes[i][j+1].x, warp.nodes[i][j+1].y,0.0);
glColor3f(warp.nodes[i+1][j].i, warp.nodes[i+1][j].i, warp.nodes[i+1][j].i);
glTexCoord2f((warp.nodes[i+1][j].u * uv_width), (warp.nodes[i+1][j].v * uv_height));
glVertex3f(warp.nodes[i+1][j].x, warp.nodes[i+1][j].y,0.0);
glColor3f(warp.nodes[i][j].i, warp.nodes[i][j].i, warp.nodes[i][j].i);
glTexCoord2f((warp.nodes[i][j].u * uv_width), (warp.nodes[i][j].v * uv_height));
glVertex3f(warp.nodes[i][j].x, warp.nodes[i][j].y,0.0);
}
}
glEnd();