[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59749] trunk/blender/source/blender: Ack. .. Followup to r59743: in fact, bitflags groups are not always wanted/ needed, thanks to Campell for notifying me about this!
Bastien Montagne
montagne29 at wanadoo.fr
Mon Sep 2 20:33:07 CEST 2013
Revision: 59749
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59749
Author: mont29
Date: 2013-09-02 18:33:06 +0000 (Mon, 02 Sep 2013)
Log Message:
-----------
Ack... Followup to r59743: in fact, bitflags groups are not always wanted/needed, thanks to Campell for notifying me about this!
So now, their generation is controlled by a flag, else previous "simple values" group ids are generated (one per poly region, no need here to reduce the number of used IDs!).
Will update obj exporter too.
Revision Links:
--------------
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59743
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_mesh.h
trunk/blender/source/blender/blenkernel/intern/mesh.c
trunk/blender/source/blender/makesrna/intern/rna_mesh_api.c
Modified: trunk/blender/source/blender/blenkernel/BKE_mesh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_mesh.h 2013-09-02 17:59:04 UTC (rev 59748)
+++ trunk/blender/source/blender/blenkernel/BKE_mesh.h 2013-09-02 18:33:06 UTC (rev 59749)
@@ -108,7 +108,7 @@
int *BKE_mesh_calc_smoothgroups(const struct MEdge *medge, const int totedge,
const struct MPoly *mpoly, const int totpoly,
const struct MLoop *mloop, const int totloop,
- int *r_totgroup);
+ int *r_totgroup, const bool use_bitflags);
void BKE_mesh_calc_relative_deform(
const struct MPoly *mpoly, const int totpoly,
Modified: trunk/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mesh.c 2013-09-02 17:59:04 UTC (rev 59748)
+++ trunk/blender/source/blender/blenkernel/intern/mesh.c 2013-09-02 18:33:06 UTC (rev 59749)
@@ -3312,12 +3312,12 @@
* Calculate smooth groups from sharp edges.
*
* \param r_totgroup The total number of groups, 1 or more.
- * \return Polygon aligned array of group index values (bitflags, starting at 1).
+ * \return Polygon aligned array of group index values (bitflags if use_bitflags is true), starting at 1.
*/
int *BKE_mesh_calc_smoothgroups(const MEdge *medge, const int totedge,
const MPoly *mpoly, const int totpoly,
const MLoop *mloop, const int totloop,
- int *r_totgroup)
+ int *r_totgroup, const bool use_bitflags)
{
int *poly_groups;
int *poly_stack;
@@ -3348,6 +3348,7 @@
while (true) {
int poly;
int bit_poly_group_mask = 0;
+ int poly_group_id;
int ps_curr_idx = 0, ps_end_idx = 0; /* stack indices */
for (poly = poly_prev; poly < totpoly; poly++) {
@@ -3361,10 +3362,12 @@
break;
}
+ poly_group_id = use_bitflags ? temp_poly_group_id : ++tot_group;
+
/* start searching from here next time */
poly_prev = poly + 1;
- poly_groups[poly] = temp_poly_group_id;
+ poly_groups[poly] = poly_group_id;
poly_stack[ps_end_idx++] = poly;
while (ps_curr_idx != ps_end_idx) {
@@ -3373,7 +3376,7 @@
int j;
poly = poly_stack[ps_curr_idx++];
- BLI_assert(poly_groups[poly] == temp_poly_group_id);
+ BLI_assert(poly_groups[poly] == poly_group_id);
mp = &mpoly[poly];
for (ml = &mloop[mp->loopstart], j = mp->totloop; j--; ml++) {
@@ -3384,19 +3387,19 @@
if (!(medge[ml->e].flag & ME_SHARP)) {
for (; i--; p++) {
/* if we meet other non initialized its a bug */
- BLI_assert(ELEM(poly_groups[*p], 0, temp_poly_group_id));
+ BLI_assert(ELEM(poly_groups[*p], 0, poly_group_id));
if (poly_groups[*p] == 0) {
- poly_groups[*p] = temp_poly_group_id;
+ poly_groups[*p] = poly_group_id;
poly_stack[ps_end_idx++] = *p;
}
}
}
- else {
+ else if (use_bitflags) {
/* Find contiguous smooth groups already assigned, these are the values we can't reuse! */
for (; i--; p++) {
int bit = poly_groups[*p];
- if (!ELEM3(bit, 0, temp_poly_group_id, poly_group_id_overflowed) &&
+ if (!ELEM3(bit, 0, poly_group_id, poly_group_id_overflowed) &&
!(bit_poly_group_mask & bit))
{
bit_poly_group_mask |= bit;
@@ -3408,8 +3411,9 @@
/* And now, we have all our poly from current group in poly_stack (from 0 to (ps_end_idx - 1)), as well as
* all smoothgroups bits we can't use in bit_poly_group_mask.
*/
- {
- int i, *p, gid_bit = 0, poly_group_id = 1;
+ if (use_bitflags) {
+ int i, *p, gid_bit = 0;
+ poly_group_id = 1;
/* Find first bit available! */
for (; (poly_group_id & bit_poly_group_mask) && (gid_bit < 32); gid_bit++) {
Modified: trunk/blender/source/blender/makesrna/intern/rna_mesh_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_mesh_api.c 2013-09-02 17:59:04 UTC (rev 59748)
+++ trunk/blender/source/blender/makesrna/intern/rna_mesh_api.c 2013-09-02 18:33:06 UTC (rev 59749)
@@ -57,14 +57,15 @@
return ret;
}
-void rna_Mesh_calc_smooth_groups(struct Mesh *mesh, int *r_poly_group_len, int **r_poly_group, int *r_group_total)
+void rna_Mesh_calc_smooth_groups(struct Mesh *mesh, int use_bitflags, int *r_poly_group_len,
+ int **r_poly_group, int *r_group_total)
{
*r_poly_group_len = mesh->totpoly;
*r_poly_group = BKE_mesh_calc_smoothgroups(
mesh->medge, mesh->totedge,
mesh->mpoly, mesh->totpoly,
mesh->mloop, mesh->totloop,
- r_group_total);
+ r_group_total, use_bitflags);
}
#else
@@ -87,6 +88,7 @@
func = RNA_def_function(srna, "calc_smooth_groups", "rna_Mesh_calc_smooth_groups");
RNA_def_function_ui_description(func, "Calculate smooth groups from sharp edges");
+ RNA_def_boolean(func, "use_bitflags", false, "", "Produce bitflags groups instead of simple numeric values");
/* return values */
parm = RNA_def_int_array(func, "poly_groups", 1, NULL, 0, 0, "", "Smooth Groups", 0, 0);
RNA_def_property_flag(parm, PROP_DYNAMIC | PROP_OUTPUT);
More information about the Bf-blender-cvs
mailing list