[Bf-blender-cvs] [f35e9f047a0] blender2.8: Merge branch 'master' into blender2.8

Campbell Barton noreply at git.blender.org
Wed Sep 19 04:07:11 CEST 2018


Commit: f35e9f047a0381732a41ec331945b7a0654ee578
Author: Campbell Barton
Date:   Wed Sep 19 12:14:36 2018 +1000
Branches: blender2.8
https://developer.blender.org/rBf35e9f047a0381732a41ec331945b7a0654ee578

Merge branch 'master' into blender2.8

===================================================================



===================================================================

diff --cc source/blender/blenkernel/intern/icons.c
index 23cb6c71696,e49f24c8120..2a348751365
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@@ -557,18 -507,7 +557,18 @@@ static Icon *icon_create(int icon_id, i
  	new_icon->drawinfo = NULL;
  	new_icon->drawinfo_free = NULL;
  
- 	BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(icon_id), new_icon);
 -	BLI_ghash_insert(gIcons, POINTER_FROM_INT(id->icon_id), new_icon);
++	BLI_ghash_insert(gIcons, POINTER_FROM_INT(icon_id), new_icon);
 +
 +	return new_icon;
 +}
 +
 +static int icon_id_ensure_create_icon(struct ID *id)
 +{
 +	BLI_assert(BLI_thread_is_main());
 +
 +	Icon *icon = icon_create(id->icon_id, ICON_DATA_ID, id);
 +	icon->id_type = GS(id->name);
 +	icon->flag = ICON_FLAG_MANAGED;
  
  	return id->icon_id;
  }
@@@ -738,127 -649,21 +738,127 @@@ void BKE_icon_id_delete(struct ID *id
  /**
   * Remove icon and free data.
   */
 -void BKE_icon_delete(const int icon_id)
 +bool BKE_icon_delete(const int icon_id)
  {
 -	Icon *icon;
 +	if (icon_id == 0) {
 +		/* no icon defined for library object */
 +		return false;
 +	}
  
- 	Icon *icon = BLI_ghash_popkey(gIcons, SET_INT_IN_POINTER(icon_id), NULL);
 -	if (!icon_id) return;  /* no icon defined for library object */
++	Icon *icon = BLI_ghash_popkey(gIcons, POINTER_FROM_INT(icon_id), NULL);
 +	if (icon) {
 +		icon_free_data(icon_id, icon);
 +		icon_free(icon);
 +		return true;
 +	}
 +	else {
 +		return false;
 +	}
 +}
  
 -	icon = BLI_ghash_popkey(gIcons, POINTER_FROM_INT(icon_id), NULL);
 +bool BKE_icon_delete_unmanaged(const int icon_id)
 +{
 +	if (icon_id == 0) {
 +		/* no icon defined for library object */
 +		return false;
 +	}
  
- 	Icon *icon = BLI_ghash_popkey(gIcons, SET_INT_IN_POINTER(icon_id), NULL);
++	Icon *icon = BLI_ghash_popkey(gIcons, POINTER_FROM_INT(icon_id), NULL);
  	if (icon) {
 -		if (icon->id_type != 0) {
 -			((ID *)(icon->obj))->icon_id = 0;
 +		if (UNLIKELY(icon->flag & ICON_FLAG_MANAGED)) {
- 			BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(icon_id), icon);
++			BLI_ghash_insert(gIcons, POINTER_FROM_INT(icon_id), icon);
 +			return false;
  		}
  		else {
 -			((PreviewImage *)(icon->obj))->icon_id = 0;
 +			icon_free_data(icon_id, icon);
 +			icon_free(icon);
 +			return true;
  		}
 -		icon_free(icon);
  	}
 +	else {
 +		return false;
 +	}
 +}
 +
 +/* -------------------------------------------------------------------- */
 +/** \name Geometry Icon
 + * \{ */
 +
 +int BKE_icon_geom_ensure(struct Icon_Geom *geom)
 +{
 +	BLI_assert(BLI_thread_is_main());
 +
 +	if (geom->icon_id) {
 +		return geom->icon_id;
 +	}
 +
 +	geom->icon_id = get_next_free_id();
 +
 +	icon_create(geom->icon_id, ICON_DATA_GEOM, geom);
 +	/* Not managed for now, we may want this to be configurable per icon). */
 +
 +	return geom->icon_id;
 +}
 +
 +struct Icon_Geom *BKE_icon_geom_from_memory(const uchar *data, size_t data_len)
 +{
 +	BLI_assert(BLI_thread_is_main());
 +	if (data_len <= 8) {
 +		goto fail;
 +	}
 +	/* Skip the header. */
 +	data_len -= 8;
 +	const int div = 3 * 2 * 3;
 +	const int coords_len = data_len / div;
 +	if (coords_len * div != data_len) {
 +		goto fail;
 +	}
 +
 +	const uchar header[4] = {'V', 'C', 'O', 0};
 +	const uchar *p = data;
 +	if (memcmp(p, header, ARRAY_SIZE(header)) != 0) {
 +		goto fail;
 +	}
 +	p += 4;
 +
 +	struct Icon_Geom *geom = MEM_mallocN(sizeof(*geom), __func__);
 +	geom->coords_range[0] = (int)*p++;
 +	geom->coords_range[1] = (int)*p++;
 +	/* x, y ignored for now */
 +	p += 2;
 +
 +	geom->coords_len = coords_len;
 +	geom->coords = (const void *)p;
 +	geom->colors = (const void *)(p + (data_len / 3));
 +	geom->icon_id = 0;
 +	geom->mem = data;
 +	return geom;
 +
 +fail:
 +	MEM_freeN((void *)data);
 +	return NULL;
 +}
 +
 +struct Icon_Geom *BKE_icon_geom_from_file(const char *filename)
 +{
 +	BLI_assert(BLI_thread_is_main());
 +	size_t data_len;
 +	uchar *data = BLI_file_read_binary_as_mem(filename, 0, &data_len);
 +	if (data == NULL) {
 +		return NULL;
 +	}
 +	return BKE_icon_geom_from_memory(data, data_len);
 +}
 +
 +/** \} */
 +
 +/** \name Studio Light Icon
 + * \{ */
 +int BKE_icon_ensure_studio_light(struct StudioLight *sl, int id_type)
 +{
 +	int icon_id = get_next_free_id();
 +	Icon *icon = icon_create(icon_id, ICON_DATA_STUDIOLIGHT, sl);
 +	icon->id_type = id_type;
 +	return icon_id;
  }
 +/** \} */
diff --cc source/blender/blenkernel/intern/mesh_merge.c
index d49ca507e02,00000000000..5324c397ebf
mode 100644,000000..100644
--- a/source/blender/blenkernel/intern/mesh_merge.c
+++ b/source/blender/blenkernel/intern/mesh_merge.c
@@@ -1,685 -1,0 +1,685 @@@
 +/*
 + * ***** BEGIN GPL LICENSE BLOCK *****
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software Foundation,
 + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 + * All rights reserved.
 + *
 + * Contributor(s): Blender Foundation
 + *
 + * ***** END GPL LICENSE BLOCK *****
 + */
 +
 +/** \file blender/blenkernel/intern/mesh_merge.c
 + *  \ingroup bke
 + */
 +#include <string.h> // for memcpy
 +
 +#include "MEM_guardedalloc.h"
 +
 +#include "DNA_mesh_types.h"
 +#include "DNA_meshdata_types.h"
 +
 +#include "BLI_utildefines.h"
 +#include "BLI_utildefines_stack.h"
 +#include "BLI_edgehash.h"
 +#include "BLI_ghash.h"
 +
 +#include "BKE_customdata.h"
 +#include "BKE_library.h"
 +#include "BKE_mesh.h"
 +#include "BKE_mesh_mapping.h"
 +
 +
 +/**
 + * Poly compare with vtargetmap
 + * Function used by #BKE_mesh_merge_verts.
 + * The function compares poly_source after applying vtargetmap, with poly_target.
 + * The two polys are identical if they share the same vertices in the same order, or in reverse order,
 + * but starting position loopstart may be different.
 + * The function is called with direct_reverse=1 for same order (i.e. same normal),
 + * and may be called again with direct_reverse=-1 for reverse order.
 + * \return 1 if polys are identical,  0 if polys are different.
 + */
 +static int cddm_poly_compare(
 +        MLoop *mloop_array,
 +        MPoly *mpoly_source, MPoly *mpoly_target,
 +        const int *vtargetmap, const int direct_reverse)
 +{
 +	int vert_source, first_vert_source, vert_target;
 +	int i_loop_source;
 +	int i_loop_target, i_loop_target_start, i_loop_target_offset, i_loop_target_adjusted;
 +	bool compare_completed = false;
 +	bool same_loops = false;
 +
 +	MLoop *mloop_source, *mloop_target;
 +
 +	BLI_assert(direct_reverse == 1 || direct_reverse == -1);
 +
 +	i_loop_source = 0;
 +	mloop_source = mloop_array + mpoly_source->loopstart;
 +	vert_source = mloop_source->v;
 +
 +	if (vtargetmap[vert_source] != -1) {
 +		vert_source = vtargetmap[vert_source];
 +	}
 +	else {
 +		/* All source loop vertices should be mapped */
 +		BLI_assert(false);
 +	}
 +
 +	/* Find same vertex within mpoly_target's loops */
 +	mloop_target = mloop_array + mpoly_target->loopstart;
 +	for (i_loop_target = 0; i_loop_target < mpoly_target->totloop; i_loop_target++, mloop_target++) {
 +		if (mloop_target->v == vert_source) {
 +			break;
 +		}
 +	}
 +
 +	/* If same vertex not found, then polys cannot be equal */
 +	if (i_loop_target >= mpoly_target->totloop) {
 +		return false;
 +	}
 +
 +	/* Now mloop_source and m_loop_target have one identical vertex */
 +	/* mloop_source is at position 0, while m_loop_target has advanced to find identical vertex */
 +	/* Go around the loop and check that all vertices match in same order */
 +	/* Skipping source loops when consecutive source vertices are mapped to same target vertex */
 +
 +	i_loop_target_start = i_loop_target;
 +	i_loop_target_offset = 0;
 +	first_vert_source = vert_source;
 +
 +	compare_completed = false;
 +	same_loops = false;
 +
 +	while (!compare_completed) {
 +
 +		vert_target = mloop_target->v;
 +
 +		/* First advance i_loop_source, until it points to different vertex, after mapping applied */
 +		do {
 +			i_loop_source++;
 +
 +			if (i_loop_source == mpoly_source->totloop) {
 +				/* End of loops for source, must match end of loop for target.  */
 +				if (i_loop_target_offset == mpoly_target->totloop - 1) {
 +					compare_completed = true;
 +					same_loops = true;
 +					break;  /* Polys are identical */
 +				}
 +				else {
 +					compare_completed = true;
 +					same_loops = false;
 +					break;  /* Polys are different */
 +				}
 +			}
 +
 +			mloop_source++;
 +			vert_source = mloop_source->v;
 +
 +			if (vtargetmap[vert_source] != -1) {
 +				vert_source = vtargetmap[vert_source];
 +			}
 +			else {
 +				/* All source loop vertices should be mapped */
 +				BLI_assert(false);
 +			}
 +
 +		} while (vert_source == vert_target);
 +
 +		if (compare_completed) {
 +			break;
 +		}
 +
 +		/* Now advance i_loop_target as well */
 +		i_loop_target_offset++;
 +
 +		if (i_loop_target_offset == mpoly_target->totloop) {
 +			/* End of loops for target only, that means no match */
 +			/* except if all remaining source vertices are mapped to first target */
 +			for (; i_loop_source < mpoly_source->totloop; i_loop_source++, mloop_source++) {
 +				vert_source = vtargetmap[mloop_source->v];
 +				if (vert_source != first_vert_source) {
 +					compare_completed = true;
 +					same_loops = false;
 +					break;
 +				}
 +			}
 +			if (!compare_completed) {
 +				same_loops = true;
 +			}
 +			break;
 +		}
 +
 +		/* Adjust i_loop_target for cycling around and for direct/reverse order defined by delta = +1 or -1 */
 +		i_loop_target_adjusted = (i_loop_target_start + direct_reverse * i_loop_target_offset) % mpoly_target->totloop;
 +		if (i_loop_target_adjusted < 0) {
 +			i_l

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list