Merge branch 'master' into blender2.8

This commit is contained in:
Sergey Sharybin 2017-09-19 21:08:14 +05:00
commit af170839af
45 changed files with 336 additions and 152 deletions

View File

@ -16,19 +16,23 @@
#
# ***** END GPL LICENSE BLOCK *****
set(LIBSNDFILE_EXTRA_ARGS)
set(LIBSNDFILE_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/flac/lib/pkgconfig:${mingw_LIBDIR})
set(SNDFILE_EXTRA_ARGS)
set(SNDFILE_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/flac/lib/pkgconfig:${mingw_LIBDIR})
if(WIN32)
set(LIBSNDFILE_ENV set ${LIBSNDFILE_ENV} &&)
set(SNDFILE_ENV set ${SNDFILE_ENV} &&)
#shared for windows because static libs will drag in a libgcc dependency.
set(SNDFILE_OPTIONS --disable-static --enable-shared )
else()
set(SNDFILE_OPTIONS --enable-static --disable-shared )
endif()
ExternalProject_Add(external_sndfile
URL ${LIBSNDFILE_URI}
URL ${SNDFILE_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${LIBSNDFILE_HASH}
URL_HASH MD5=${SNDFILE_HASH}
PREFIX ${BUILD_DIR}/sndfile
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && ${LIBSNDFILE_ENV} ${CONFIGURE_COMMAND} --enable-static --disable-shared --prefix=${mingw_LIBDIR}/sndfile
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && ${SNDFILE_ENV} ${CONFIGURE_COMMAND} ${SNDFILE_OPTIONS} --prefix=${mingw_LIBDIR}/sndfile
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make -j${MAKE_THREADS}
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make install
INSTALL_DIR ${LIBDIR}/sndfile

View File

@ -216,9 +216,9 @@ set(LAPACK_VERSION 3.6.0)
set(LAPACK_URI http://www.netlib.org/lapack/lapack-${LAPACK_VERSION}.tgz)
set(LAPACK_HASH f2f6c67134e851fe189bb3ca1fbb5101)
set(LIBSNDFILE_VERSION 1.0.26)
set(LIBSNDFILE_URI http://www.mega-nerd.com/libsndfile/files/libsndfile-${LIBSNDFILE_VERSION}.tar.gz)
set(LIBSNDFILE_HASH ec810a0c60c08772a8a5552704b63393)
set(SNDFILE_VERSION 1.0.28)
set(SNDFILE_URI http://www.mega-nerd.com/libsndfile/files/libsndfile-${SNDFILE_VERSION}.tar.gz)
set(SNDFILE_HASH 646b5f98ce89ac60cdb060fcd398247c)
#set(HIDAPI_VERSION 0.8.0-rc1)
#set(HIDAPI_URI https://github.com/signal11/hidapi/archive/hidapi-${HIDAPI_VERSION}.tar.gz)

View File

@ -1847,47 +1847,134 @@ static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int i
assert(iNrTrianglesIn == t);
}
static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn, const int iTotTris)
typedef struct VertReverseLookupContext {
tbool bIsInitialized;
int * pLookup;
int iMaxVertIndex;
} VertReverseLookupContext;
static void GenerateReverseLookup(
const int piTriListIn[],
const int iNrTrianglesIn,
VertReverseLookupContext *pLookupCtx)
{
int t;
// Figure out what size of lookup array we need.
pLookupCtx->iMaxVertIndex = -1;
for (t=0; t<3*iNrTrianglesIn; t++)
{
int iVertIndex = piTriListIn[t];
if (iVertIndex > pLookupCtx->iMaxVertIndex) {
pLookupCtx->iMaxVertIndex = iVertIndex;
}
}
// Allocate memory.
if (pLookupCtx->iMaxVertIndex < 1)
{
// Nothing to allocate, all triangles are degenerate.
return;
}
pLookupCtx->pLookup = malloc(sizeof(int) * (pLookupCtx->iMaxVertIndex + 1));
if (pLookupCtx->pLookup == NULL)
{
// Most likely run out of memory.
return;
}
// Fill in lookup.
for (t=0; t<=pLookupCtx->iMaxVertIndex; t++) {
pLookupCtx->pLookup[t] = -1;
}
for (t=0; t<3*iNrTrianglesIn; t++)
{
int iVertIndex = piTriListIn[t];
if (pLookupCtx->pLookup[iVertIndex] != -1)
{
continue;
}
pLookupCtx->pLookup[iVertIndex] = t;
}
}
static int LookupVertexIndexFromGoodTriangle(
VertReverseLookupContext *pLookupCtx,
int piTriListIn[],
const int iNrTrianglesIn,
const int iVertexIndex)
{
// Allocate lookup on demand.
if (!pLookupCtx->bIsInitialized)
{
GenerateReverseLookup(piTriListIn,
iNrTrianglesIn,
pLookupCtx);
pLookupCtx->bIsInitialized = TTRUE;
}
// Make sure vertex index is in the mapping.
if (iVertexIndex > pLookupCtx->iMaxVertIndex)
{
return -1;
}
if (pLookupCtx->pLookup == NULL) {
return -1;
}
// Perform actual lookup.
return pLookupCtx->pLookup[iVertexIndex];
}
static void FreeReverseLookup(VertReverseLookupContext *pLookupCtx)
{
if (!pLookupCtx->bIsInitialized) {
return;
}
if (pLookupCtx->pLookup != NULL) {
free(pLookupCtx->pLookup);
}
}
static void DegenEpilogue(STSpace psTspace[],
STriInfo pTriInfos[],
int piTriListIn[],
const SMikkTSpaceContext * pContext,
const int iNrTrianglesIn,
const int iTotTris)
{
int t=0, i=0;
VertReverseLookupContext lookupCtx = { TFALSE };
// deal with degenerate triangles
// punishment for degenerate triangles is O(N^2)
// punishment for degenerate triangles is O(iNrTrianglesIn) extra memory.
for (t=iNrTrianglesIn; t<iTotTris; t++)
{
// degenerate triangles on a quad with one good triangle are skipped
// here but processed in the next loop
const tbool bSkip = (pTriInfos[t].iFlag&QUAD_ONE_DEGEN_TRI)!=0 ? TTRUE : TFALSE;
if (bSkip) {
continue;
}
if (!bSkip)
for (i=0; i<3; i++)
{
for (i=0; i<3; i++)
const int index1 = piTriListIn[t*3+i];
int j = LookupVertexIndexFromGoodTriangle(&lookupCtx,
piTriListIn,
iNrTrianglesIn,
index1);
if (j < 0)
{
const int index1 = piTriListIn[t*3+i];
// search through the good triangles
tbool bNotFound = TTRUE;
int j=0;
while (bNotFound && j<(3*iNrTrianglesIn))
{
const int index2 = piTriListIn[j];
if (index1==index2) bNotFound=TFALSE;
else ++j;
}
if (!bNotFound)
{
const int iTri = j/3;
const int iVert = j%3;
const int iSrcVert=pTriInfos[iTri].vert_num[iVert];
const int iSrcOffs=pTriInfos[iTri].iTSpacesOffs;
const int iDstVert=pTriInfos[t].vert_num[i];
const int iDstOffs=pTriInfos[t].iTSpacesOffs;
// copy tspace
psTspace[iDstOffs+iDstVert] = psTspace[iSrcOffs+iSrcVert];
}
// Matching vertex from good triangle is not found.
continue;
}
const int iTri = j/3;
const int iVert = j%3;
const int iSrcVert=pTriInfos[iTri].vert_num[iVert];
const int iSrcOffs=pTriInfos[iTri].iTSpacesOffs;
const int iDstVert=pTriInfos[t].vert_num[i];
const int iDstOffs=pTriInfos[t].iTSpacesOffs;
// copy tspace
psTspace[iDstOffs+iDstVert] = psTspace[iSrcOffs+iSrcVert];
}
}
FreeReverseLookup(&lookupCtx);
// deal with degenerate quads with one good triangle
for (t=0; t<iNrTrianglesIn; t++)

View File

@ -146,9 +146,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
layout.row().prop(md, "offset_type", expand=True)
def BOOLEAN(self, layout, ob, md):
solver = md.solver
if not bpy.app.build_options.mod_boolean:
layout.label("Built without Boolean modifier")
return
if solver == 'CARVE':
layout.label("Built without Carve solver")
split = layout.split()
@ -164,9 +165,13 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
split.column().label(text="Solver:")
split.column().prop(md, "solver", text="")
if md.solver == 'BMESH':
if solver == 'BMESH':
layout.prop(md, "double_threshold")
if bpy.app.debug:
layout.prop(md, "debug_options")
def BUILD(self, layout, ob, md):
split = layout.split()

View File

@ -192,7 +192,9 @@ struct DerivedMesh {
* \warning Typical access is done via #getLoopTriArray, #getNumLoopTri.
*/
struct {
struct MLoopTri *array;
/* WARNING! swapping between array (ready-to-be-used data) and array_wip (where data is actually computed)
* shall always be protected by same lock as one used for looptris computing. */
struct MLoopTri *array, *array_wip;
int num;
int num_alloc;
} looptris;

View File

@ -97,7 +97,7 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
#endif
static ThreadMutex loops_cache_lock = BLI_MUTEX_INITIALIZER;
static ThreadRWMutex loops_cache_lock = PTHREAD_RWLOCK_INITIALIZER;
static void add_shapekey_layers(DerivedMesh *dm, Mesh *me, Object *ob);
@ -244,19 +244,26 @@ static int dm_getNumLoopTri(DerivedMesh *dm)
static const MLoopTri *dm_getLoopTriArray(DerivedMesh *dm)
{
if (dm->looptris.array) {
MLoopTri *looptri;
BLI_rw_mutex_lock(&loops_cache_lock, THREAD_LOCK_READ);
looptri = dm->looptris.array;
BLI_rw_mutex_unlock(&loops_cache_lock);
if (looptri != NULL) {
BLI_assert(dm->getNumLoopTri(dm) == dm->looptris.num);
}
else {
BLI_mutex_lock(&loops_cache_lock);
BLI_rw_mutex_lock(&loops_cache_lock, THREAD_LOCK_WRITE);
/* We need to ensure array is still NULL inside mutex-protected code, some other thread might have already
* recomputed those looptris. */
if (dm->looptris.array == NULL) {
dm->recalcLoopTri(dm);
}
BLI_mutex_unlock(&loops_cache_lock);
looptri = dm->looptris.array;
BLI_rw_mutex_unlock(&loops_cache_lock);
}
return dm->looptris.array;
return looptri;
}
static CustomData *dm_getVertCData(DerivedMesh *dm)
@ -498,6 +505,8 @@ void DM_ensure_tessface(DerivedMesh *dm)
/**
* Ensure the array is large enough
*
* /note This function must always be thread-protected by caller. It should only be used by internal code.
*/
void DM_ensure_looptri_data(DerivedMesh *dm)
{
@ -505,18 +514,22 @@ void DM_ensure_looptri_data(DerivedMesh *dm)
const unsigned int totloop = dm->numLoopData;
const int looptris_num = poly_to_tri_count(totpoly, totloop);
BLI_assert(dm->looptris.array_wip == NULL);
SWAP(MLoopTri *, dm->looptris.array, dm->looptris.array_wip);
if ((looptris_num > dm->looptris.num_alloc) ||
(looptris_num < dm->looptris.num_alloc * 2) ||
(totpoly == 0))
{
MEM_SAFE_FREE(dm->looptris.array);
MEM_SAFE_FREE(dm->looptris.array_wip);
dm->looptris.num_alloc = 0;
dm->looptris.num = 0;
}
if (totpoly) {
if (dm->looptris.array == NULL) {
dm->looptris.array = MEM_mallocN(sizeof(*dm->looptris.array) * looptris_num, __func__);
if (dm->looptris.array_wip == NULL) {
dm->looptris.array_wip = MEM_mallocN(sizeof(*dm->looptris.array_wip) * looptris_num, __func__);
dm->looptris.num_alloc = looptris_num;
}

View File

@ -37,7 +37,7 @@
#include "BLI_math.h"
#include "BLI_edgehash.h"
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BKE_pbvh.h"
#include "BKE_cdderivedmesh.h"
@ -1799,12 +1799,16 @@ void CDDM_recalc_looptri(DerivedMesh *dm)
const unsigned int totloop = dm->numLoopData;
DM_ensure_looptri_data(dm);
BLI_assert(cddm->dm.looptris.array_wip != NULL);
BKE_mesh_recalc_looptri(
cddm->mloop, cddm->mpoly,
cddm->mvert,
totloop, totpoly,
cddm->dm.looptris.array);
cddm->dm.looptris.array_wip);
BLI_assert(cddm->dm.looptris.array == NULL);
SWAP(MLoopTri *, cddm->dm.looptris.array, cddm->dm.looptris.array_wip);
}
static void cdDM_free_internal(CDDerivedMesh *cddm)

View File

@ -279,8 +279,9 @@ static void emDM_recalcLoopTri(DerivedMesh *dm)
int i;
DM_ensure_looptri_data(dm);
mlooptri = dm->looptris.array;
mlooptri = dm->looptris.array_wip;
BLI_assert(mlooptri != NULL);
BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num);
BLI_assert(tottri == dm->looptris.num);
@ -297,6 +298,9 @@ static void emDM_recalcLoopTri(DerivedMesh *dm)
BM_elem_index_get(ltri[2]));
lt->poly = BM_elem_index_get(ltri[0]->f);
}
BLI_assert(dm->looptris.array == NULL);
SWAP(MLoopTri *, dm->looptris.array, dm->looptris.array_wip);
}
static void emDM_foreachMappedVert(

View File

@ -4228,8 +4228,9 @@ static void ccgDM_recalcLoopTri(DerivedMesh *dm)
int i, poly_index;
DM_ensure_looptri_data(dm);
mlooptri = dm->looptris.array;
mlooptri = dm->looptris.array_wip;
BLI_assert(mlooptri != NULL);
BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num);
BLI_assert(tottri == dm->looptris.num);
@ -4248,6 +4249,9 @@ static void ccgDM_recalcLoopTri(DerivedMesh *dm)
lt->tri[2] = (poly_index * 4) + 2;
lt->poly = poly_index;
}
BLI_assert(dm->looptris.array == NULL);
SWAP(MLoopTri *, dm->looptris.array, dm->looptris.array_wip);
}
static void ccgDM_calcNormals(DerivedMesh *dm)

View File

@ -681,6 +681,7 @@ static AVStream *alloc_video_stream(FFMpegContext *context, RenderData *rd, int
/* xasp & yasp got float lately... */
st->sample_aspect_ratio = c->sample_aspect_ratio = av_d2q(((double) rd->xasp / (double) rd->yasp), 255);
st->avg_frame_rate = av_inv_q(c->time_base);
set_ffmpeg_properties(rd, c, "video", &opts);

View File

@ -39,7 +39,7 @@ extern "C" {
#endif
#include "BLI_compiler_attrs.h"
#include "BLI_variadic_defines.h"
#include "BLI_utildefines_variadic.h"
struct ListBase;

View File

@ -39,7 +39,7 @@ extern "C" {
/* avoid many includes for now */
#include "BLI_sys_types.h"
#include "BLI_compiler_compat.h"
#include "BLI_variadic_defines.h"
#include "BLI_utildefines_variadic.h"
#ifndef NDEBUG /* for BLI_assert */
#include <stdio.h>

View File

@ -0,0 +1,52 @@
/*
* ***** 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
* of the License, or (at your option) any later version.
*
* 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,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_UTILDEFINES_ITER_H__
#define __BLI_UTILDEFINES_ITER_H__
/** \file BLI_utildefines_iter.h
* \ingroup bli
*
* General looping helpers, use `BLI_FOREACH` prefix.
*/
/**
* Even value distribution.
*
* \a src must be larger than \a dst,
* \a dst defines the number of iterations, their values are evenly spaced.
*
* The following pairs represent (src, dst) arguments and the values they loop over.
* <pre>
* (19, 4) -> [2, 7, 11. 16]
* (100, 5) -> [9, 29, 49, 69, 89]
* (100, 3) -> [16, 49, 83]
* (100, 100) -> [0..99]
* </pre>
* \note this is mainly useful for numbers that might not divide evenly into eachother.
*/
#define BLI_FOREACH_SPARSE_RANGE(src, dst, i) \
for (int _src = (src), _src2 = _src * 2, _dst2 = (dst) * 2, _error = _dst2 - _src, i = 0, _delta; \
((void)(_delta = divide_floor_i(_error, _dst2)), \
(void)(i -= _delta), \
(i < _src)); \
_error -= (_delta * _dst2) + _src2)
#endif /* __BLI_UTILDEFINES_ITER_H__ */

View File

@ -18,10 +18,10 @@
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_STACKDEFINES_H__
#define __BLI_STACKDEFINES_H__
#ifndef __BLI_UTILDEFINES_STACK_H__
#define __BLI_UTILDEFINES_STACK_H__
/** \file BLI_stackdefines.h
/** \file BLI_utildefines_stack.h
* \ingroup bli
*
* Macro's for a simple array based stack
@ -86,4 +86,4 @@
} ((void)0)
#endif
#endif /* __BLI_STACKDEFINES_H__ */
#endif /* __BLI_UTILDEFINES_STACK_H__ */

View File

@ -18,10 +18,10 @@
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_VARIADIC_DEFINES_H__
#define __BLI_VARIADIC_DEFINES_H__
#ifndef __BLI_UTILDEFINES_VARIADIC_H__
#define __BLI_UTILDEFINES_VARIADIC_H__
/** \file BLI_variadic_defines.h
/** \file BLI_utildefines_variadic.h
* \ingroup bli
*/
@ -47,4 +47,4 @@
#define VA_NARGS_CALL_OVERLOAD(name, ...) \
_VA_NARGS_GLUE(_VA_NARGS_OVERLOAD_MACRO(name, VA_NARGS_COUNT(__VA_ARGS__)), (__VA_ARGS__))
#endif /* __BLI_VARIADIC_DEFINES_H__ */
#endif /* __BLI_UTILDEFINES_VARIADIC_H__ */

View File

@ -195,7 +195,6 @@ set(SRC
BLI_sort.h
BLI_sort_utils.h
BLI_stack.h
BLI_stackdefines.h
BLI_strict_flags.h
BLI_string.h
BLI_string_cursor_utf8.h
@ -207,8 +206,10 @@ set(SRC
BLI_threads.h
BLI_timecode.h
BLI_utildefines.h
BLI_utildefines_iter.h
BLI_utildefines_stack.h
BLI_utildefines_variadic.h
BLI_uvproject.h
BLI_variadic_defines.h
BLI_vfontdata.h
BLI_voronoi.h
BLI_voxel.h

View File

@ -121,6 +121,10 @@ BLI_INLINE bool is_boundary_edge(unsigned int i_a, unsigned int i_b, const unsig
* Assuming we have 2 triangles sharing an edge (2 - 4),
* check if the edge running from (1 - 3) gives better results.
*
* \param lock_degenerate: Use to avoid rotating out of a degenerate state.
* - When true, an existing zero area face on either side of the (2 - 4) split will return a positive value.
* - When false, the check must be non-biased towards either split direction.
*
* \return (negative number means the edge can be rotated, lager == better).
*/
float BLI_polyfill_beautify_quad_rotate_calc_ex(
@ -129,8 +133,6 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex(
{
/* not a loop (only to be able to break out) */
do {
bool is_zero_a, is_zero_b;
const float area_2x_234 = cross_tri_v2(v2, v3, v4);
const float area_2x_241 = cross_tri_v2(v2, v4, v1);
@ -142,25 +144,27 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex(
(ELEM(v3, v1, v2, v4) == false) &&
(ELEM(v4, v1, v2, v3) == false));
if (lock_degenerate) {
is_zero_a = (fabsf(area_2x_234) <= FLT_EPSILON);
is_zero_b = (fabsf(area_2x_241) <= FLT_EPSILON);
/*
* Test for unusable (1-3) state.
* - Area sign flipping to check faces aren't going to point in opposite directions.
* - Area epsilon check that the one of the faces won't be zero area.
*/
if (((area_2x_123 >= 0.0f) != (area_2x_134 >= 0.0f)) ||
(fabsf(area_2x_123) <= FLT_EPSILON) || (fabsf(area_2x_134) <= FLT_EPSILON))
{
break;
}
if (is_zero_a && is_zero_b) {
/* Test for unusable (2-4) state (same as above). */
if (((area_2x_234 >= 0.0f) != (area_2x_241 >= 0.0f)) ||
((fabsf(area_2x_234) <= FLT_EPSILON) || (fabsf(area_2x_241) <= FLT_EPSILON)))
{
if (lock_degenerate) {
break;
}
}
/* one of the tri's was degenerate, check we're not rotating
* into a different degenerate shape or flipping the face */
if ((fabsf(area_2x_123) <= FLT_EPSILON) || (fabsf(area_2x_134) <= FLT_EPSILON)) {
/* one of the new rotations is degenerate */
break;
}
if ((area_2x_123 >= 0.0f) != (area_2x_134 >= 0.0f)) {
/* rotation would cause flipping */
break;
else {
return -FLT_MAX; /* always rotate */
}
}
{

View File

@ -32,7 +32,7 @@
#include "BLI_array.h"
#include "BLI_alloca.h"
#include "BLI_linklist_stack.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BLT_translation.h"

View File

@ -32,6 +32,7 @@
#include "BLI_math_vector.h"
#include "BLI_listbase.h"
#include "BLI_mempool.h"
#include "BLI_utildefines_iter.h"
#include "bmesh.h"
@ -707,29 +708,6 @@ void BM_edgeloop_expand(
split_swap = !split_swap;
}
/* TODO, move to generic define? */
/**
* Even value distribution.
*
* \a src must be larger than \a dst,
* \a dst defines the number of iterations, their values are evenly spaced.
*
* The following pairs represent (src, dst) arguments and the values they loop over.
* <pre>
* (19, 4) -> [2, 7, 11. 16]
* (100, 5) -> [9, 29, 49, 69, 89]
* (100, 3) -> [16, 49, 83]
* (100, 100) -> [0..99]
* </pre>
* \note this is mainly useful for numbers that might not divide evenly into eachother.
*/
#define BLI_FOREACH_SPARSE_RANGE(src, dst, i) \
for (int _src = (src), _src2 = _src * 2, _dst2 = (dst) * 2, _error = _dst2 - _src, i = 0, _delta; \
((void)(_delta = divide_floor_i(_error, _dst2)), \
(void)(i -= _delta), \
(i < _src)); \
_error -= (_delta * _dst2) + _src2)
if (el_store->len < el_store_len) {
LinkData *node_curr = el_store->verts.first;

View File

@ -1523,7 +1523,7 @@ void BM_mesh_calc_tessellation_beauty(BMesh *bm, BMLoop *(*looptris)[3], int *r_
* Use #BLI_polyfill_beautify_quad_rotate_calc since we have the normal.
*/
#if 0
const bool split_24 = (BM_verts_calc_rotate_beauty(
const bool split_13 = (BM_verts_calc_rotate_beauty(
l_v1->v, l_v2->v, l_v3->v, l_v4->v, 0, 0) < 0.0f);
#else
float axis_mat[3][3], v_quad[4][2];
@ -1533,13 +1533,13 @@ void BM_mesh_calc_tessellation_beauty(BMesh *bm, BMLoop *(*looptris)[3], int *r_
mul_v2_m3v3(v_quad[2], axis_mat, l_v3->v->co);
mul_v2_m3v3(v_quad[3], axis_mat, l_v4->v->co);
const bool split_24 = BLI_polyfill_beautify_quad_rotate_calc(
const bool split_13 = BLI_polyfill_beautify_quad_rotate_calc(
v_quad[0], v_quad[1], v_quad[2], v_quad[3]) < 0.0f;
#endif
BMLoop **l_ptr_a = looptris[i++];
BMLoop **l_ptr_b = looptris[i++];
if (split_24 == 0) {
if (split_13) {
l_ptr_a[0] = l_v1;
l_ptr_a[1] = l_v2;
l_ptr_a[2] = l_v3;

View File

@ -32,7 +32,7 @@
#include "BLI_memarena.h"
#include "BLI_array.h"
#include "BLI_alloca.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BLI_linklist_stack.h"
#include "BLI_sort.h"
#include "BLI_sort_utils.h"

View File

@ -36,7 +36,7 @@
#include "BLI_math.h"
#include "BLI_alloca.h"
#include "BLI_linklist.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BKE_customdata.h"

View File

@ -29,7 +29,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BLI_math.h"
#include "bmesh.h"

View File

@ -27,7 +27,7 @@
*/
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BLI_alloca.h"
#include "BLI_linklist_stack.h"

View File

@ -33,7 +33,7 @@
#include "BLI_math.h"
#include "BLI_alloca.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BKE_customdata.h"

View File

@ -31,7 +31,7 @@
#include "BLI_math.h"
#include "BLI_alloca.h"
#include "BLI_kdtree.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BLI_stack.h"
#include "BKE_customdata.h"

View File

@ -40,7 +40,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BLI_alloca.h"
#include "BLI_math.h"
#include "BLI_listbase.h"

View File

@ -38,7 +38,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BLI_alloca.h"
#include "BLI_linklist.h"
#include "BLI_linklist_stack.h"

View File

@ -40,7 +40,7 @@
#include "BLI_edgehash.h"
#include "BLI_polyfill2d.h"
#include "BLI_polyfill2d_beautify.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BKE_customdata.h"

View File

@ -44,7 +44,7 @@
#include "BLI_sort_utils.h"
#include "BLI_linklist_stack.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#ifndef NDEBUG
# include "BLI_array_utils.h"
#endif

View File

@ -29,7 +29,7 @@
#include "BLI_math.h"
#include "BLI_linklist.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BLI_alloca.h"
#include "bmesh.h"

View File

@ -230,8 +230,8 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph)
}
}
id_node->done = COMPONENT_STATE_DONE;
comp_node->done = 1;
id_node->done = 1;
comp_node->done = COMPONENT_STATE_DONE;
/* Flush to nodes along links... */
/* TODO(sergey): This is mainly giving speedup due ot less queue pushes, which

View File

@ -1013,7 +1013,7 @@ void uiItemsFullEnumO(
struct IDProperty *properties, int context, int flag);
void uiItemsFullEnumO_items(
uiLayout *layout, struct wmOperatorType *ot, PointerRNA ptr, PropertyRNA *prop,
IDProperty *properties, int context, int flag,
struct IDProperty *properties, int context, int flag,
const EnumPropertyItem *item_array, int totitem);
void uiItemL(uiLayout *layout, const char *name, int icon); /* label */

View File

@ -489,6 +489,9 @@ static int ui_but_calc_float_precision(uiBut *but, double value)
else if (prec == -1) {
prec = (but->hardmax < 10.001f) ? 3 : 2;
}
else {
CLAMP(prec, 0, UI_PRECISION_FLOAT_MAX);
}
return UI_calc_float_precision(prec, value);
}

View File

@ -150,6 +150,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
for (i = 0; i < NUM_VALUE_KINDS; i++) {
opdata->shift_value[i] = -1.0f;
opdata->initial_length[i] = -1.0f;
/* note: scale for OFFSET_VALUE will get overwritten in edbm_bevel_invoke */
opdata->scale[i] = value_scale_per_inch[i] / pixels_per_inch;
@ -300,7 +301,7 @@ static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event,
mlen[1] = opdata->mcenter[1] - event->mval[1];
len = len_v2(mlen);
vmode = opdata->value_mode;
if (mode_changed) {
if (mode_changed || opdata->initial_length[vmode] == -1.0f) {
/* If current value is not default start value, adjust len so that
* the scaling and offset in edbm_bevel_mouse_set_value will
* start at current value */
@ -506,6 +507,8 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT)
opdata->value_mode = OFFSET_VALUE;
RNA_property_enum_set(op->ptr, prop, type);
if (opdata->initial_length[opdata->value_mode] == -1.0f)
edbm_bevel_calc_initial_length(op, event, true);
}
/* Update offset accordingly to new offset_type. */
if (!has_numinput &&

View File

@ -50,7 +50,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_linklist_stack.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BKE_context.h"

View File

@ -52,7 +52,7 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_ghash.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BLI_memarena.h"
#include "BKE_nla.h"

View File

@ -654,7 +654,8 @@ typedef struct BooleanModifierData {
struct Object *object;
char operation;
char solver;
char pad[2];
char pad;
char bm_flag;
float double_threshold;
} BooleanModifierData;
@ -669,6 +670,13 @@ typedef enum {
eBooleanModifierSolver_BMesh = 1,
} BooleanSolver;
/* bm_flag (only used when G_DEBUG) */
enum {
eBooleanModifierBMeshFlag_BMesh_Separate = (1 << 0),
eBooleanModifierBMeshFlag_BMesh_NoDissolve = (1 << 1),
eBooleanModifierBMeshFlag_BMesh_NoConnectRegions = (1 << 2),
};
typedef struct MDefInfluence {
int vertex;
float weight;

View File

@ -44,6 +44,8 @@
#include "BLT_translation.h"
#include "UI_interface.h" /* For things like UI_PRECISION_FLOAT_MAX... */
#include "RNA_define.h"
#include "rna_internal.h"
@ -1405,13 +1407,13 @@ void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, bool consecutive)
* For ints, whole values are used.
*
* \param precision The number of zeros to show
* (as a whole number - common range is 1 - 6), see PRECISION_FLOAT_MAX
* (as a whole number - common range is 1 - 6), see UI_PRECISION_FLOAT_MAX
*/
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
{
StructRNA *srna = DefRNA.laststruct;
#ifdef DEBUG
#ifndef NDEBUG
if (min > max) {
fprintf(stderr, "%s: \"%s.%s\", min > max.\n",
__func__, srna->identifier, prop->identifier);
@ -1424,8 +1426,8 @@ void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double
DefRNA.error = 1;
}
if (precision < -1 || precision > 10) {
fprintf(stderr, "%s: \"%s.%s\", step outside range.\n",
if (precision < -1 || precision > UI_PRECISION_FLOAT_MAX) {
fprintf(stderr, "%s: \"%s.%s\", precision outside range.\n",
__func__, srna->identifier, prop->identifier);
DefRNA.error = 1;
}
@ -1447,21 +1449,6 @@ void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double
fprop->softmax = (float)max;
fprop->step = (float)step;
fprop->precision = (int)precision;
#if 0 /* handy but annoying */
if (DefRNA.preprocess) {
/* check we're not over PRECISION_FLOAT_MAX */
if (fprop->precision > 6) {
fprintf(stderr, "%s: \"%s.%s\", precision value over maximum.\n",
__func__, srna->identifier, prop->identifier);
DefRNA.error = 1;
}
else if (fprop->precision < 1) {
fprintf(stderr, "%s: \"%s.%s\", precision value under minimum.\n",
__func__, srna->identifier, prop->identifier);
DefRNA.error = 1;
}
}
#endif
break;
}
default:

View File

@ -1976,9 +1976,26 @@ static void rna_def_modifier_boolean(BlenderRNA *brna)
prop = RNA_def_property(srna, "double_threshold", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "double_threshold");
RNA_def_property_range(prop, 0, 1.0f);
RNA_def_property_ui_range(prop, 0, 1, 0.0001, 7);
RNA_def_property_ui_range(prop, 0, 1, 0.0001, 6);
RNA_def_property_ui_text(prop, "Overlap Threshold", "Threshold for checking overlapping geometry");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
/* BMesh debugging options, only used when G_DEBUG is set */
/* BMesh intersection options */
static EnumPropertyItem debug_items[] = {
{eBooleanModifierBMeshFlag_BMesh_Separate, "SEPARATE", 0, "Separate", ""},
{eBooleanModifierBMeshFlag_BMesh_NoDissolve, "NO_DISSOLVE", 0, "NoDissolve", ""},
{eBooleanModifierBMeshFlag_BMesh_NoConnectRegions, "NO_CONNECT_REGIONS", 0, "NoConnectRegions", ""},
{0, NULL, 0, NULL, NULL}
};
prop = RNA_def_property(srna, "debug_options", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, debug_items);
RNA_def_property_enum_sdna(prop, NULL, "bm_flag");
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Debug", "Debugging options, only when started with '-d'");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
static void rna_def_modifier_array(BlenderRNA *brna)

View File

@ -57,6 +57,7 @@
#include "BLI_alloca.h"
#include "BLI_math_geom.h"
#include "BKE_material.h"
#include "BKE_global.h" /* only to check G.debug */
#include "MEM_guardedalloc.h"
#include "bmesh.h"
@ -304,11 +305,17 @@ static DerivedMesh *applyModifier_bmesh(
* currently this is ok for 'BM_mesh_intersect' */
// BM_mesh_normals_update(bm);
/* change for testing */
bool use_separate = false;
bool use_dissolve = true;
bool use_island_connect = true;
/* change for testing */
if (G.debug & G_DEBUG) {
use_separate = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_Separate) != 0;
use_dissolve = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_NoDissolve) == 0;
use_island_connect = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_NoConnectRegions) == 0;
}
BM_mesh_intersect(
bm,
looptris, tottri,

View File

@ -29,7 +29,7 @@
*/
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BLI_math.h"
#include "BLI_string.h"

View File

@ -36,7 +36,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
#include "BLI_bitmap.h"
#include "BLI_math.h"

View File

@ -28,7 +28,7 @@
#define __PY_CAPI_UTILS_H__
#include "BLI_sys_types.h"
#include "BLI_variadic_defines.h"
#include "BLI_utildefines_variadic.h"
void PyC_ObSpit(const char *name, PyObject *var);
void PyC_LineSpit(void);

View File

@ -5,7 +5,7 @@
extern "C" {
#include "BLI_utildefines.h"
#include "BLI_array_utils.h"
#include "BLI_stackdefines.h"
#include "BLI_utildefines_stack.h"
}
/* -------------------------------------------------------------------- */