Merging changes from trunk r58091-58323.

This commit is contained in:
Mitchell Stokes 2013-07-17 01:40:26 +00:00
commit eb21bdd249
233 changed files with 2319 additions and 1235 deletions

@ -2040,6 +2040,20 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNDEF -Wno-undef)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn)
ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field)
ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing)
ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor)
ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_REORDER -Wno-reorder)
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)

@ -2,9 +2,11 @@
# Find the native Python includes and library
#
# Note:, This is not _yet_ intended to be a general python module for other
# projects to use since its hard coded to python 3.2 as blender only supports
# a single python version.
# This is for blender/unix python only.
# projects to use since its hard coded to fixed Python version
# as Blender only supports a single Python version at the moment.
#
# Note:
# this is for Blender/Unix Python only.
#
# This module defines
# PYTHON_VERSION

@ -530,7 +530,9 @@ macro(remove_strict_flags_file
foreach(_SOURCE ${ARGV})
if(CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_COMPILER_IS_GNUCC OR
(CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set_source_files_properties(${_SOURCE}
PROPERTIES
COMPILE_FLAGS "${CC_REMOVE_STRICT_FLAGS}"

@ -1,3 +1,25 @@
/* ***** BEGIN GPL LICENSE BLOCK *****
*
* Copyright 2008 Peter Schlaile
*
* This file is part of libredcode.
*
* Libredcode 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.
*
* Libredcode 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 libredcode; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****/
#include "codec.h"
#include "format.h"
#include "debayer.h"

@ -1,3 +1,25 @@
/* ***** BEGIN GPL LICENSE BLOCK *****
*
* Copyright 2008 Peter Schlaile
*
* This file is part of libredcode.
*
* Libredcode 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.
*
* Libredcode 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 Libredcode; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****/
#ifndef __CODEC_H__
#define __CODEC_H__

@ -1,3 +1,25 @@
/* ***** BEGIN GPL LICENSE BLOCK *****
*
* Copyright 2008 Peter Schlaile
*
* This file is part of libredcode.
*
* Libredcode 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.
*
* Libredcode 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 Libredcode; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****/
#include "debayer.h"
/* pretty simple but astonishingly very effective "debayer" function

@ -1,3 +1,25 @@
/* ***** BEGIN GPL LICENSE BLOCK *****
*
* Copyright 2008 Peter Schlaile
*
* This file is part of libredcode.
*
* Libredcode 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.
*
* Libredcode 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 Libredcode; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****/
#ifndef __DEBAYER_H__
#define __DEBAYER_H__

@ -1,3 +1,25 @@
/* ***** BEGIN GPL LICENSE BLOCK *****
*
* Copyright 2008 Peter Schlaile
*
* This file is part of libredcode.
*
* Libredcode 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.
*
* Libredcode 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 Libredcode; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

@ -1,3 +1,25 @@
/* ***** BEGIN GPL LICENSE BLOCK *****
*
* Copyright 2008 Peter Schlaile
*
* This file is part of libredcode.
*
* Libredcode 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.
*
* Libredcode 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 Libredcode; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****/
#ifndef __FORMAT_H__
#define __FORMAT_H__

@ -28,10 +28,10 @@ set(INC
../container
../guardedalloc
../memutil
../moto/include
)
set(INC_SYS
../moto/include
../../extern/carve/include
)

@ -41,6 +41,7 @@ class CyclesRender(bpy.types.RenderEngine):
bl_use_shading_nodes = True
bl_use_preview = True
bl_use_exclude_layers = True
bl_use_save_buffers = True
def __init__(self):
self.session = None

@ -213,21 +213,23 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
subsub.enabled = not rd.use_border
subsub.prop(rd, "use_save_buffers")
col = split.column()
col = split.column(align=True)
sub = col.column(align=True)
sub.label(text="Acceleration structure:")
sub.prop(cscene, "debug_bvh_type", text="")
sub.prop(cscene, "debug_use_spatial_splits")
sub.prop(cscene, "use_cache")
col.label(text="Viewport:")
col.prop(cscene, "debug_bvh_type", text="")
col.separator()
col.prop(cscene, "preview_start_resolution")
sub = col.column(align=True)
sub.label(text="Viewport:")
sub.prop(cscene, "preview_start_resolution")
col.separator()
sub = col.column(align=True)
sub.label(text="Final Render:")
sub.prop(rd, "use_persistent_data", text="Persistent Images")
col.label(text="Final Render:")
col.prop(cscene, "use_cache")
col.prop(rd, "use_persistent_data", text="Persistent Images")
col.separator()
col.label(text="Acceleration structure:")
col.prop(cscene, "debug_use_spatial_splits")
class CyclesRender_PT_opengl(CyclesButtonsPanel, Panel):

@ -212,13 +212,27 @@ static void mikk_compute_tangents(BL::Mesh b_mesh, BL::MeshTextureFaceLayer b_la
static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<uint>& used_shaders)
{
/* create vertices */
/* count vertices and faces */
int numverts = b_mesh.vertices.length();
int numfaces = b_mesh.tessfaces.length();
int numtris = 0;
BL::Mesh::vertices_iterator v;
BL::Mesh::tessfaces_iterator f;
for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v)
mesh->verts.push_back(get_float3(v->co()));
for(b_mesh.tessfaces.begin(f); f != b_mesh.tessfaces.end(); ++f) {
int4 vi = get_int4(f->vertices_raw());
numtris += (vi[3] == 0)? 1: 2;
}
/* reserve memory */
mesh->reserve(numverts, numtris, 0, 0);
/* create vertex coordinates and normals */
int i = 0;
for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v, ++i)
mesh->verts[i] = get_float3(v->co());
/* create vertex normals */
Attribute *attr_N = mesh->attributes.add(ATTR_STD_VERTEX_NORMAL);
float3 *N = attr_N->data_float3();
@ -226,10 +240,10 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
*N = get_float3(v->normal());
/* create faces */
BL::Mesh::tessfaces_iterator f;
vector<int> nverts;
vector<int> nverts(numfaces);
int fi = 0, ti = 0;
for(b_mesh.tessfaces.begin(f); f != b_mesh.tessfaces.end(); ++f) {
for(b_mesh.tessfaces.begin(f); f != b_mesh.tessfaces.end(); ++f, ++fi) {
int4 vi = get_int4(f->vertices_raw());
int n = (vi[3] == 0)? 3: 4;
int mi = clamp(f->material_index(), 0, used_shaders.size()-1);
@ -239,18 +253,18 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
if(n == 4) {
if(len_squared(cross(mesh->verts[vi[1]] - mesh->verts[vi[0]], mesh->verts[vi[2]] - mesh->verts[vi[0]])) == 0.0f ||
len_squared(cross(mesh->verts[vi[2]] - mesh->verts[vi[0]], mesh->verts[vi[3]] - mesh->verts[vi[0]])) == 0.0f) {
mesh->add_triangle(vi[0], vi[1], vi[3], shader, smooth);
mesh->add_triangle(vi[2], vi[3], vi[1], shader, smooth);
mesh->set_triangle(ti++, vi[0], vi[1], vi[3], shader, smooth);
mesh->set_triangle(ti++, vi[2], vi[3], vi[1], shader, smooth);
}
else {
mesh->add_triangle(vi[0], vi[1], vi[2], shader, smooth);
mesh->add_triangle(vi[0], vi[2], vi[3], shader, smooth);
mesh->set_triangle(ti++, vi[0], vi[1], vi[2], shader, smooth);
mesh->set_triangle(ti++, vi[0], vi[2], vi[3], shader, smooth);
}
}
else
mesh->add_triangle(vi[0], vi[1], vi[2], shader, smooth);
mesh->set_triangle(ti++, vi[0], vi[1], vi[2], shader, smooth);
nverts.push_back(n);
nverts[fi] = n;
}
/* create vertex color attributes */

@ -127,6 +127,7 @@ private:
use_surfaces(true),
use_hair(true),
use_viewport_visibility(false),
use_localview(false),
samples(0), bound_samples(false)
{}

@ -166,6 +166,12 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra
ray->D = panorama_to_direction(kg, Pcamera.x, Pcamera.y);
/* indicates ray should not receive any light, outside of the lens */
if(is_zero(ray->D)) {
ray->t = 0.0f;
return;
}
/* modify ray for depth of field */
float aperturesize = kernel_data.cam.aperturesize;
@ -186,12 +192,6 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra
ray->D = normalize(Pfocus - ray->P);
}
/* indicates ray should not receive any light, outside of the lens */
if(is_zero(ray->D)) {
ray->t = 0.0f;
return;
}
/* transform ray from camera to world */
Transform cameratoworld = kernel_data.cam.cameratoworld;

@ -359,12 +359,15 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
case PASS_BACKGROUND:
kfilm->pass_background = kfilm->pass_stride;
kfilm->use_light_pass = 1;
break;
case PASS_AO:
kfilm->pass_ao = kfilm->pass_stride;
kfilm->use_light_pass = 1;
break;
case PASS_SHADOW:
kfilm->pass_shadow = kfilm->pass_stride;
kfilm->use_light_pass = 1;
break;
case PASS_NONE:
break;
}

@ -347,8 +347,9 @@ void ShaderGraph::remove_unneeded_nodes()
if(tonode->special_type == SHADER_SPECIAL_TYPE_AUTOCONVERT) {
bool all_links_removed = true;
vector<ShaderInput*> links = tonode->outputs[0]->links;
foreach(ShaderInput *autoin, tonode->outputs[0]->links) {
foreach(ShaderInput *autoin, links) {
if(autoin->default_value == ShaderInput::NONE)
all_links_removed = false;
else

@ -53,7 +53,7 @@ static void shade_background_pixels(Device *device, DeviceScene *dscene, int res
}
/* compute on device */
float4 *d_output_data = d_output.resize(width*height);
d_output.resize(width*height);
memset((void*)d_output.data_pointer, 0, d_output.memory_size());
device->const_copy_to("__data", &dscene->data, sizeof(dscene->data));
@ -82,7 +82,7 @@ static void shade_background_pixels(Device *device, DeviceScene *dscene, int res
device->mem_free(d_input);
device->mem_free(d_output);
d_output_data = reinterpret_cast<float4*>(d_output.data_pointer);
float4 *d_output_data = reinterpret_cast<float4*>(d_output.data_pointer);
pixels.resize(width*height);

@ -98,6 +98,18 @@ void Mesh::clear()
transform_normal = transform_identity();
}
void Mesh::set_triangle(int i, int v0, int v1, int v2, int shader_, bool smooth_)
{
Triangle tri;
tri.v[0] = v0;
tri.v[1] = v1;
tri.v[2] = v2;
triangles[i] = tri;
shader[i] = shader_;
smooth[i] = smooth_;
}
void Mesh::add_triangle(int v0, int v1, int v2, int shader_, bool smooth_)
{
Triangle tri;

@ -110,6 +110,7 @@ public:
void reserve(int numverts, int numfaces, int numcurves, int numcurvekeys);
void clear();
void set_triangle(int i, int v0, int v1, int v2, int shader, bool smooth);
void add_triangle(int v0, int v1, int v2, int shader, bool smooth);
void add_curve_key(float3 loc, float radius);
void add_curve(int first_key, int num_keys, int shader);

@ -99,7 +99,7 @@ void LookupTables::remove_table(size_t offset)
for(table = lookup_tables.begin(); table != lookup_tables.end(); table++) {
if(table->offset == offset) {
lookup_tables.erase(table);
break;
return;
}
}

@ -152,6 +152,10 @@ private:
GHOST_SystemWin32 *m_system;
/* Data type of the dragged object */
GHOST_TDragnDropTypes m_draggedObjectType;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_DropTargetWin32")
#endif
};
#endif // __GHOST_DROPTARGETWIN32_H__

@ -84,6 +84,9 @@ void GHOST_DropTargetX11::Initialize(void)
void GHOST_DropTargetX11::Uninitialize(void)
{
xdnd_shut(&m_dndClass);
delete[] m_dndActions;
delete[] m_dndTypes;
}
GHOST_DropTargetX11::GHOST_DropTargetX11(GHOST_WindowX11 *window, GHOST_SystemX11 *system)

@ -130,6 +130,10 @@ private:
/* counter of references to global XDND structures */
static int m_refCounter;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_DropTargetX11")
#endif
};
#endif // __GHOST_DROPTARGETX11_H__

@ -26,11 +26,10 @@
set(INC
intern
../memutil
../moto/include
)
set(INC_SYS
../moto/include
)
set(SRC

@ -95,7 +95,7 @@ endif()
if(WITH_FFTW3)
add_definitions(-DWITH_FFTW3)
list(APPEND INC
list(APPEND INC_SYS
${FFTW3_INCLUDE_DIRS}
)
endif()

@ -40,6 +40,7 @@ class SpellChecker():
"derivate",
"doesn", # doesn't
"fader",
"globbing",
"hasn", # hasn't
"hoc", # ad-hoc
"indices",
@ -59,6 +60,7 @@ class SpellChecker():
"autoclip",
"autocomplete",
"autoexec",
"autoexecution",
"autoname",
"autosave",
"autoscale",

@ -87,7 +87,7 @@ void blf_font_size(FontBLF *font, unsigned int size, unsigned int dpi)
err = FT_Set_Char_Size(font->face, 0, (FT_F26Dot6)(size * 64), dpi, dpi);
if (err) {
/* FIXME: here we can go through the fixed size and choice a close one */
printf("The current font don't support the size, %d and dpi, %d\n", size, dpi);
printf("The current font don't support the size, %u and dpi, %u\n", size, dpi);
return;
}

@ -323,6 +323,7 @@ struct DerivedMesh {
/** Get smooth vertex normal, undefined if index is not valid */
void (*getVertNo)(DerivedMesh *dm, int index, float no_r[3]);
void (*getPolyNo)(DerivedMesh *dm, int index, float no_r[3]);
/** Get a map of vertices to faces
*/

@ -29,6 +29,7 @@
struct bContext;
struct wmOperator;
struct Scene;
/* Actual surface point */
typedef struct PaintSurfaceData {
@ -69,8 +70,8 @@ void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct Dyn
int dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, struct Scene *scene);
struct DynamicPaintSurface *dynamicPaint_createNewSurface(struct DynamicPaintCanvasSettings *canvas, struct Scene *scene);
void dynamicPaint_clearSurface(struct DynamicPaintSurface *surface);
int dynamicPaint_resetSurface(struct DynamicPaintSurface *surface);
void dynamicPaint_clearSurface(struct Scene *scene, struct DynamicPaintSurface *surface);
int dynamicPaint_resetSurface(struct Scene *scene, struct DynamicPaintSurface *surface);
void dynamicPaint_freeSurface(struct DynamicPaintSurface *surface);
void dynamicPaint_freeCanvas(struct DynamicPaintModifierData *pmd);
void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd);
@ -85,7 +86,7 @@ void dynamicPaint_resetPreview(struct DynamicPaintCanvasSettings *canvas);
struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings *canvas);
/* image sequence baking */
int dynamicPaint_createUVSurface(struct DynamicPaintSurface *surface);
int dynamicPaint_createUVSurface(struct Scene *scene, struct DynamicPaintSurface *surface);
int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, struct Scene *scene, struct Object *cObject, int frame);
void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface, char *filename, short output_layer);

@ -209,6 +209,7 @@ const char *BKE_mesh_cmp(struct Mesh *me1, struct Mesh *me2, float thresh);
struct BoundBox *BKE_mesh_boundbox_get(struct Object *ob);
void BKE_mesh_texspace_get(struct Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]);
void BKE_mesh_texspace_copy_from_object(struct Mesh *me, struct Object *ob);
/* if old, it converts mface->edcode to edge drawflags */
void BKE_mesh_make_edges(struct Mesh *me, const bool use_old);

@ -95,15 +95,16 @@ void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], bool use_compat)
void BKE_object_to_mat3(struct Object *ob, float mat[3][3]);
void BKE_object_to_mat4(struct Object *ob, float mat[4][4]);
void BKE_object_apply_mat4(struct Object *ob, float mat[4][4], const bool use_compat, const bool use_parent);
void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]);
bool BKE_object_pose_context_check(struct Object *ob);
struct Object *BKE_object_pose_armature_get(struct Object *ob);
void BKE_object_where_is_calc(struct Scene *scene, struct Object *ob);
void BKE_object_where_is_calc_ex(struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob);
void BKE_object_where_is_calc_ex(struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob, float r_originmat[3][3]);
void BKE_object_where_is_calc_time(struct Scene *scene, struct Object *ob, float ctime);
void BKE_object_where_is_calc_time_ex(struct Scene *scene, struct Object *ob, float ctime,
struct RigidBodyWorld *rbw);
struct RigidBodyWorld *rbw, float r_originmat[3][3]);
void BKE_object_where_is_calc_simul(struct Scene *scene, struct Object *ob);
void BKE_object_where_is_calc_mat4(struct Scene *scene, struct Object *ob, float obmat[4][4]);

@ -75,7 +75,17 @@ struct Base *BKE_scene_base_add(struct Scene *sce, struct Object *ob);
void BKE_scene_base_unlink(struct Scene *sce, struct Base *base);
void BKE_scene_base_deselect_all(struct Scene *sce);
void BKE_scene_base_select(struct Scene *sce, struct Base *selbase);
int BKE_scene_base_iter_next(struct Scene **scene, int val, struct Base **base, struct Object **ob);
/* Scene base iteration function.
* Define struct here, so no need to bother with alloc/free it.
*/
typedef struct SceneBaseIter {
struct ListBase *duplilist;
struct DupliObject *dupob;
int fase;
} SceneBaseIter;
int BKE_scene_base_iter_next(struct SceneBaseIter *iter, struct Scene **scene, int val, struct Base **base, struct Object **ob);
void BKE_scene_base_flag_to_objects(struct Scene *scene);
void BKE_scene_base_flag_from_objects(struct Scene *scene);

@ -334,7 +334,7 @@ typedef struct SeqLoadInfo {
int tot_success;
int tot_error;
int len; /* only for image strips */
char path[512];
char path[1024]; /* 1024 = FILE_MAX */
char name[64];
} SeqLoadInfo;

@ -484,8 +484,6 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask)
Mesh tmp = *me;
int totvert, totedge /*, totface */ /* UNUSED */, totloop, totpoly;
int did_shapekeys = 0;
float *texloc, *texrot, *texsize;
short *texflag;
CustomData_reset(&tmp.vdata);
CustomData_reset(&tmp.edata);
@ -533,12 +531,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask)
}
/* copy texture space */
if (BKE_object_obdata_texspace_get(ob, &texflag, &texloc, &texsize, &texrot)) {
tmp.texflag = *texflag;
copy_v3_v3(tmp.loc, texloc);
copy_v3_v3(tmp.size, texsize);
copy_v3_v3(tmp.rot, texrot);
}
BKE_mesh_texspace_copy_from_object(&tmp, ob);
/* not all DerivedMeshes store their verts/edges/faces in CustomData, so
* we set them here in case they are missing */
@ -655,21 +648,25 @@ void DM_add_poly_layer(DerivedMesh *dm, int type, int alloctype, void *layer)
void *DM_get_vert_data(DerivedMesh *dm, int index, int type)
{
BLI_assert(index >= 0 && index < dm->getNumVerts(dm));
return CustomData_get(&dm->vertData, index, type);
}
void *DM_get_edge_data(DerivedMesh *dm, int index, int type)
{
BLI_assert(index >= 0 && index < dm->getNumEdges(dm));
return CustomData_get(&dm->edgeData, index, type);
}
void *DM_get_tessface_data(DerivedMesh *dm, int index, int type)
{
BLI_assert(index >= 0 && index < dm->getNumTessFaces(dm));
return CustomData_get(&dm->faceData, index, type);
}
void *DM_get_poly_data(DerivedMesh *dm, int index, int type)
{
BLI_assert(index >= 0 && index < dm->getNumPolys(dm));
return CustomData_get(&dm->polyData, index, type);
}

@ -981,6 +981,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
rule = BLI_findlink(&state->rules, rand % BLI_countlist(&state->rules));
apply_boid_rule(bbd, rule, &val, pa, -1.0);
break;
}
case eBoidRulesetType_Average:
{

@ -539,7 +539,7 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
else if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) {
float rotation = -mtex->rot;
float point_2d[2] = {point[0], point[1]};
float x = 0.0f, y = 0.0f; /* Quite warnings */
float x, y;
float co[3];
x = point_2d[0] - br->stencil_pos[0];
@ -658,7 +658,7 @@ float BKE_brush_sample_masktex(const Scene *scene, Brush *br,
if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) {
float rotation = -mtex->rot;
float point_2d[2] = {point[0], point[1]};
float x = 0.0f, y = 0.0f; /* Quite warnings */
float x, y;
float co[3];
x = point_2d[0] - br->mask_stencil_pos[0];
@ -993,7 +993,8 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side)
co[2] = 0.0f;
/* This is copied from displace modifier code */
hasrgb = multitex_ext(mtex->tex, co, NULL, NULL, 0, &texres, NULL);
/* TODO(sergey): brush are always cacheing with CM enabled for now. */
hasrgb = multitex_ext(mtex->tex, co, NULL, NULL, 0, &texres, NULL, true);
/* if the texture gave an RGB value, we assume it didn't give a valid
* intensity, so calculate one (formula from do_material_tex).

@ -2519,7 +2519,7 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* only evaluate if there is a target */
if (VALID_CONS_TARGET(ct)) {
float dvec[3], dist = 0.0f, sfac = 1.0f;
float dvec[3], dist, sfac = 1.0f;
short clamp_surf = 0;
/* calculate our current distance from the target */

@ -1729,16 +1729,19 @@ bool CustomData_free_layer(CustomData *data, int type, int totelem, int index)
data->totlayer--;
/* if layer was last of type in array, set new active layer */
if ((index >= data->totlayer) || (data->layers[index].type != type)) {
i = CustomData_get_layer_index__notypemap(data, type);
if (i >= 0)
for (; i < data->totlayer && data->layers[i].type == type; i++) {
data->layers[i].active--;
data->layers[i].active_rnd--;
data->layers[i].active_clone--;
data->layers[i].active_mask--;
}
i = CustomData_get_layer_index__notypemap(data, type);
if (i != -1) {
/* don't decrement zero index */
const int index_nonzero = index ? index : 1;
CustomDataLayer *layer;
for (layer = &data->layers[i]; i < data->totlayer && layer->type == type; i++, layer++) {
if (layer->active >= index_nonzero) layer->active--;
if (layer->active_rnd >= index_nonzero) layer->active_rnd--;
if (layer->active_clone >= index_nonzero) layer->active_clone--;
if (layer->active_mask >= index_nonzero) layer->active_mask--;
}
}
if (data->totlayer <= data->maxlayer - CUSTOMDATA_GROW)
@ -2073,6 +2076,8 @@ void *CustomData_get(const CustomData *data, int index, int type)
int offset;
int layer_index;
BLI_assert(index >= 0);
/* get the layer index of the active layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
if (layer_index < 0) return NULL;
@ -2088,6 +2093,8 @@ void *CustomData_get_n(const CustomData *data, int type, int index, int n)
int layer_index;
int offset;
BLI_assert(index >= 0 && n >= 0);
/* get the layer index of the first layer of type */
layer_index = data->typemap[type];
if (layer_index < 0) return NULL;

@ -1449,12 +1449,13 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
MEM_freeN(temp_data);
}
static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
static void dynamicPaint_setInitialColor(Scene *scene, DynamicPaintSurface *surface)
{
PaintSurfaceData *sData = surface->data;
PaintPoint *pPoint = (PaintPoint *)sData->type_data;
DerivedMesh *dm = surface->canvas->dm;
int i;
bool scene_color_manage = BKE_scene_check_color_management_enabled(scene);
if (surface->type != MOD_DPAINT_SURFACE_T_PAINT)
return;
@ -1503,7 +1504,7 @@ static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
uv[0] = tface[i].uv[j][0] * 2.0f - 1.0f;
uv[1] = tface[i].uv[j][1] * 2.0f - 1.0f;
multitex_ext_safe(tex, uv, &texres, pool);
multitex_ext_safe(tex, uv, &texres, pool, scene_color_manage);
if (texres.tin > pPoint[*vert].alpha) {
copy_v3_v3(pPoint[*vert].color, &texres.tr);
@ -1536,8 +1537,8 @@ static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
/* remap to -1.0 to 1.0 */
uv_final[0] = uv_final[0] * 2.0f - 1.0f;
uv_final[1] = uv_final[1] * 2.0f - 1.0f;
multitex_ext_safe(tex, uv_final, &texres, NULL);
multitex_ext_safe(tex, uv_final, &texres, NULL, scene_color_manage);
/* apply color */
copy_v3_v3(pPoint[i].color, &texres.tr);
@ -1596,7 +1597,7 @@ static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
}
/* clears surface data back to zero */
void dynamicPaint_clearSurface(DynamicPaintSurface *surface)
void dynamicPaint_clearSurface(Scene *scene, DynamicPaintSurface *surface)
{
PaintSurfaceData *sData = surface->data;
if (sData && sData->type_data) {
@ -1613,7 +1614,7 @@ void dynamicPaint_clearSurface(DynamicPaintSurface *surface)
/* set initial color */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
dynamicPaint_setInitialColor(surface);
dynamicPaint_setInitialColor(scene, surface);
if (sData->bData)
sData->bData->clear = 1;
@ -1621,7 +1622,7 @@ void dynamicPaint_clearSurface(DynamicPaintSurface *surface)
}
/* completely (re)initializes surface (only for point cache types)*/
int dynamicPaint_resetSurface(DynamicPaintSurface *surface)
int dynamicPaint_resetSurface(Scene *scene, DynamicPaintSurface *surface)
{
int numOfPoints = dynamicPaint_surfaceNumOfPoints(surface);
/* free existing data */
@ -1642,16 +1643,16 @@ int dynamicPaint_resetSurface(DynamicPaintSurface *surface)
/* set initial color */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
dynamicPaint_setInitialColor(surface);
dynamicPaint_setInitialColor(scene, surface);
return 1;
}
/* make sure allocated surface size matches current requirements */
static int dynamicPaint_checkSurfaceData(DynamicPaintSurface *surface)
static int dynamicPaint_checkSurfaceData(Scene *scene, DynamicPaintSurface *surface)
{
if (!surface->data || ((dynamicPaint_surfaceNumOfPoints(surface) != surface->data->total_points))) {
return dynamicPaint_resetSurface(surface);
return dynamicPaint_resetSurface(scene, surface);
}
return 1;
}
@ -1942,6 +1943,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
/* loop through surfaces */
for (; surface; surface = surface->next) {
int current_frame = (int)scene->r.cfra;
bool no_surface_data;
/* free bake data if not required anymore */
surface_freeUnusedData(surface);
@ -1951,12 +1953,13 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
if (!(surface->flags & MOD_DPAINT_ACTIVE)) continue;
/* make sure surface is valid */
if (!dynamicPaint_checkSurfaceData(surface)) continue;
no_surface_data = surface->data == NULL;
if (!dynamicPaint_checkSurfaceData(scene, surface)) continue;
/* limit frame range */
CLAMP(current_frame, surface->start_frame, surface->end_frame);
if (current_frame != surface->current_frame || (int)scene->r.cfra == surface->start_frame) {
if (no_surface_data || current_frame != surface->current_frame || (int)scene->r.cfra == surface->start_frame) {
PointCache *cache = surface->pointcache;
PTCacheID pid;
surface->current_frame = current_frame;
@ -2223,7 +2226,7 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
/*
* Create a surface for uv image sequence format
*/
int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
{
/* Antialias jitter point relative coords */
float jitter5sample[10] = {0.0f, 0.0f,
@ -2674,7 +2677,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
}
#endif
dynamicPaint_setInitialColor(surface);
dynamicPaint_setInitialColor(scene, surface);
}
return (error == 0);

@ -1109,6 +1109,66 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *r_vert)
copy_v3_v3(r_vert->co, bmdm->vertexCos[index]);
}
static void emDM_getVertCo(DerivedMesh *dm, int index, float r_co[3])
{
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
BMesh *bm = bmdm->em->bm;
if (UNLIKELY(index < 0 || index >= bm->totvert)) {
BLI_assert(!"error in emDM_getVertCo");
return;
}
if (bmdm->vertexCos) {
copy_v3_v3(r_co, bmdm->vertexCos[index]);
}
else {
BMVert *ev = bmdm->em->vert_index[index]; /* should be EDBM_vert_at_index() */
// ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */
copy_v3_v3(r_co, ev->co);
}
}
static void emDM_getVertNo(DerivedMesh *dm, int index, float r_no[3])
{
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
BMesh *bm = bmdm->em->bm;
if (UNLIKELY(index < 0 || index >= bm->totvert)) {
BLI_assert(!"error in emDM_getVertNo");
return;
}
if (bmdm->vertexNos) {
copy_v3_v3(r_no, bmdm->vertexNos[index]);
}
else {
BMVert *ev = bmdm->em->vert_index[index]; /* should be EDBM_vert_at_index() */
// ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */
copy_v3_v3(r_no, ev->no);
}
}
static void emDM_getPolyNo(DerivedMesh *dm, int index, float r_no[3])
{
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
BMesh *bm = bmdm->em->bm;
if (UNLIKELY(index < 0 || index >= bm->totface)) {
BLI_assert(!"error in emDM_getPolyNo");
return;
}
if (bmdm->polyNos) {
copy_v3_v3(r_no, bmdm->polyNos[index]);
}
else {
BMFace *efa = bmdm->em->face_index[index]; /* should be EDBM_vert_at_index() */
// efa = BM_face_at_index(bm, index); /* warning, does list loop, _not_ ideal */
copy_v3_v3(r_no, efa->no);
}
}
static void emDM_getEdge(DerivedMesh *dm, int index, MEdge *r_edge)
{
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
@ -1456,6 +1516,9 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em,
bmdm->dm.getNumPolys = emDM_getNumPolys;
bmdm->dm.getVert = emDM_getVert;
bmdm->dm.getVertCo = emDM_getVertCo;
bmdm->dm.getVertNo = emDM_getVertNo;
bmdm->dm.getPolyNo = emDM_getPolyNo;
bmdm->dm.getEdge = emDM_getEdge;
bmdm->dm.getTessFace = emDM_getTessFace;
bmdm->dm.copyVertArray = emDM_copyVertArray;
@ -1487,6 +1550,7 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em,
bmdm->dm.release = emDM_release;
bmdm->vertexCos = vertexCos;
bmdm->dm.deformedOnly = (vertexCos != NULL);
if (cd_dvert_offset != -1) {
BMIter iter;

@ -744,6 +744,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
float nabla = eff->pd->tex_nabla;
int hasrgb;
short mode = eff->pd->tex_mode;
bool scene_color_manage;
if (!eff->pd->tex)
return;
@ -763,7 +764,9 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
mul_m4_v3(eff->ob->imat, tex_co);
}
hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result, NULL);
scene_color_manage = BKE_scene_check_color_management_enabled(eff->scene);
hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result, NULL, scene_color_manage);
if (hasrgb && mode==PFIELD_TEX_RGB) {
force[0] = (0.5f - result->tr) * strength;
@ -774,15 +777,15 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
strength/=nabla;
tex_co[0] += nabla;
multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+1, NULL);
multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+1, NULL, scene_color_manage);
tex_co[0] -= nabla;
tex_co[1] += nabla;
multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+2, NULL);
multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+2, NULL, scene_color_manage);
tex_co[1] -= nabla;
tex_co[2] += nabla;
multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+3, NULL);
multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+3, NULL, scene_color_manage);
if (mode == PFIELD_TEX_GRAD || !hasrgb) { /* if we don't have rgb fall back to grad */
/* generate intensity if texture only has rgb value */

@ -1697,7 +1697,7 @@ static float evaluate_driver(ChannelDriver *driver, const float evaltime)
/* perform operations on the total if appropriate */
if (driver->type == DRIVER_TYPE_AVERAGE)
driver->curval = (value / (float)tot);
driver->curval = tot ? (value / (float)tot) : 0.0f;
else
driver->curval = value;
}

@ -516,7 +516,7 @@ struct CharTrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int
/* Create unicode string */
utf8len = BLI_strlen_utf8(cu->str);
mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem");
mem = MEM_mallocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem");
BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1);

@ -633,7 +633,7 @@ Image *BKE_image_load_exists(const char *filepath)
for (ima = G.main->image.first; ima; ima = ima->id.next) {
if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) {
BLI_strncpy(strtest, ima->name, sizeof(ima->name));
BLI_path_abs(strtest, G.main->name);
BLI_path_abs(strtest, ID_BLEND_PATH(G.main, &ima->id));
if (BLI_path_cmp(strtest, str) == 0) {
if (ima->anim == NULL || ima->id.us == 0) {
@ -2718,8 +2718,8 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
re = RE_GetRender(iuser->scene->id.name);
channels = 4;
layer = (iuser) ? iuser->layer : 0;
pass = (iuser) ? iuser->pass : 0;
layer = iuser->layer;
pass = iuser->pass;
if (from_render) {
RE_AcquireResultImage(re, &rres);

@ -681,7 +681,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
* we want either a Mesh with no derived data, or derived data with
* deformverts
*/
if (target && target->type == OB_MESH) {
if (target->type == OB_MESH) {
/* if there's derived data without deformverts, don't use vgroups */
if (dm) {
use_vgroups = (dm->getVertData(dm, 0, CD_MDEFORMVERT) != NULL);

@ -183,7 +183,7 @@ static LineStyleModifier *new_modifier(int type, size_t size)
m = (LineStyleModifier *)MEM_callocN(size, "line style modifier");
m->type = type;
strcpy(m->name, modifier_name[type]);
BLI_strncpy(m->name, modifier_name[type], sizeof(m->name));
m->influence = 1.0f;
m->flags = LS_MODIFIER_ENABLED | LS_MODIFIER_EXPANDED;

@ -530,7 +530,7 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
if (1) {
/* now convert linknodes into arrays for faster per pixel access */
unsigned int **buckets_face = MEM_mallocN(bucket_tot * sizeof(unsigned int **), __func__);
unsigned int **buckets_face = MEM_mallocN(bucket_tot * sizeof(*buckets_face), __func__);
unsigned int bucket_index;
for (bucket_index = 0; bucket_index < bucket_tot; bucket_index++) {

@ -2051,8 +2051,10 @@ int do_version_tface(Main *main, int fileload)
printf("Warning: material \"%s\" skipped - to convert old game texface to material go to the Help menu.\n", ma->id.name + 2);
nowarning = 0;
}
else
convert_tfacematerial(main, ma); continue;
else {
convert_tfacematerial(main, ma);
}
continue;
}
/* no conflicts in this material - 90% of cases

@ -485,14 +485,15 @@ void BKE_mball_properties_copy(Scene *scene, Object *active_object)
MetaBall *active_mball = (MetaBall *)active_object->data;
int basisnr, obnr;
char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
SceneBaseIter iter;
BLI_split_name_num(basisname, &basisnr, active_object->id.name + 2, '.');
/* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */
if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL))
if (F_ERROR == BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL))
return;
while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) {
while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &ob)) {
if (ob->type == OB_MBALL) {
if (ob != active_object) {
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
@ -529,14 +530,15 @@ Object *BKE_mball_basis_find(Scene *scene, Object *basis)
Object *ob, *bob = basis;
int basisnr, obnr;
char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
SceneBaseIter iter;
BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.');
/* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */
if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL))
if (F_ERROR == BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL))
return NULL;
while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) {
while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &ob)) {
if (ob->type == OB_MBALL) {
if (ob != bob) {
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
@ -1644,6 +1646,14 @@ BLI_INLINE void copy_v3_fl3(float v[3], float x, float y, float z)
v[2] = z;
}
/* TODO(sergey): Perhaps it could be general utility function in mathutils. */
static bool has_zero_axis_m4(float matrix[4][4])
{
return len_squared_v3(matrix[0]) < FLT_EPSILON ||
len_squared_v3(matrix[1]) < FLT_EPSILON ||
len_squared_v3(matrix[2]) < FLT_EPSILON;
}
static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return totsize */
{
Scene *sce_iter = scene;
@ -1655,7 +1665,8 @@ static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return
//float max = 0.0f;
int a, obnr, zero_size = 0;
char obname[MAX_ID_NAME];
SceneBaseIter iter;
copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from BKE_scene_base_iter_next */
invert_m4_m4(obinv, ob->obmat);
a = 0;
@ -1663,8 +1674,8 @@ static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
/* make main array */
BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL);
while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &bob)) {
BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL);
while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &bob)) {
if (bob->type == OB_MBALL) {
zero_size = 0;
@ -1691,13 +1702,13 @@ static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return
/* when metaball object has zero scale, then MetaElem to this MetaBall
* will not be put to mainb array */
if (bob->size[0] == 0.0f || bob->size[1] == 0.0f || bob->size[2] == 0.0f) {
if (has_zero_axis_m4(bob->obmat)) {
zero_size = 1;
}
else if (bob->parent) {
struct Object *pob = bob->parent;
while (pob) {
if (pob->size[0] == 0.0f || pob->size[1] == 0.0f || pob->size[2] == 0.0f) {
if (has_zero_axis_m4(pob->obmat)) {
zero_size = 1;
break;
}
@ -2225,15 +2236,16 @@ static void mball_count(PROCESS *process, Scene *scene, Object *basis)
MetaElem *ml = NULL;
int basisnr, obnr;
char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
SceneBaseIter iter;
BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.');
process->totelem = 0;
/* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */
if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL))
if (F_ERROR == BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL))
return;
while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) {
while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &ob)) {
if (ob->type == OB_MBALL) {
if (ob == bob) {
MetaBall *mb = ob->data;
@ -2434,6 +2446,7 @@ bool BKE_mball_center_median(MetaBall *mb, float r_cent[3])
for (ml = mb->elems.first; ml; ml = ml->next) {
add_v3_v3(r_cent, &ml->x);
total++;
}
if (total) {

@ -702,6 +702,19 @@ void BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float r_siz
if (r_size) copy_v3_v3(r_size, me->size);
}
void BKE_mesh_texspace_copy_from_object(Mesh *me, Object *ob)
{
float *texloc, *texrot, *texsize;
short *texflag;
if (BKE_object_obdata_texspace_get(ob, &texflag, &texloc, &texsize, &texrot)) {
me->texflag = *texflag;
copy_v3_v3(me->loc, texloc);
copy_v3_v3(me->size, texsize);
copy_v3_v3(me->rot, texrot);
}
}
float (*BKE_mesh_orco_verts_get(Object *ob))[3]
{
Mesh *me = ob->data;
@ -2450,10 +2463,11 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
int totvert, int totpoly, int totloop)
{
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert poly map");
int *indices = MEM_mallocN(sizeof(int) * totloop, "vert poly map mem");
int *indices, *index_iter;
int i, j;
indices = index_iter = MEM_mallocN(sizeof(int) * totloop, "vert poly map mem");
/* Count number of polys for each vertex */
for (i = 0; i < totpoly; i++) {
const MPoly *p = &mpoly[i];
@ -2464,8 +2478,8 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
/* Assign indices mem */
for (i = 0; i < totvert; i++) {
map[i].indices = indices;
indices += map[i].count;
map[i].indices = index_iter;
index_iter += map[i].count;
/* Reset 'count' for use as index in last loop */
map[i].count = 0;
@ -2495,6 +2509,7 @@ void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
{
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert-edge map");
int *indices = MEM_mallocN(sizeof(int) * totedge * 2, "vert-edge map mem");
int *i_pt = indices;
int i;
@ -2506,8 +2521,8 @@ void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
/* Assign indices mem */
for (i = 0; i < totvert; i++) {
map[i].indices = indices;
indices += map[i].count;
map[i].indices = i_pt;
i_pt += map[i].count;
/* Reset 'count' for use as index in last loop */
map[i].count = 0;

@ -440,7 +440,7 @@ static void *moviecache_getprioritydata(void *key_v)
MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *) key_v;
MovieClipCachePriorityData *priority_data;
priority_data = MEM_callocN(sizeof(priority_data), "movie cache clip priority data");
priority_data = MEM_callocN(sizeof(*priority_data), "movie cache clip priority data");
priority_data->framenr = key->framenr;
return priority_data;

@ -349,9 +349,6 @@ static void free_dynamic_typeinfo(bNodeType *ntype)
if (ntype->outputs) {
MEM_freeN(ntype->outputs);
}
if (ntype->ui_name) {
MEM_freeN((void *)ntype->ui_name);
}
}
}

@ -121,9 +121,6 @@
#include "GPU_material.h"
/* Local function protos */
float originmat[3][3]; /* after BKE_object_where_is_calc(), can be used in other functions (bad!) */
void BKE_object_workob_clear(Object *workob)
{
memset(workob, 0, sizeof(Object));
@ -1739,6 +1736,18 @@ void BKE_object_to_mat4(Object *ob, float mat[4][4])
add_v3_v3v3(mat[3], ob->loc, ob->dloc);
}
void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4])
{
if (ob->parent) {
float invmat[4][4]; /* for inverse of parent's matrix */
invert_m4_m4(invmat, ob->parent->obmat);
mul_m4_m4m4(mat, invmat, ob->obmat);
}
else {
copy_m4_m4(mat, ob->obmat);
}
}
/* extern */
int enable_cu_speed = 1;
@ -1991,7 +2000,11 @@ static void ob_parvert3(Object *ob, Object *par, float mat[4][4])
}
}
static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4][4], float slowmat[4][4], int simul)
/**
* \param r_originmat Optional matrix that stores the space the object is in (without its own matrix applied)
*/
static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4][4], float slowmat[4][4],
float r_originmat[3][3], const bool simul)
{
float totmat[4][4];
float tmat[4][4];
@ -2056,8 +2069,10 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4
}
else {
/* external usable originmat */
copy_m3_m4(originmat, tmat);
if (r_originmat) {
/* usable originmat */
copy_m3_m4(r_originmat, tmat);
}
/* origin, for help line */
if ((ob->partype & PARTYPE) == PARSKEL) {
@ -2091,7 +2106,7 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[
/* note, scene is the active scene while actual_scene is the scene the object resides in */
void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
RigidBodyWorld *rbw)
RigidBodyWorld *rbw, float r_originmat[3][3])
{
if (ob == NULL) return;
@ -2103,7 +2118,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
float slowmat[4][4] = MAT4_UNITY;
/* calculate parent matrix */
solve_parenting(scene, ob, par, ob->obmat, slowmat, 0);
solve_parenting(scene, ob, par, ob->obmat, slowmat, r_originmat, false);
/* "slow parent" is definitely not threadsafe, and may also give bad results jumping around
* An old-fashioned hack which probably doesn't really cut it anymore
@ -2138,7 +2153,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
{
BKE_object_where_is_calc_time_ex(scene, ob, ctime, NULL);
BKE_object_where_is_calc_time_ex(scene, ob, ctime, NULL, NULL);
}
/* get object transformation matrix without recalculating dependencies and
@ -2152,7 +2167,7 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
if (ob->parent) {
Object *par = ob->parent;
solve_parenting(scene, ob, par, obmat, slowmat, 1);
solve_parenting(scene, ob, par, obmat, slowmat, NULL, true);
if (ob->partype & PARSLOW)
where_is_object_parslow(ob, obmat, slowmat);
@ -2162,13 +2177,13 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
}
}
void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob)
void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3])
{
BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), rbw);
BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat);
}
void BKE_object_where_is_calc(Scene *scene, Object *ob)
{
BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), NULL);
BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), NULL, NULL);
}
/* was written for the old game engine (until 2.04) */
@ -2186,7 +2201,7 @@ void BKE_object_where_is_calc_simul(Scene *scene, Object *ob)
if (ob->parent) {
par = ob->parent;
solve_parenting(scene, ob, par, ob->obmat, slowmat, 1);
solve_parenting(scene, ob, par, ob->obmat, slowmat, NULL, true);
if (ob->partype & PARSLOW) {
fac1 = (float)(1.0 / (1.0 + fabs(ob->sf)));
@ -2658,7 +2673,7 @@ void BKE_object_handle_update_ex(Scene *scene, Object *ob,
copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
}
else
BKE_object_where_is_calc_ex(scene, rbw, ob);
BKE_object_where_is_calc_ex(scene, rbw, ob, NULL);
}
if (ob->recalc & OB_RECALC_DATA) {

@ -3414,8 +3414,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m
OrigSpaceFace *osface;
float (*orcodata)[3];
int i = pa->num_dmcache == DMCACHE_NOTFOUND ? pa->num : pa->num_dmcache;
int i = (ELEM(pa->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND)) ? pa->num : pa->num_dmcache;
if (i == -1 || i >= dm->getNumTessFaces(dm)) { unit_m4(mat); return; }
mface = dm->getTessFaceData(dm, i, CD_MFACE);
@ -4511,7 +4510,7 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part,
num = DMCACHE_NOTFOUND;
}
if (mtface && num != DMCACHE_NOTFOUND) {
if (mtface && !ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
mface = psmd->dm->getTessFaceData(psmd->dm, num, CD_MFACE);
mtface += num;
psys_interpolate_uvs(mtface, mface->v4, pa->fuv, uv);

@ -1660,17 +1660,22 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
{
Object *ob = sim->ob;
ParticleSystem *psys = sim->psys;
ParticleSettings *part;
ParticleSettings *part = psys->part;
ParticleTexture ptex;
float fac, phasefac, nor[3] = {0,0,0},loc[3],vel[3] = {0.0,0.0,0.0},rot[4],q2[4];
float r_vel[3],r_ave[3],r_rot[4],vec[3],p_vel[3] = {0.0,0.0,0.0};
float x_vec[3] = {1.0,0.0,0.0}, utan[3] = {0.0,1.0,0.0}, vtan[3] = {0.0,0.0,1.0}, rot_vec[3] = {0.0,0.0,0.0};
float q_phase[4];
const bool use_boids = ((part->phystype == PART_PHYS_BOIDS) &&
(pa->boid != NULL));
const bool use_tangents = ((use_boids == false) &&
((part->tanfac != 0.0f) || (part->rotmode == PART_ROT_NOR_TAN)));
int p = pa - psys->particles;
part=psys->part;
/* get birth location from object */
if (part->tanfac != 0.f)
if (use_tangents)
psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0);
else
psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0);
@ -1688,7 +1693,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
normalize_v3(nor);
/* -tangent */
if (part->tanfac!=0.0f) {
if (use_tangents) {
//float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f;
float phase=0.0f;
mul_v3_fl(vtan,-cosf((float)M_PI*(part->tanphase+phase)));
@ -1737,7 +1742,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
mul_qt_qtqt(r_rot,r_rot,rot);
}
if (part->phystype==PART_PHYS_BOIDS && pa->boid) {
if (use_boids) {
float dvec[3], q[4], mat[3][3];
copy_v3_v3(state->co,loc);
@ -1823,35 +1828,112 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
unit_qt(state->rot);
if (part->rotmode) {
bool use_global_space;
/* create vector into which rotation is aligned */
switch (part->rotmode) {
case PART_ROT_NOR:
case PART_ROT_NOR_TAN:
copy_v3_v3(rot_vec, nor);
use_global_space = false;
break;
case PART_ROT_VEL:
copy_v3_v3(rot_vec, vel);
use_global_space = true;
break;
case PART_ROT_GLOB_X:
case PART_ROT_GLOB_Y:
case PART_ROT_GLOB_Z:
rot_vec[part->rotmode - PART_ROT_GLOB_X] = 1.0f;
use_global_space = true;
break;
case PART_ROT_OB_X:
case PART_ROT_OB_Y:
case PART_ROT_OB_Z:
copy_v3_v3(rot_vec, ob->obmat[part->rotmode - PART_ROT_OB_X]);
use_global_space = false;
break;
default:
use_global_space = true;
break;
}
/* create rotation quat */
negate_v3(rot_vec);
vec_to_quat( q2,rot_vec, OB_POSX, OB_POSZ);
/* randomize rotation quat */
if (part->randrotfac!=0.0f)
interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
else
copy_qt_qt(rot,q2);
if (use_global_space) {
negate_v3(rot_vec);
vec_to_quat(q2, rot_vec, OB_POSX, OB_POSZ);
/* randomize rotation quat */
if (part->randrotfac != 0.0f) {
interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
}
else {
copy_qt_qt(rot, q2);
}
}
else {
/* calculate rotation in local-space */
float q_obmat[4];
float q_imat[4];
mat4_to_quat(q_obmat, ob->obmat);
invert_qt_qt(q_imat, q_obmat);
if (part->rotmode != PART_ROT_NOR_TAN) {
float rot_vec_local[3];
/* rot_vec */
negate_v3(rot_vec);
copy_v3_v3(rot_vec_local, rot_vec);
mul_qt_v3(q_imat, rot_vec_local);
normalize_v3(rot_vec_local);
vec_to_quat(q2, rot_vec_local, OB_POSX, OB_POSZ);
}
else {
/* (part->rotmode == PART_ROT_NOR_TAN) */
float tmat[3][3];
/* note: utan_local is not taken from 'utan', we calculate from rot_vec/vtan */
/* note: it looks like rotation phase may be applied twice (once with vtan, again below)
* however this isn't the case - campbell */
float *rot_vec_local = tmat[0];
float *vtan_local = tmat[1];
float *utan_local = tmat[2];
/* use tangents */
BLI_assert(use_tangents == true);
/* rot_vec */
copy_v3_v3(rot_vec_local, rot_vec);
mul_qt_v3(q_imat, rot_vec_local);
/* vtan_local */
copy_v3_v3(vtan_local, vtan); /* flips, cant use */
mul_qt_v3(q_imat, vtan_local);
/* ensure orthogonal matrix (rot_vec aligned) */
cross_v3_v3v3(utan_local, vtan_local, rot_vec_local);
cross_v3_v3v3(vtan_local, utan_local, rot_vec_local);
/* note: no need to normalize */
mat3_to_quat(q2, tmat);
}
/* randomize rotation quat */
if (part->randrotfac != 0.0f) {
mul_qt_qtqt(r_rot, r_rot, q_imat);
interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
}
else {
copy_qt_qt(rot, q2);
}
mul_qt_qtqt(rot, q_obmat, rot);
}
/* rotation phase */
phasefac = part->phasefac;

@ -2800,7 +2800,7 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
smokeModifier_reset_turbulence(pid->calldata);
#endif
else if (pid->type == PTCACHE_TYPE_DYNAMICPAINT)
dynamicPaint_clearSurface((DynamicPaintSurface*)pid->calldata);
dynamicPaint_clearSurface(scene, (DynamicPaintSurface*)pid->calldata);
}
if (clear)
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);

@ -684,12 +684,9 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
}
}
/* sort baselist */
DAG_scene_relations_rebuild(bmain, scene);
/* ensure dags are built for sets */
/* sort baselist for scene and sets */
for (sce = scene; sce; sce = sce->set)
DAG_scene_relations_update(bmain, sce);
DAG_scene_relations_rebuild(bmain, sce);
/* copy layers and flags from bases to objects */
for (base = scene->base.first; base; base = base->next) {
@ -746,17 +743,16 @@ void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce)
/* used by metaballs
* doesn't return the original duplicated object, only dupli's
*/
int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
int BKE_scene_base_iter_next(SceneBaseIter *iter, Scene **scene, int val, Base **base, Object **ob)
{
static ListBase *duplilist = NULL;
static DupliObject *dupob;
static int fase = F_START, in_next_object = 0;
static int in_next_object = 0;
int run_again = 1;
/* init */
if (val == 0) {
fase = F_START;
dupob = NULL;
iter->fase = F_START;
iter->dupob = NULL;
iter->duplilist = NULL;
/* XXX particle systems with metas+dupligroups call this recursively */
/* see bug #18725 */
@ -774,11 +770,11 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
run_again = 0;
/* the first base */
if (fase == F_START) {
if (iter->fase == F_START) {
*base = (*scene)->base.first;
if (*base) {
*ob = (*base)->object;
fase = F_SCENE;
iter->fase = F_SCENE;
}
else {
/* exception: empty scene */
@ -787,20 +783,20 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
if ((*scene)->base.first) {
*base = (*scene)->base.first;
*ob = (*base)->object;
fase = F_SCENE;
iter->fase = F_SCENE;
break;
}
}
}
}
else {
if (*base && fase != F_DUPLI) {
if (*base && iter->fase != F_DUPLI) {
*base = (*base)->next;
if (*base) {
*ob = (*base)->object;
}
else {
if (fase == F_SCENE) {
if (iter->fase == F_SCENE) {
/* (*scene) is finished, now do the set */
while ((*scene)->set) {
(*scene) = (*scene)->set;
@ -816,45 +812,45 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
}
if (*base == NULL) {
fase = F_START;
iter->fase = F_START;
}
else {
if (fase != F_DUPLI) {
if (iter->fase != F_DUPLI) {
if ( (*base)->object->transflag & OB_DUPLI) {
/* groups cannot be duplicated for mballs yet,
* this enters eternal loop because of
* makeDispListMBall getting called inside of group_duplilist */
if ((*base)->object->dup_group == NULL) {
duplilist = object_duplilist((*scene), (*base)->object, FALSE);
iter->duplilist = object_duplilist((*scene), (*base)->object, FALSE);
dupob = duplilist->first;
iter->dupob = iter->duplilist->first;
if (!dupob)
free_object_duplilist(duplilist);
if (!iter->dupob)
free_object_duplilist(iter->duplilist);
}
}
}
/* handle dupli's */
if (dupob) {
if (iter->dupob) {
copy_m4_m4(dupob->ob->obmat, dupob->mat);
copy_m4_m4(iter->dupob->ob->obmat, iter->dupob->mat);
(*base)->flag |= OB_FROMDUPLI;
*ob = dupob->ob;
fase = F_DUPLI;
*ob = iter->dupob->ob;
iter->fase = F_DUPLI;
dupob = dupob->next;
iter->dupob = iter->dupob->next;
}
else if (fase == F_DUPLI) {
fase = F_SCENE;
else if (iter->fase == F_DUPLI) {
iter->fase = F_SCENE;
(*base)->flag &= ~OB_FROMDUPLI;
for (dupob = duplilist->first; dupob; dupob = dupob->next) {
copy_m4_m4(dupob->ob->obmat, dupob->omat);
for (iter->dupob = iter->duplilist->first; iter->dupob; iter->dupob = iter->dupob->next) {
copy_m4_m4(iter->dupob->ob->obmat, iter->dupob->omat);
}
free_object_duplilist(duplilist);
duplilist = NULL;
free_object_duplilist(iter->duplilist);
iter->duplilist = NULL;
run_again = 1;
}
}
@ -870,7 +866,7 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
/* reset recursion test */
in_next_object = 0;
return fase;
return iter->fase;
}
Object *BKE_scene_camera_find(Scene *sc)
@ -1483,6 +1479,16 @@ void BKE_scene_disable_color_management(Scene *scene)
int BKE_scene_check_color_management_enabled(const Scene *scene)
{
/* TODO(sergey): shouldn't be needed. but we're currently far to close to the release,
* so better be extra-safe than sorry.
*
* Will remove the check after the release.
*/
if (!scene) {
BLI_assert(!"Shouldn't happen!");
return TRUE;
}
return strcmp(scene->display_settings.display_device, "None") != 0;
}

@ -50,6 +50,7 @@
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
@ -3111,8 +3112,18 @@ static void sequence_invalidate_cache(Scene *scene, Sequence *seq, int invalidat
Editing *ed = scene->ed;
/* invalidate cache for current sequence */
if (invalidate_self)
if (invalidate_self) {
if (seq->anim) {
/* Animation structure holds some buffers inside,
* so for proper cache invalidation we need to
* re-open the animation.
*/
IMB_free_anim(seq->anim);
seq->anim = NULL;
}
BKE_sequencer_cache_cleanup_sequence(seq);
}
/* if invalidation is invoked from sequence free routine, effectdata would be NULL here */
if (seq->effectdata && seq->type == SEQ_TYPE_SPEED)
@ -3938,7 +3949,8 @@ Mask *BKE_sequencer_mask_get(Scene *scene)
static void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load)
{
if (seq) {
BLI_strncpy(seq->name + 2, seq_load->name, sizeof(seq->name) - 2);
BLI_strncpy_utf8(seq->name + 2, seq_load->name, sizeof(seq->name) - 2);
BLI_utf8_invalid_strip(seq->name + 2, sizeof(seq->name) - 2);
BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
if (seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) {

@ -1413,12 +1413,14 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke
}
}
/* TODO(sergey): de-duplicate with get_texture_value from modifier utils */
/* NOTE: Skips color management, because result is only used for value now, not for color. */
static void get_texture_value(Tex *texture, float tex_co[3], TexResult *texres)
{
int result_type;
/* no node textures for now */
result_type = multitex_ext_safe(texture, tex_co, texres, NULL);
result_type = multitex_ext_safe(texture, tex_co, texres, NULL, false);
/* if the texture gave an RGB value, we assume it didn't give a valid
* intensity, since this is in the context of modifiers don't use perceptual color conversion.
@ -2100,7 +2102,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
/* sample subframes */
else {
int scene_frame = scene->r.cfra;
float scene_subframe = scene->r.subframe;
// float scene_subframe = scene->r.subframe; // UNUSED
int subframe;
for (subframe = 0; subframe <= subframes; subframe++) {
EmissionMap em_temp = {0};

@ -847,19 +847,6 @@ int txt_utf8_column_to_offset(const char *str, int column)
return offset;
}
/* returns the real number of characters in string */
/* not the same as BLI_strlen_utf8, which returns length for wide characters */
static int txt_utf8_len(const char *src)
{
int len;
for (len = 0; *src; len++) {
src += BLI_str_utf8_size(src);
}
return len;
}
void txt_move_up(Text *text, short sel)
{
TextLine **linep;
@ -2059,7 +2046,7 @@ void txt_do_undo(Text *text)
text->undo_pos--;
}
buf[i] = 0;
linep = txt_utf8_len(buf);
linep = BLI_strlen_utf8(buf);
MEM_freeN(buf);
/* skip over the length that was stored again */

@ -3455,7 +3455,7 @@ static bool check_point_in_stroke(bGPDstroke *stroke, float x, float y)
prev = i;
}
return count % 2 ? true : false;
return (count % 2) ? true : false;
}
/* Check whether point is inside any stroke of grease pencil layer. */

@ -95,6 +95,11 @@ typedef struct bUnitDef {
#define B_UNIT_DEF_SUPPRESS 1 /* Use for units that are not used enough to be translated into for common use */
#define B_UNIT_DEF_TENTH 2 /* Display a unit even if its value is 0.1, eg 0.1mm instead of 100um */
/* workaround encoding issue with "µm", bug [#36090] */
#define B_UNIT_CHAR_MICRO "\xb5"
#define UM B_UNIT_CHAR_MICRO"m"
#define US B_UNIT_CHAR_MICRO"s"
/* define a single unit */
typedef struct bUnitCollection {
struct bUnitDef *units;
@ -116,7 +121,7 @@ static struct bUnitDef buMetricLenDef[] = {
{"decimeter", "decimeters", "dm", NULL, "10 Centimeters", UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS},
{"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_CM, 0.0, B_UNIT_DEF_NONE},
{"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_MM, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH},
{"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, // micron too?
{"micrometer", "micrometers", UM, "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, // micron too?
/* These get displayed because of float precision problems in the transform header,
* could work around, but for now probably people wont use these */
@ -149,7 +154,7 @@ static struct bUnitDef buMetricAreaDef[] = {
{"square decimeter", "square decimetees", "dm²", "dm2", "Square Decimeters", UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS},
{"square centimeter", "square centimeters", "cm²", "cm2", "Square Centimeters", UN_SC_CM * UN_SC_CM, 0.0, B_UNIT_DEF_NONE},
{"square millimeter", "square millimeters", "mm²", "mm2", "Square Millimeters", UN_SC_MM * UN_SC_MM, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH},
{"square micrometer", "square micrometers", "µm²", "um2", "Square Micrometers", UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
{"square micrometer", "square micrometers", UM"²", "um2", "Square Micrometers", UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
};
static struct bUnitCollection buMetricAreaCollection = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef) / sizeof(bUnitDef)};
@ -175,7 +180,7 @@ static struct bUnitDef buMetricVolDef[] = {
{"cubic decimeter", "cubic decimeters", "dm³", "dm3", "Cubic Decimeters", UN_SC_DM * UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS},
{"cubic centimeter", "cubic centimeters", "cm³", "cm3", "Cubic Centimeters", UN_SC_CM * UN_SC_CM * UN_SC_CM, 0.0, B_UNIT_DEF_NONE},
{"cubic millimeter", "cubic millimeters", "mm³", "mm3", "Cubic Millimeters", UN_SC_MM * UN_SC_MM * UN_SC_MM, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH},
{"cubic micrometer", "cubic micrometers", "µm³", "um3", "Cubic Micrometers", UN_SC_UM * UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
{"cubic micrometer", "cubic micrometers", UM"³", "um3", "Cubic Micrometers", UN_SC_UM * UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
};
static struct bUnitCollection buMetricVolCollection = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef) / sizeof(bUnitDef)};
@ -253,7 +258,7 @@ static struct bUnitDef buNaturalTimeDef[] = {
{"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE},
{"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */
{"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0, B_UNIT_DEF_NONE},
{"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE},
{"microsecond", "microseconds", US, "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE},
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
};
static struct bUnitCollection buNaturalTimeCollection = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef) / sizeof(bUnitDef)};
@ -273,7 +278,7 @@ static struct bUnitDef buCameraLenDef[] = {
{"decimeter", "decimeters", "dm", NULL, "10 Centimeters", UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS},
{"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS},
{"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_M, 0.0, B_UNIT_DEF_NONE},
{"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_MM, 0.0, B_UNIT_DEF_SUPPRESS}, // micron too?
{"micrometer", "micrometers", UM, "um", "Micrometers", UN_SC_MM, 0.0, B_UNIT_DEF_SUPPRESS}, // micron too?
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
};
static struct bUnitCollection buCameraLenCollection = {buCameraLenDef, 3, 0, sizeof(buCameraLenDef) / sizeof(bUnitDef)};

@ -72,7 +72,7 @@ void BLI_freelinkN(struct ListBase *listbase, void *vlink);
void BLI_movelisttolist(struct ListBase *dst, struct ListBase *src);
void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src);
void BLI_reverselist(struct ListBase *lb);
void BLI_rotatelist(struct ListBase *lb, LinkData *vlink);
void BLI_rotatelist(struct ListBase *lb, void *vlink);
/* create a generic list node containing link to provided data */
struct LinkData *BLI_genericNodeN(void *data);

@ -75,7 +75,8 @@ void closest_to_line_segment_v2(float closest[2], const float p[2], const float
float dist_to_plane_normalized_v3(const float p[3], const float plane_co[3], const float plane_no_unit[3]);
float dist_to_plane_v3(const float p[3], const float plane_co[3], const float plane_no[3]);
float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]);
float dist_squared_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]);
float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]);
float dist_to_line_v3(const float p[3], const float l1[3], const float l2[3]);
float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]);
float closest_to_line_v2(float r[2], const float p[2], const float l1[2], const float l2[2]);

@ -240,6 +240,7 @@ void rotate_normalized_v3_v3v3fl(float v[3], const float p[3], const float axis[
void print_v2(const char *str, const float a[2]);
void print_v3(const char *str, const float a[3]);
void print_v4(const char *str, const float a[4]);
void print_vn(const char *str, const float v[], const int n);
MINLINE void normal_short_to_float_v3(float r[3], const short n[3]);
MINLINE void normal_float_to_short_v3(short r[3], const float n[3]);

@ -93,14 +93,14 @@ __attribute__((nonnull))
#endif
;
size_t BLI_snprintf(char *__restrict buffer, size_t len, const char *__restrict format, ...)
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...)
#ifdef __GNUC__
__attribute__ ((format(printf, 3, 4)))
__attribute__((nonnull))
#endif
;
size_t BLI_vsnprintf(char *__restrict buffer, size_t count, const char *__restrict format, va_list arg)
size_t BLI_vsnprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format, va_list arg)
#ifdef __GNUC__
__attribute__ ((format(printf, 3, 0)))
#endif

@ -51,8 +51,10 @@ char *BLI_str_prev_char_utf8(const char *p);
/* wchar_t functions, copied from blenders own font.c originally */
size_t BLI_wstrlen_utf8(const wchar_t *src);
size_t BLI_strlen_utf8_ex(const char *strc, int *r_len_bytes);
size_t BLI_strlen_utf8(const char *strc);
size_t BLI_strnlen_utf8(const char *start, const size_t maxlen);
size_t BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, int *r_len_bytes);
size_t BLI_strnlen_utf8(const char *strc, const size_t maxlen);
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxcpy);
size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst, const char *__restrict src, const size_t maxcpy);

@ -199,7 +199,7 @@ bool BLI_file_touch(const char *file)
{
FILE *f = BLI_fopen(file, "r+b");
if (f != NULL) {
char c = getc(f);
int c = getc(f);
rewind(f);
putc(c, f);
}

@ -557,14 +557,14 @@ void BLI_reverselist(ListBase *lb)
/**
* \param vlink Link to make first.
*/
void BLI_rotatelist(ListBase *lb, LinkData *vlink)
void BLI_rotatelist(ListBase *lb, void *vlink)
{
/* make circular */
((LinkData *)lb->first)->prev = lb->last;
((LinkData *)lb->last)->next = lb->first;
lb->first = vlink;
lb->last = vlink->prev;
lb->last = ((LinkData *)vlink)->prev;
((LinkData *)lb->first)->prev = NULL;
((LinkData *)lb->last)->next = NULL;

@ -324,21 +324,26 @@ float dist_to_plane_v3(const float p[3], const float plane_co[3], const float pl
return line_point_factor_v3(p, plane_co, plane_co_other);
}
/* distance v1 to line-piece v2-v3 in 3D */
float dist_to_line_segment_v3(const float v1[3], const float v2[3], const float v3[3])
/* distance v1 to line-piece l1-l2 in 3D */
float dist_squared_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3])
{
float closest[3];
closest_to_line_segment_v3(closest, v1, v2, v3);
closest_to_line_segment_v3(closest, p, l1, l2);
return len_v3v3(closest, v1);
return len_squared_v3v3(closest, p);
}
float dist_to_line_v3(const float v1[3], const float v2[3], const float v3[3])
float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3])
{
return sqrtf(dist_squared_to_line_segment_v3(p, l1, l2));
}
float dist_to_line_v3(const float v1[3], const float l1[3], const float l2[3])
{
float closest[3];
closest_to_line_v3(closest, v1, v2, v3);
closest_to_line_v3(closest, v1, l1, l2);
return len_v3v3(closest, v1);
}
@ -2598,45 +2603,62 @@ static float mean_value_half_tan_v2(const float v1[2], const float v2[2], const
void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[3])
{
/* TODO: t1 and t2 overlap each iter, we could call this only once per iter and reuse previous value */
float totweight, t1, t2, len, *vmid, *vprev, *vnext;
int i, i_next, i_curr;
const float eps = 0.00001f; /* take care, low values cause [#36105] */
const float eps_sq = eps * eps;
float *v_curr, *v_next;
float ht_prev, ht; /* half tangents */
float totweight = 0.0f;
int i = 0;
bool vert_interp = false;
bool edge_interp = false;
totweight = 0.0f;
v_curr = v[0];
v_next = v[1];
for (i = 0; i < n; i++) {
i_curr = i;
i_next = (i == n - 1) ? 0 : i + 1;
ht_prev = mean_value_half_tan_v3(co, v[n - 1], v_curr);
vmid = v[i];
vprev = (i == 0) ? v[n - 1] : v[i - 1];
vnext = v[i_next];
while (i < n) {
const float len_sq = len_squared_v3v3(co, v_curr);
/* Mark Mayer et al algorithm that is used here does not operate well if vertex is close
* to borders of face. In that case, do simple linear interpolation between the two edge vertices */
if (dist_to_line_segment_v3(co, vmid, vnext) < 10 * FLT_EPSILON) {
if (len_sq < eps_sq) {
vert_interp = true;
break;
}
else if (dist_squared_to_line_segment_v3(co, v_curr, v_next) < eps_sq) {
edge_interp = true;
break;
}
t1 = mean_value_half_tan_v3(co, vprev, vmid);
t2 = mean_value_half_tan_v3(co, vmid, vnext);
len = len_v3v3(co, vmid);
w[i] = (len != 0.0f) ? (t1 + t2) / len: 0.0f;
ht = mean_value_half_tan_v3(co, v_curr, v_next);
w[i] = (ht_prev + ht) / sqrtf(len_sq);
totweight += w[i];
/* step */
i++;
v_curr = v_next;
v_next = v[(i + 1) % n];
ht_prev = ht;
}
if (edge_interp) {
float len_curr = len_v3v3(co, vmid);
float len_next = len_v3v3(co, vnext);
if (vert_interp) {
const int i_curr = i;
for (i = 0; i < n; i++)
w[i] = 0.0;
w[i_curr] = 1.0f;
}
else if (edge_interp) {
const int i_curr = i;
float len_curr = len_v3v3(co, v_curr);
float len_next = len_v3v3(co, v_next);
float edge_len = len_curr + len_next;
for (i = 0; i < n; i++)
w[i] = 0.0;
w[i_curr] = len_next / edge_len;
w[i_next] = len_curr / edge_len;
w[(i_curr + 1) % n] = len_curr / edge_len;
}
else {
if (totweight != 0.0f) {
@ -2650,45 +2672,62 @@ void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[
void interp_weights_poly_v2(float *w, float v[][2], const int n, const float co[2])
{
/* TODO: t1 and t2 overlap each iter, we could call this only once per iter and reuse previous value */
float totweight, t1, t2, len, *vmid, *vprev, *vnext;
int i, i_next, i_curr;
const float eps = 0.00001f; /* take care, low values cause [#36105] */
const float eps_sq = eps * eps;
float *v_curr, *v_next;
float ht_prev, ht; /* half tangents */
float totweight = 0.0f;
int i = 0;
bool vert_interp = false;
bool edge_interp = false;
totweight = 0.0f;
v_curr = v[0];
v_next = v[1];
for (i = 0; i < n; i++) {
i_curr = i;
i_next = (i == n - 1) ? 0 : i + 1;
ht_prev = mean_value_half_tan_v2(co, v[n - 1], v_curr);
vmid = v[i];
vprev = (i == 0) ? v[n - 1] : v[i - 1];
vnext = v[i_next];
while (i < n) {
const float len_sq = len_squared_v2v2(co, v_curr);
/* Mark Mayer et al algorithm that is used here does not operate well if vertex is close
* to borders of face. In that case, do simple linear interpolation between the two edge vertices */
if (dist_to_line_segment_v2(co, vmid, vnext) < 10 * FLT_EPSILON) {
if (len_sq < eps_sq) {
vert_interp = true;
break;
}
else if (dist_squared_to_line_segment_v2(co, v_curr, v_next) < eps_sq) {
edge_interp = true;
break;
}
t1 = mean_value_half_tan_v2(co, vprev, vmid);
t2 = mean_value_half_tan_v2(co, vmid, vnext);
len = len_v2v2(co, vmid);
w[i] = (len != 0.0f) ? (t1 + t2) / len: 0.0f;
ht = mean_value_half_tan_v2(co, v_curr, v_next);
w[i] = (ht_prev + ht) / sqrtf(len_sq);
totweight += w[i];
/* step */
i++;
v_curr = v_next;
v_next = v[(i + 1) % n];
ht_prev = ht;
}
if (edge_interp) {
float len_curr = len_v2v2(co, vmid);
float len_next = len_v2v2(co, vnext);
if (vert_interp) {
const int i_curr = i;
for (i = 0; i < n; i++)
w[i] = 0.0;
w[i_curr] = 1.0f;
}
else if (edge_interp) {
const int i_curr = i;
float len_curr = len_v2v2(co, v_curr);
float len_next = len_v2v2(co, v_next);
float edge_len = len_curr + len_next;
for (i = 0; i < n; i++)
w[i] = 0.0;
w[i_curr] = len_next / edge_len;
w[i_next] = len_curr / edge_len;
w[(i_curr + 1) % n] = len_curr / edge_len;
}
else {
if (totweight != 0.0f) {

@ -790,6 +790,7 @@ void orthogonalize_m3(float mat[3][3], int axis)
normalize_v3(mat[2]);
cross_v3_v3v3(mat[1], mat[2], mat[0]);
}
break;
case 1:
if (dot_v3v3(mat[1], mat[0]) < 1) {
cross_v3_v3v3(mat[2], mat[0], mat[1]);
@ -812,6 +813,7 @@ void orthogonalize_m3(float mat[3][3], int axis)
normalize_v3(mat[0]);
cross_v3_v3v3(mat[2], mat[0], mat[1]);
}
break;
case 2:
if (dot_v3v3(mat[2], mat[0]) < 1) {
cross_v3_v3v3(mat[1], mat[2], mat[0]);
@ -834,6 +836,9 @@ void orthogonalize_m3(float mat[3][3], int axis)
normalize_v3(mat[0]);
cross_v3_v3v3(mat[1], mat[2], mat[0]);
}
break;
default:
BLI_assert(0);
}
mul_v3_fl(mat[0], size[0]);
mul_v3_fl(mat[1], size[1]);
@ -868,8 +873,8 @@ void orthogonalize_m4(float mat[4][4], int axis)
normalize_v3(mat[2]);
cross_v3_v3v3(mat[1], mat[2], mat[0]);
}
break;
case 1:
normalize_v3(mat[0]);
if (dot_v3v3(mat[1], mat[0]) < 1) {
cross_v3_v3v3(mat[2], mat[0], mat[1]);
normalize_v3(mat[2]);
@ -891,6 +896,7 @@ void orthogonalize_m4(float mat[4][4], int axis)
normalize_v3(mat[0]);
cross_v3_v3v3(mat[2], mat[0], mat[1]);
}
break;
case 2:
if (dot_v3v3(mat[2], mat[0]) < 1) {
cross_v3_v3v3(mat[1], mat[2], mat[0]);
@ -913,6 +919,9 @@ void orthogonalize_m4(float mat[4][4], int axis)
normalize_v3(mat[0]);
cross_v3_v3v3(mat[1], mat[2], mat[0]);
}
break;
default:
BLI_assert(0);
}
mul_v3_fl(mat[0], size[0]);
mul_v3_fl(mat[1], size[1]);
@ -1207,16 +1216,19 @@ void mat4_to_size(float size[3], float mat[4][4])
float mat3_to_scale(float mat[3][3])
{
/* unit length vector */
float unit_vec[3] = {0.577350269189626f, 0.577350269189626f, 0.577350269189626f};
float unit_vec[3];
copy_v3_fl(unit_vec, 0.577350269189626f);
mul_m3_v3(mat, unit_vec);
return len_v3(unit_vec);
}
float mat4_to_scale(float mat[4][4])
{
float tmat[3][3];
copy_m3_m4(tmat, mat);
return mat3_to_scale(tmat);
/* unit length vector */
float unit_vec[3];
copy_v3_fl(unit_vec, 0.577350269189626f);
mul_mat3_m4_v3(mat, unit_vec);
return len_v3(unit_vec);
}
void mat3_to_rot_size(float rot[3][3], float size[3], float mat3[3][3])

@ -542,6 +542,16 @@ void print_v4(const char *str, const float v[4])
printf("%s: %.3f %.3f %.3f %.3f\n", str, v[0], v[1], v[2], v[3]);
}
void print_vn(const char *str, const float v[], const int n)
{
int i = 0;
printf("%s[%d]:", str, n);
while (i < n) {
printf(" %.3f", v[i++]);
}
printf("\n");
}
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
{
if (min[0] > vec[0]) min[0] = vec[0];

@ -47,6 +47,8 @@
# pragma GCC diagnostic error "-Wsign-conversion"
#endif
// #define DEBUG_STRSIZE
/**
* Duplicates the first \a len bytes of cstring \a str
* into a newly mallocN'd string and returns it. \a str
@ -111,6 +113,10 @@ char *BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t
size_t srclen = BLI_strnlen(src, maxncpy - 1);
BLI_assert(maxncpy != 0);
#ifdef DEBUG_STRSIZE
memset(dst, 0xff, sizeof(*dst) * maxncpy);
#endif
memcpy(dst, src, srclen);
dst[srclen] = '\0';
return dst;
@ -134,6 +140,10 @@ size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, const
size_t srclen = BLI_strnlen(src, maxncpy - 1);
BLI_assert(maxncpy != 0);
#ifdef DEBUG_STRSIZE
memset(dst, 0xff, sizeof(*dst) * maxncpy);
#endif
memcpy(dst, src, srclen);
dst[srclen] = '\0';
return srclen;
@ -149,21 +159,21 @@ size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src)
/**
* Portable replacement for #vsnprintf
*/
size_t BLI_vsnprintf(char *__restrict buffer, size_t count, const char *__restrict format, va_list arg)
size_t BLI_vsnprintf(char *__restrict buffer, size_t maxncpy, const char *__restrict format, va_list arg)
{
size_t n;
BLI_assert(buffer != NULL);
BLI_assert(count > 0);
BLI_assert(maxncpy > 0);
BLI_assert(format != NULL);
n = (size_t)vsnprintf(buffer, count, format, arg);
n = (size_t)vsnprintf(buffer, maxncpy, format, arg);
if (n != -1 && n < count) {
if (n != -1 && n < maxncpy) {
buffer[n] = '\0';
}
else {
buffer[count - 1] = '\0';
buffer[maxncpy - 1] = '\0';
}
return n;
@ -172,13 +182,17 @@ size_t BLI_vsnprintf(char *__restrict buffer, size_t count, const char *__restri
/**
* Portable replacement for #snprintf
*/
size_t BLI_snprintf(char *__restrict buffer, size_t count, const char *__restrict format, ...)
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...)
{
size_t n;
va_list arg;
#ifdef DEBUG_STRSIZE
memset(dst, 0xff, sizeof(*dst) * maxncpy);
#endif
va_start(arg, format);
n = BLI_vsnprintf(buffer, count, format, arg);
n = BLI_vsnprintf(dst, maxncpy, format, arg);
va_end(arg);
return n;

@ -45,6 +45,8 @@
# pragma GCC diagnostic error "-Wsign-conversion"
#endif
// #define DEBUG_STRSIZE
/* from libswish3, originally called u8_isvalid(),
* modified to return the index of the bad character (byte index not utf).
* http://svn.swish-e.org/libswish3/trunk/src/libswish3/utf8.c r3044 - campbell */
@ -195,6 +197,10 @@ char *BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t
BLI_assert(maxncpy != 0);
#ifdef DEBUG_STRSIZE
memset(dst, 0xff, sizeof(*dst) * maxncpy);
#endif
/* note: currently we don't attempt to deal with invalid utf8 chars */
BLI_STR_UTF8_CPY(dst, src, maxncpy);
@ -208,6 +214,10 @@ char *BLI_strncat_utf8(char *__restrict dst, const char *__restrict src, size_t
maxncpy--;
}
#ifdef DEBUG_STRSIZE
memset(dst, 0xff, sizeof(*dst) * maxncpy);
#endif
BLI_STR_UTF8_CPY(dst, src, maxncpy);
return dst;
@ -220,11 +230,16 @@ char *BLI_strncat_utf8(char *__restrict dst, const char *__restrict src, size_t
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxncpy)
{
const size_t maxlen = maxncpy - 1;
size_t len = 0;
BLI_assert(maxncpy != 0);
while (*src && len < maxncpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */
#ifdef DEBUG_STRSIZE
memset(dst, 0xff, sizeof(*dst) * maxncpy);
#endif
while (*src && len < maxlen) { /* XXX can still run over the buffer because utf8 size isn't known :| */
len += BLI_str_utf8_from_unicode((unsigned int)*src++, dst + len);
}
@ -245,24 +260,16 @@ size_t BLI_wstrlen_utf8(const wchar_t *src)
return len;
}
/* this is very close to 'BLI_str_utf8_size' functionality, perhaps we should de-duplicate */
/* size of UTF-8 character in bytes */
static size_t strlen_utf8_char(const char *strc)
size_t BLI_strlen_utf8_ex(const char *strc, int *r_len_bytes)
{
if ((*strc & 0xe0) == 0xc0) {
if ((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00)
return 2;
}
else if ((*strc & 0xf0) == 0xe0) {
if ((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00)
return 3;
}
else if ((*strc & 0xf8) == 0xf0) {
if ((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00)
return 4;
}
size_t len;
const char *strc_orig = strc;
return 1;
for (len = 0; *strc; len++)
strc += BLI_str_utf8_size_safe(strc);
*r_len_bytes = (strc - strc_orig);
return len;
}
size_t BLI_strlen_utf8(const char *strc)
@ -270,25 +277,37 @@ size_t BLI_strlen_utf8(const char *strc)
size_t len;
for (len = 0; *strc; len++)
strc += strlen_utf8_char(strc);
strc += BLI_str_utf8_size_safe(strc);
return len;
}
size_t BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, int *r_len_bytes)
{
size_t len;
const char *strc_orig = strc;
const char *strc_end = strc + maxlen;
for (len = 0; *strc && strc < strc_end; len++) {
strc += BLI_str_utf8_size_safe(strc);
}
*r_len_bytes = (strc - strc_orig);
return len;
}
/**
* \param start the string to measure the length.
* \param maxlen the string length (in bytes)
* \return the unicode length (not in bytes!)
*/
size_t BLI_strnlen_utf8(const char *start, const size_t maxlen)
size_t BLI_strnlen_utf8(const char *strc, const size_t maxlen)
{
const char *strc = start;
const char *strc_end = start + maxlen;
size_t len;
const char *strc_end = strc + maxlen;
for (len = 0; *strc && strc < strc_end; len++) {
strc += strlen_utf8_char(strc);
strc += BLI_str_utf8_size_safe(strc);
}
return len;
@ -296,13 +315,16 @@ size_t BLI_strnlen_utf8(const char *start, const size_t maxlen)
size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, const char *__restrict src_c, const size_t maxncpy)
{
const size_t maxlen = maxncpy - 1;
size_t len = 0;
if (dst_w == NULL || src_c == NULL) {
return 0;
}
BLI_assert(maxncpy != 0);
while (*src_c && len < maxncpy) {
#ifdef DEBUG_STRSIZE
memset(dst_w, 0xff, sizeof(*dst_w) * maxncpy);
#endif
while (*src_c && len != maxlen) {
size_t step = 0;
unsigned int unicode = BLI_str_utf8_as_unicode_and_size(src_c, &step);
if (unicode != BLI_UTF8_ERR) {
@ -316,6 +338,9 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, const char *__rest
dst_w++;
len++;
}
*dst_w = 0;
return len;
}

@ -354,7 +354,7 @@ static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me)
ma = NULL;
for (b = 0; ma && b < MAX_MTEX; b++)
if (ma->mtex && ma->mtex[b] && ma->mtex[b]->mapto & MAP_ALPHA)
if (ma->mtex[b] && ma->mtex[b]->mapto & MAP_ALPHA)
texalpha = 1;
}
else {

@ -1642,13 +1642,6 @@ static void write_mballs(WriteData *wd, ListBase *idbase)
}
}
static int amount_of_chars(char *str)
{
// Since the data is saved as UTF-8 to the cu->str
// The cu->len is not same as the strlen(cu->str)
return strlen(str);
}
static void write_curves(WriteData *wd, ListBase *idbase)
{
Curve *cu;
@ -1666,8 +1659,12 @@ static void write_curves(WriteData *wd, ListBase *idbase)
if (cu->adt) write_animdata(wd, cu->adt);
if (cu->vfont) {
writedata(wd, DATA, amount_of_chars(cu->str)+1, cu->str);
writestruct(wd, DATA, "CharInfo", cu->len+1, cu->strinfo);
/* TODO, sort out 'cu->len', in editmode its character, object mode its bytes */
int len_bytes;
int len_chars = BLI_strlen_utf8_ex(cu->str, &len_bytes);
writedata(wd, DATA, len_bytes + 1, cu->str);
writestruct(wd, DATA, "CharInfo", len_chars + 1, cu->strinfo);
writestruct(wd, DATA, "TextBox", cu->totbox, cu->tb);
}
else {

@ -803,50 +803,65 @@ static void bm_face_attrs_copy(BMesh *source_mesh, BMesh *target_mesh,
}
/* BMESH_TODO: Special handling for hide flags? */
/* BMESH_TODO: swap src/dst args, everywhere else in bmesh does other way round */
/**
* Copies attributes, e.g. customdata, header flags, etc, from one element
* to another of the same type.
*/
void BM_elem_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const void *source, void *target)
void BM_elem_attrs_copy_ex(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v,
const char hflag_mask)
{
const BMHeader *sheader = source;
BMHeader *theader = target;
const BMHeader *ele_src = ele_src_v;
BMHeader *ele_dst = ele_dst_v;
BLI_assert(sheader->htype == theader->htype);
BLI_assert(ele_src->htype == ele_dst->htype);
if (sheader->htype != theader->htype) {
if (ele_src->htype != ele_dst->htype) {
BLI_assert(!"type mismatch");
return;
}
/* First we copy select */
if (BM_elem_flag_test((BMElem *)sheader, BM_ELEM_SELECT)) {
BM_elem_select_set(target_mesh, (BMElem *)target, true);
if ((hflag_mask & BM_ELEM_SELECT) == 0) {
/* First we copy select */
if (BM_elem_flag_test((BMElem *)ele_src, BM_ELEM_SELECT)) {
BM_elem_select_set(bm_dst, (BMElem *)ele_dst, true);
}
}
/* Now we copy flags */
theader->hflag = sheader->hflag;
if (hflag_mask == 0) {
ele_dst->hflag = ele_src->hflag;
}
else {
ele_dst->hflag = ((ele_dst->hflag & hflag_mask) | (ele_src->hflag & ~hflag_mask));
}
/* Copy specific attributes */
switch (theader->htype) {
switch (ele_dst->htype) {
case BM_VERT:
bm_vert_attrs_copy(source_mesh, target_mesh, (const BMVert *)source, (BMVert *)target);
bm_vert_attrs_copy(bm_src, bm_dst, (const BMVert *)ele_src, (BMVert *)ele_dst);
break;
case BM_EDGE:
bm_edge_attrs_copy(source_mesh, target_mesh, (const BMEdge *)source, (BMEdge *)target);
bm_edge_attrs_copy(bm_src, bm_dst, (const BMEdge *)ele_src, (BMEdge *)ele_dst);
break;
case BM_LOOP:
bm_loop_attrs_copy(source_mesh, target_mesh, (const BMLoop *)source, (BMLoop *)target);
bm_loop_attrs_copy(bm_src, bm_dst, (const BMLoop *)ele_src, (BMLoop *)ele_dst);
break;
case BM_FACE:
bm_face_attrs_copy(source_mesh, target_mesh, (const BMFace *)source, (BMFace *)target);
bm_face_attrs_copy(bm_src, bm_dst, (const BMFace *)ele_src, (BMFace *)ele_dst);
break;
default:
BLI_assert(0);
}
}
void BM_elem_attrs_copy(BMesh *bm_src, BMesh *bm_dst, const void *ele_src, void *ele_dst)
{
/* BMESH_TODO, default 'use_flags' to false */
BM_elem_attrs_copy_ex(bm_src, bm_dst, ele_src, ele_dst, 0);
}
/* helper function for 'BM_mesh_copy' */
static BMFace *bm_mesh_copy_new_face(BMesh *bm_new, BMesh *bm_old,
BMVert **vtable, BMEdge **etable,
@ -890,6 +905,24 @@ static BMFace *bm_mesh_copy_new_face(BMesh *bm_new, BMesh *bm_old,
return f_new;
}
void BM_mesh_copy_init_customdata(BMesh *bm_dst, BMesh *bm_src, const BMAllocTemplate *allocsize)
{
if (allocsize == NULL) {
allocsize = &bm_mesh_allocsize_default;
}
CustomData_copy(&bm_src->vdata, &bm_dst->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
CustomData_copy(&bm_src->edata, &bm_dst->edata, CD_MASK_BMESH, CD_CALLOC, 0);
CustomData_copy(&bm_src->ldata, &bm_dst->ldata, CD_MASK_BMESH, CD_CALLOC, 0);
CustomData_copy(&bm_src->pdata, &bm_dst->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
CustomData_bmesh_init_pool(&bm_dst->vdata, allocsize->totvert, BM_VERT);
CustomData_bmesh_init_pool(&bm_dst->edata, allocsize->totedge, BM_EDGE);
CustomData_bmesh_init_pool(&bm_dst->ldata, allocsize->totloop, BM_LOOP);
CustomData_bmesh_init_pool(&bm_dst->pdata, allocsize->totface, BM_FACE);
}
BMesh *BM_mesh_copy(BMesh *bm_old)
{
BMesh *bm_new;
@ -908,15 +941,7 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
/* allocate a bmesh */
bm_new = BM_mesh_create(&allocsize);
CustomData_copy(&bm_old->vdata, &bm_new->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
CustomData_copy(&bm_old->edata, &bm_new->edata, CD_MASK_BMESH, CD_CALLOC, 0);
CustomData_copy(&bm_old->ldata, &bm_new->ldata, CD_MASK_BMESH, CD_CALLOC, 0);
CustomData_copy(&bm_old->pdata, &bm_new->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
CustomData_bmesh_init_pool(&bm_new->vdata, allocsize.totvert, BM_VERT);
CustomData_bmesh_init_pool(&bm_new->edata, allocsize.totedge, BM_EDGE);
CustomData_bmesh_init_pool(&bm_new->ldata, allocsize.totloop, BM_LOOP);
CustomData_bmesh_init_pool(&bm_new->pdata, allocsize.totface, BM_FACE);
BM_mesh_copy_init_customdata(bm_new, bm_old, &allocsize);
vtable = MEM_mallocN(sizeof(BMVert *) * bm_old->totvert, "BM_mesh_copy vtable");
etable = MEM_mallocN(sizeof(BMEdge *) * bm_old->totedge, "BM_mesh_copy etable");

@ -27,6 +27,8 @@
* \ingroup bmesh
*/
struct BMAllocTemplate;
BMFace *BM_face_create_quad_tri_v(BMesh *bm,
BMVert **verts, int len,
const BMFace *example, const bool no_double);
@ -48,8 +50,11 @@ void BMO_remove_tagged_verts(BMesh *bm, const short oflag);
void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type);
void BM_elem_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const void *source, void *target);
void BM_elem_attrs_copy_ex(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v,
const char hflag_mask);
void BM_elem_attrs_copy(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v);
void BM_mesh_copy_init_customdata(BMesh *bm_dst, BMesh *bm_src, const struct BMAllocTemplate *allocsize);
BMesh *BM_mesh_copy(BMesh *bm_old);
char BM_face_flag_from_mflag(const char mflag);

@ -210,7 +210,7 @@ static BMLoop *bm_face_boundary_add(BMesh *bm, BMFace *f, BMVert *startv, BMEdge
return l;
}
BMFace *BM_face_copy(BMesh *bm, BMFace *f,
BMFace *BM_face_copy(BMesh *bm_dst, BMesh *bm_src, BMFace *f,
const bool copy_verts, const bool copy_edges)
{
BMVert **verts = BLI_array_alloca(verts, f->len);
@ -221,11 +221,13 @@ BMFace *BM_face_copy(BMesh *bm, BMFace *f,
BMFace *f_copy;
int i;
BLI_assert((bm_dst == bm_src) || (copy_verts && copy_edges));
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
i = 0;
do {
if (copy_verts) {
verts[i] = BM_vert_create(bm, l_iter->v->co, l_iter->v, 0);
verts[i] = BM_vert_create(bm_dst, l_iter->v->co, l_iter->v, 0);
}
else {
verts[i] = l_iter->v;
@ -248,7 +250,7 @@ BMFace *BM_face_copy(BMesh *bm, BMFace *f,
v1 = verts[(i + 1) % f->len];
}
edges[i] = BM_edge_create(bm, v1, v2, l_iter->e, 0);
edges[i] = BM_edge_create(bm_dst, v1, v2, l_iter->e, 0);
}
else {
edges[i] = l_iter->e;
@ -256,14 +258,14 @@ BMFace *BM_face_copy(BMesh *bm, BMFace *f,
i++;
} while ((l_iter = l_iter->next) != l_first);
f_copy = BM_face_create(bm, verts, edges, f->len, BM_CREATE_SKIP_CD);
f_copy = BM_face_create(bm_dst, verts, edges, f->len, BM_CREATE_SKIP_CD);
BM_elem_attrs_copy(bm, bm, f, f_copy);
BM_elem_attrs_copy(bm_src, bm_dst, f, f_copy);
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
l_copy = BM_FACE_FIRST_LOOP(f_copy);
do {
BM_elem_attrs_copy(bm, bm, l_iter, l_copy);
BM_elem_attrs_copy(bm_src, bm_dst, l_iter, l_copy);
l_copy = l_copy->next;
} while ((l_iter = l_iter->next) != l_first);

@ -27,7 +27,7 @@
* \ingroup bmesh
*/
BMFace *BM_face_copy(BMesh *bm, BMFace *f,
BMFace *BM_face_copy(BMesh *bm_dst, BMesh *bm_src, BMFace *f,
const bool copy_verts, const bool copy_edges);
typedef enum eBMCreateFlag {

@ -429,32 +429,32 @@ static void bm_loop_flip_disp(float source_axis_x[3], float source_axis_y[3],
disp[1] = (mat[0][0] * b[1] - b[0] * mat[1][0]) / d;
}
static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source)
static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *l_dst, BMFace *f_src)
{
MDisps *mdisps;
const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
MDisps *md_dst;
float d, v1[3], v2[3], v3[3], v4[3] = {0.0f, 0.0f, 0.0f}, e1[3], e2[3];
int ix, res;
float axis_x[3], axis_y[3];
if (cd_loop_mdisp_offset == -1)
return;
/* ignore 2-edged faces */
if (UNLIKELY(target->f->len < 3))
if (UNLIKELY(l_dst->f->len < 3))
return;
md_dst = BM_ELEM_CD_GET_VOID_P(l_dst, cd_loop_mdisp_offset);
compute_mdisp_quad(l_dst, v1, v2, v3, v4, e1, e2);
if (!CustomData_has_layer(&bm->ldata, CD_MDISPS))
return;
mdisps = CustomData_bmesh_get(&bm->ldata, target->head.data, CD_MDISPS);
compute_mdisp_quad(target, v1, v2, v3, v4, e1, e2);
/* if no disps data allocate a new grid, the size of the first grid in source. */
if (!mdisps->totdisp) {
MDisps *md2 = CustomData_bmesh_get(&bm->ldata, BM_FACE_FIRST_LOOP(source)->head.data, CD_MDISPS);
/* if no disps data allocate a new grid, the size of the first grid in f_src. */
if (!md_dst->totdisp) {
MDisps *md_src = BM_ELEM_CD_GET_VOID_P(BM_FACE_FIRST_LOOP(f_src), cd_loop_mdisp_offset);
mdisps->totdisp = md2->totdisp;
mdisps->level = md2->level;
if (mdisps->totdisp) {
mdisps->disps = MEM_callocN(sizeof(float) * 3 * mdisps->totdisp,
"mdisp->disps in bmesh_loop_intern_mdisps");
md_dst->totdisp = md_src->totdisp;
md_dst->level = md_src->level;
if (md_dst->totdisp) {
md_dst->disps = MEM_callocN(sizeof(float) * 3 * md_dst->totdisp, __func__);
}
else {
return;
@ -463,7 +463,7 @@ static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source)
mdisp_axis_from_quad(v1, v2, v3, v4, axis_x, axis_y);
res = (int)sqrt(mdisps->totdisp);
res = (int)sqrt(md_dst->totdisp);
d = 1.0f / (float)(res - 1);
#pragma omp parallel for if (res > 3)
for (ix = 0; ix < res; ix++) {
@ -487,18 +487,17 @@ static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source)
mul_v3_fl(co, x);
add_v3_v3(co, co1);
l_iter = l_first = BM_FACE_FIRST_LOOP(source);
l_iter = l_first = BM_FACE_FIRST_LOOP(f_src);
do {
float x2, y2;
MDisps *md1, *md2;
MDisps *md_src;
float src_axis_x[3], src_axis_y[3];
md1 = CustomData_bmesh_get(&bm->ldata, target->head.data, CD_MDISPS);
md2 = CustomData_bmesh_get(&bm->ldata, l_iter->head.data, CD_MDISPS);
md_src = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_mdisp_offset);
if (mdisp_in_mdispquad(target, l_iter, co, &x2, &y2, res, src_axis_x, src_axis_y)) {
old_mdisps_bilinear(md1->disps[iy * res + ix], md2->disps, res, (float)x2, (float)y2);
bm_loop_flip_disp(src_axis_x, src_axis_y, axis_x, axis_y, md1->disps[iy * res + ix]);
if (mdisp_in_mdispquad(l_dst, l_iter, co, &x2, &y2, res, src_axis_x, src_axis_y)) {
old_mdisps_bilinear(md_dst->disps[iy * res + ix], md_src->disps, res, (float)x2, (float)y2);
bm_loop_flip_disp(src_axis_x, src_axis_y, axis_x, axis_y, md_dst->disps[iy * res + ix]);
break;
}
@ -513,16 +512,17 @@ static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source)
*/
void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
{
const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
BMLoop *l;
BMIter liter;
if (!CustomData_has_layer(&bm->ldata, CD_MDISPS))
if (cd_loop_mdisp_offset == -1)
return;
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
MDisps *mdp = CustomData_bmesh_get(&bm->ldata, l->prev->head.data, CD_MDISPS);
MDisps *mdl = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MDISPS);
MDisps *mdn = CustomData_bmesh_get(&bm->ldata, l->next->head.data, CD_MDISPS);
MDisps *mdp = BM_ELEM_CD_GET_VOID_P(l->prev, cd_loop_mdisp_offset);
MDisps *mdl = BM_ELEM_CD_GET_VOID_P(l, cd_loop_mdisp_offset);
MDisps *mdn = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_mdisp_offset);
float co1[3];
int sides;
int y;
@ -551,7 +551,7 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
}
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
MDisps *mdl1 = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MDISPS);
MDisps *mdl1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_mdisp_offset);
MDisps *mdl2;
float co1[3], co2[3], co[3];
int sides;
@ -575,9 +575,9 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
continue;
if (l->radial_next->v == l->v)
mdl2 = CustomData_bmesh_get(&bm->ldata, l->radial_next->head.data, CD_MDISPS);
mdl2 = BM_ELEM_CD_GET_VOID_P(l->radial_next, cd_loop_mdisp_offset);
else
mdl2 = CustomData_bmesh_get(&bm->ldata, l->radial_next->next->head.data, CD_MDISPS);
mdl2 = BM_ELEM_CD_GET_VOID_P(l->radial_next->next, cd_loop_mdisp_offset);
sides = (int)sqrt(mdl1->totdisp);
for (y = 0; y < sides; y++) {
@ -640,8 +640,6 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source,
/* convert the 3d coords into 2d for projection */
axis_dominant_v3_to_m3(axis_mat, source->no);
BM_elem_attrs_copy(bm, bm, source, target->f);
i = 0;
l_iter = l_first = BM_FACE_FIRST_LOOP(source);
do {
@ -663,9 +661,7 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source,
}
if (do_multires) {
if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
bm_loop_interp_mdisps(bm, target, source);
}
bm_loop_interp_mdisps(bm, target, source);
}
}

@ -240,7 +240,7 @@ void BM_mesh_clear(BMesh *bm)
bm_mempool_init(bm, &bm_mesh_allocsize_default);
bm->stackdepth = 1;
bm->totflags = 1;
bm->totflags = 0;
CustomData_reset(&bm->vdata);
CustomData_reset(&bm->edata);

@ -345,7 +345,7 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l
/* do we have a multires layer? */
if (has_mdisp) {
f_tmp = BM_face_copy(bm, f, false, false);
f_tmp = BM_face_copy(bm, bm, f, false, false);
}
#ifdef USE_BMESH_HOLES
@ -414,7 +414,7 @@ BMFace *BM_face_split_n(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, float cos[
BLI_assert(v1 != v2);
f_tmp = BM_face_copy(bm, f, true, true);
f_tmp = BM_face_copy(bm, bm, f, true, true);
if (!r_l)
r_l = &l_dummy;
@ -662,7 +662,7 @@ BMVert *BM_edge_split(BMesh *bm, BMEdge *e, BMVert *v, BMEdge **r_e, float perce
/* flag existing faces so we can differentiate oldfaces from new faces */
for (i = 0; i < BLI_array_count(oldfaces); i++) {
BM_ELEM_API_FLAG_ENABLE(oldfaces[i], _FLAG_OVERLAP);
oldfaces[i] = BM_face_copy(bm, oldfaces[i], true, true);
oldfaces[i] = BM_face_copy(bm, bm, oldfaces[i], true, true);
BM_ELEM_API_FLAG_DISABLE(oldfaces[i], _FLAG_OVERLAP);
}
}

@ -1248,7 +1248,7 @@ static void bmo_flag_layer_free(BMesh *bm)
/* now go through and memcpy all the flag */
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) {
void *oldflags = ele->oflags;
ele->oflags = BLI_mempool_calloc(newpool);
ele->oflags = BLI_mempool_alloc(newpool);
memcpy(ele->oflags, oldflags, new_totflags_size);
BM_elem_index_set(ele, i); /* set_inline */
BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele);
@ -1264,7 +1264,7 @@ static void bmo_flag_layer_free(BMesh *bm)
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) {
void *oldflags = ele->oflags;
ele->oflags = BLI_mempool_calloc(newpool);
ele->oflags = BLI_mempool_alloc(newpool);
memcpy(ele->oflags, oldflags, new_totflags_size);
BM_elem_index_set(ele, i); /* set_inline */
BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele);
@ -1280,7 +1280,7 @@ static void bmo_flag_layer_free(BMesh *bm)
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) {
void *oldflags = ele->oflags;
ele->oflags = BLI_mempool_calloc(newpool);
ele->oflags = BLI_mempool_alloc(newpool);
memcpy(ele->oflags, oldflags, new_totflags_size);
BM_elem_index_set(ele, i); /* set_inline */
BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele);

@ -144,11 +144,13 @@ static void bridge_loop_pair(BMesh *bm,
struct BMEdgeLoopStore *el_store_b,
const bool use_merge, const float merge_factor)
{
const float eps = 0.00001f;
LinkData *el_a_first, *el_b_first;
const bool is_closed = BM_edgeloop_is_closed(el_store_a) && BM_edgeloop_is_closed(el_store_b);
int el_store_a_len, el_store_b_len;
bool el_store_b_free = false;
float el_dir[3];
float dot_a, dot_b;
const bool use_edgeout = true;
el_store_a_len = BM_edgeloop_length_get((struct BMEdgeLoopStore *)el_store_a);
@ -160,7 +162,7 @@ static void bridge_loop_pair(BMesh *bm,
}
if (use_merge) {
BLI_assert((el_store_a_len == el_store_a_len));
BLI_assert((el_store_a_len == el_store_b_len));
}
if (el_store_a_len != el_store_b_len) {
@ -202,9 +204,22 @@ static void bridge_loop_pair(BMesh *bm,
BM_edgeloop_calc_normal_aligned(bm, el_store_b, no);
}
if ((dot_v3v3(BM_edgeloop_normal_get(el_store_a), el_dir) < 0.0f) !=
(dot_v3v3(BM_edgeloop_normal_get(el_store_b), el_dir) < 0.0f))
dot_a = dot_v3v3(BM_edgeloop_normal_get(el_store_a), el_dir);
dot_b = dot_v3v3(BM_edgeloop_normal_get(el_store_b), el_dir);
if (UNLIKELY((len_squared_v3(el_dir) < eps) ||
((fabsf(dot_a) < eps) && (fabsf(dot_b) < eps))))
{
/* in this case there is no depth between the two loops,
* eg: 2x 2d circles, one scaled smaller,
* in this case 'el_dir' cant be used, just ensure we have matching flipping. */
if (dot_v3v3(BM_edgeloop_normal_get(el_store_a),
BM_edgeloop_normal_get(el_store_b)) < 0.0f)
{
BM_edgeloop_flip(bm, el_store_b);
}
}
else if ((dot_a < 0.0f) != (dot_b < 0.0f)) {
BM_edgeloop_flip(bm, el_store_b);
}

@ -381,7 +381,7 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
pc.v_b = ((BMVert **)op_verts_slot->data.p)[1];
/* fail! */
if (!(pc.v_a && pc.v_a)) {
if (!(pc.v_a && pc.v_b)) {
return;
}

@ -56,7 +56,7 @@ static bool bmo_recalc_normal_edge_filter_cb(BMEdge *e, void *UNUSED(user_data))
*/
static void bmo_recalc_face_normals_array(BMesh *bm, BMFace **faces, const int faces_len, const short oflag)
{
float cent[3];
float cent[3], tvec[3];
float (*faces_center)[3] = MEM_mallocN(sizeof(*faces_center) * faces_len, __func__);
const float cent_fac = 1.0f / (float)faces_len;
int i, f_start_index;
@ -91,7 +91,8 @@ static void bmo_recalc_face_normals_array(BMesh *bm, BMFace **faces, const int f
}
/* make sure the starting face has the correct winding */
if (dot_v3v3(faces_center[f_start_index], faces[f_start_index]->no) < 0.0f) {
sub_v3_v3v3(tvec, faces_center[f_start_index], cent);
if (dot_v3v3(tvec, faces[f_start_index]->no) < 0.0f) {
BMO_elem_flag_enable(bm, faces[f_start_index], FACE_FLIP);
}

@ -893,7 +893,7 @@ static void bm_edgering_pair_order(BMesh *bm,
/* before going much further, get ourselves in order
* - align loops (not strictly necessary but handy)
* - ensure winding is set for both loops */
if (BM_edgeloop_is_closed(el_store_a) && BM_edgeloop_is_closed(el_store_a)) {
if (BM_edgeloop_is_closed(el_store_a) && BM_edgeloop_is_closed(el_store_b)) {
BMIter eiter;
BMEdge *e;
BMVert *v_other;

@ -1941,26 +1941,35 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
int i, found_shared_face, ccw_test_sum;
int nsel = 0;
int ntot = 0;
int fcnt;
/* Gather input selected edges.
* Only bevel selected edges that have exactly two incident faces.
* Want edges to be ordered so that they share faces.
* There may be one or more chains of shared faces broken by
* gaps where there are no faces.
* TODO: make following work when more than one gap.
*/
if (bp->vertex_only)
first_bme = v->e;
else
first_bme = NULL;
first_bme = NULL;
BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) {
fcnt = BM_edge_face_count(bme);
if (BM_elem_flag_test(bme, BM_ELEM_TAG) && !bp->vertex_only) {
BLI_assert(BM_edge_is_manifold(bme));
BLI_assert(fcnt == 2);
nsel++;
if (!first_bme)
first_bme = bme;
}
if (fcnt == 1) {
/* good to start face chain from this edge */
first_bme = bme;
}
ntot++;
BM_BEVEL_EDGE_TAG_DISABLE(bme);
}
if (!first_bme)
first_bme = v->e;
if ((nsel == 0 && !bp->vertex_only) || (ntot < 3 && bp->vertex_only)) {
/* signal this vert isn't being beveled */

@ -1687,6 +1687,18 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW::
}
}
static void report_class_type_unsupported(const char *path,
const COLLADAFW::AnimationList::AnimationClass animclass,
const COLLADAFW::Transformation::TransformationType type)
{
if (animclass == COLLADAFW::AnimationList::UNKNOWN_CLASS) {
fprintf(stderr, "%s: UNKNOWN animation class\n", path);
}
else {
fprintf(stderr, "%s: animation class %d is not supported yet for transformation type %d\n", path, animclass, type);
}
}
// return true to indicate that mat contains a sane value
bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float mat[4][4], float fra, const char *node_id)
{
@ -1741,11 +1753,6 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
break;
}
if (animclass == COLLADAFW::AnimationList::UNKNOWN_CLASS) {
fprintf(stderr, "%s: UNKNOWN animation class\n", path);
//continue;
}
if (type == COLLADAFW::Transformation::ROTATE) {
if (curves.size() != 1) {
fprintf(stderr, "expected 1 curve, got %d\n", (int)curves.size());
@ -1754,7 +1761,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
// TODO support other animclasses
if (animclass != COLLADAFW::AnimationList::ANGLE) {
fprintf(stderr, "%s: animation class %d is not supported yet\n", path, animclass);
report_class_type_unsupported(path, animclass, type);
return false;
}
@ -1793,7 +1800,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
vec[2] = evaluate_fcurve(curves[2], fra);
break;
default:
fprintf(stderr, "%s: animation class %d is not supported yet\n", path, animclass);
report_class_type_unsupported(path, animclass, type);
break;
}
}

@ -166,7 +166,7 @@ void ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBo
}
bone->length = len_v3v3(bone->head, bone->tail);
joint_by_uid[node->getUniqueId()] = node;
finished_joints.push_back(node);
}
@ -517,16 +517,11 @@ void ArmatureImporter::set_pose(Object *ob_arm, COLLADAFW::Node *root_node, con
// root - if this joint is the top joint in hierarchy, if a joint
// is a child of a node (not joint), root should be true since
// this is where we build armature bones from
void ArmatureImporter::add_joint(COLLADAFW::Node *node, bool root, Object *parent, Scene *sce)
void ArmatureImporter::add_root_joint(COLLADAFW::Node *node, Object *parent)
{
joint_by_uid[node->getUniqueId()] = node;
if (root) {
root_joints.push_back(node);
if (parent) {
joint_parent_map[node->getUniqueId()] = parent;
}
root_joints.push_back(node);
if (parent) {
joint_parent_map[node->getUniqueId()] = parent;
}
}

@ -140,11 +140,7 @@ public:
ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, Scene *sce);
~ArmatureImporter();
void add_joint(COLLADAFW::Node *node, bool root, Object *parent, Scene *sce);
#if 0
void add_root_joint(COLLADAFW::Node *node);
#endif
void add_root_joint(COLLADAFW::Node *node, Object *parent);
// here we add bones to armatures, having armatures previously created in write_controller
void make_armatures(bContext *C);

@ -311,11 +311,6 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW
#endif
unsigned int i;
//for (i = 0; i < 4; i++)
// ob =
anim_importer.translate_Animations(node, root_map, object_map, FW_object_map);
if (node->getType() == COLLADAFW::Node::JOINT && par == NULL) {
// For Skeletons without root node we have to simulate the
// root node here and recursively enter the same function
@ -323,6 +318,7 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW
translate_anim_recursive(node, node, parob);
}
else {
anim_importer.translate_Animations(node, root_map, object_map, FW_object_map);
COLLADAFW::NodePointerArray &children = node->getChildNodes();
for (i = 0; i < children.getCount(); i++) {
translate_anim_recursive(children[i], node, NULL);
@ -480,7 +476,9 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
object_map.insert(std::pair<COLLADAFW::UniqueId, Object *>(node->getUniqueId(), par));
node_map[node->getUniqueId()] = node;
}
armature_importer.add_joint(node, parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT, par, sce);
if (parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT) {
armature_importer.add_root_joint(node, par);
}
if (parent_node == NULL) {
// for skeletons without root node all has been done above.
@ -601,11 +599,16 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
anim_importer.read_node_transform(node, ob); // overwrites location set earlier
if (!is_joint) {
// if par was given make this object child of the previous
if (par && ob)
bc_set_parent(ob, par, mContext);
if (par && ob) {
ob->parent = par;
ob->partype = PAROBJECT;
ob->parsubstr[0] = 0;
//bc_set_parent(ob, par, mContext, false);
}
}
}
// if node has child nodes write them
COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes();
@ -624,7 +627,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
}
/** When this method is called, the writer must write the entire visual scene.
* \return The writer should return true, if writing succeeded, false otherwise.*/
* Return The writer should return true, if writing succeeded, false otherwise. */
bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScene)
{
if (mImportStage != General)

@ -97,40 +97,28 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob, B
add_transform(node, loc, rot, scale);
#endif
UnitConverter converter;
/* Using parentinv should allow use of existing curves */
if (ob->parent) {
// If parentinv is identity don't add it.
bool add_parinv = false;
double d_obmat[4][4];
float f_obmat[4][4];
for (int i = 0; i < 16; ++i) {
float f = (i % 4 == i / 4) ? 1.0f : 0.0f;
add_parinv |= (ob->parentinv[i % 4][i / 4] != f);
}
if (add_parinv) {
double dmat[4][4];
converter.mat4_to_dae_double(dmat, ob->parentinv);
node.addMatrix("parentinverse", dmat);
}
}
double d_obmat[4][4];
converter.mat4_to_dae_double(d_obmat, ob->obmat);
/* Export the local Matrix (relative to the object parent) */
BKE_object_matrix_local_get(ob, f_obmat);
converter.mat4_to_dae_double(d_obmat, f_obmat);
switch (transformation_type) {
case BC_TRANSFORMATION_TYPE_MATRIX : {
node.addMatrix("transform",d_obmat);
break;
}
case BC_TRANSFORMATION_TYPE_TRANSROTLOC: {
add_transform(node, ob->loc, ob->rot, ob->size);
break;
}
case BC_TRANSFORMATION_TYPE_BOTH : {
node.addMatrix("transform",d_obmat);
add_transform(node, ob->loc, ob->rot, ob->size);
/* intentional fall-through */
}
case BC_TRANSFORMATION_TYPE_TRANSROTLOC: {
float loc[3], rot[3], scale[3];
TransformBase::decompose(f_obmat, loc, rot, NULL, scale);
add_transform(node, loc, rot, scale);
break;
}
}

@ -47,7 +47,7 @@ void ChromaMatteNode::convertToOperations(ExecutionSystem *graph, CompositorCont
operation->setSettings((NodeChroma *)editorsnode->storage);
inputSocketImage->relinkConnections(operationRGBToYCC_Image->getInputSocket(0), 0, graph);
inputSocketKey->relinkConnections(operationRGBToYCC_Key->getInputSocket(0), 0, graph);
inputSocketKey->relinkConnections(operationRGBToYCC_Key->getInputSocket(0), 1, graph);
addLink(graph, operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0));
addLink(graph, operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1));

@ -34,11 +34,14 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext
bNode *editorNode = this->getbNode();
Tex *texture = (Tex *)editorNode->id;
TextureOperation *operation = new TextureOperation();
const ColorManagedDisplaySettings *displaySettings = context->getDisplaySettings();
bool sceneColorManage = strcmp(displaySettings->display_device, "None") != 0;
this->getOutputSocket(1)->relinkConnections(operation->getOutputSocket());
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system);
operation->setTexture(texture);
operation->setRenderData(context->getRenderData());
operation->setSceneColorManage(sceneColorManage);
system->addOperation(operation);
addPreviewOperation(system, context, operation->getOutputSocket());
@ -49,6 +52,7 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext
addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(1));
alphaOperation->setTexture(texture);
alphaOperation->setRenderData(context->getRenderData());
alphaOperation->setSceneColorManage(sceneColorManage);
system->addOperation(alphaOperation);
}
}

@ -34,7 +34,7 @@
void ZCombineNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
{
if (context->getRenderData()->scemode & R_FULL_SAMPLE) {
if ((context->getRenderData()->scemode & R_FULL_SAMPLE) || this->getbNode()->custom2) {
if (this->getOutputSocket(0)->isConnected()) {
ZCombineOperation *operation = NULL;
if (this->getbNode()->custom1) {

@ -53,33 +53,34 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect)
pixels++;
switch (this->m_setting) {
case 1:
case 1: /* rgb combined */
{
float value = rgb_to_bw(&buffer[offset]);
sum += (value - mean) * (value - mean);
break;
}
case 2:
case 2: /* red */
{
float value = buffer[offset];
sum += value;
sum += (value - mean) * (value - mean);
break;
}
case 3:
case 3: /* green */
{
float value = buffer[offset + 1];
sum += value;
sum += (value - mean) * (value - mean);
break;
}
case 4:
case 4: /* blue */
{
float value = buffer[offset + 2];
sum += value;
sum += (value - mean) * (value - mean);
break;
}
case 5:
case 5: /* luminance */
{
float yuv[3];
rgb_to_yuv(buffer[offset], buffer[offset + 1], buffer[offset + 2], &yuv[0], &yuv[1], &yuv[2]);

@ -32,6 +32,7 @@
#include "DNA_movieclip_types.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
extern "C" {
#include "BLI_voronoi.h"
@ -76,7 +77,7 @@ public:
void deinitializeTileData(rcti *rect, void *data);
void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;}
void setTrackingObject(const char *object) {strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject));}
void setTrackingObject(const char *object) { BLI_strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject)); }
void setFramenumber(int framenumber) {this->m_framenumber = framenumber;}
void executePixel(float output[4], int x, int y, void *data);

Some files were not shown because too many files have changed in this diff Show More