hexsha
stringlengths 40
40
| repo
stringlengths 5
105
| path
stringlengths 3
173
| license
sequence | language
stringclasses 1
value | identifier
stringlengths 1
438
| return_type
stringlengths 1
106
⌀ | original_string
stringlengths 21
40.7k
| original_docstring
stringlengths 18
13.4k
| docstring
stringlengths 11
3.24k
| docstring_tokens
sequence | code
stringlengths 14
20.4k
| code_tokens
sequence | short_docstring
stringlengths 0
4.36k
| short_docstring_tokens
sequence | comment
sequence | parameters
list | docstring_params
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b56403dfb6d6db2754fd8b493d040332354db724 | DemonRem/blender | source/blender/blenkernel/intern/softbody.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | SB_estimate_transform | void | void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float lscale[3][3])
{
BodyPoint *bp;
ReferenceVert *rp;
SoftBody *sb = NULL;
float(*opos)[3];
float(*rpos)[3];
float com[3], rcom[3];
int a;
if (!ob || !ob->soft) {
return; /* why did we get here ? */
}
sb = ob->soft;
if (!sb || !sb->bpoint) {
return;
}
opos = MEM_callocN((sb->totpoint) * 3 * sizeof(float), "SB_OPOS");
rpos = MEM_callocN((sb->totpoint) * 3 * sizeof(float), "SB_RPOS");
/* might filter vertex selection with a vertex group */
for (a = 0, bp = sb->bpoint, rp = sb->scratch->Ref.ivert; a < sb->totpoint; a++, bp++, rp++) {
copy_v3_v3(rpos[a], rp->pos);
copy_v3_v3(opos[a], bp->pos);
}
vcloud_estimate_transform_v3(sb->totpoint, opos, NULL, rpos, NULL, com, rcom, lrot, lscale);
// sub_v3_v3(com, rcom);
if (lloc) {
copy_v3_v3(lloc, com);
}
copy_v3_v3(sb->lcom, com);
if (lscale) {
copy_m3_m3(sb->lscale, lscale);
}
if (lrot) {
copy_m3_m3(sb->lrot, lrot);
}
MEM_freeN(opos);
MEM_freeN(rpos);
} | /* void SB_estimate_transform */
/* input Object *ob out (says any object that can do SB like mesh, lattice, curve )
* output float lloc[3], float lrot[3][3], float lscale[3][3]
* that is:
* a precise position vector denoting the motion of the center of mass
* give a rotation/scale matrix using averaging method, that's why estimate and not calculate
* see: this is kind of reverse engineering: having to states of a point cloud and recover what
* happened our advantage here we know the identity of the vertex there are others methods giving
* other results. lloc, lrot, lscale are allowed to be NULL, just in case you don't need it.
* should be pretty useful for pythoneers :)
* not! velocity .. 2nd order stuff
* vcloud_estimate_transform_v3 see
*/ | void SB_estimate_transform
input Object *ob out (says any object that can do SB like mesh, lattice, curve )
output float lloc[3], float lrot[3][3], float lscale[3][3]
that is:
a precise position vector denoting the motion of the center of mass
give a rotation/scale matrix using averaging method, that's why estimate and not calculate
see: this is kind of reverse engineering: having to states of a point cloud and recover what
happened our advantage here we know the identity of the vertex there are others methods giving
other results. lloc, lrot, lscale are allowed to be NULL, just in case you don't need it.
should be pretty useful for pythoneers :)
not. velocity .. 2nd order stuff
vcloud_estimate_transform_v3 see | [
"void",
"SB_estimate_transform",
"input",
"Object",
"*",
"ob",
"out",
"(",
"says",
"any",
"object",
"that",
"can",
"do",
"SB",
"like",
"mesh",
"lattice",
"curve",
")",
"output",
"float",
"lloc",
"[",
"3",
"]",
"float",
"lrot",
"[",
"3",
"]",
"[",
"3",
"]",
"float",
"lscale",
"[",
"3",
"]",
"[",
"3",
"]",
"that",
"is",
":",
"a",
"precise",
"position",
"vector",
"denoting",
"the",
"motion",
"of",
"the",
"center",
"of",
"mass",
"give",
"a",
"rotation",
"/",
"scale",
"matrix",
"using",
"averaging",
"method",
"that",
"'",
"s",
"why",
"estimate",
"and",
"not",
"calculate",
"see",
":",
"this",
"is",
"kind",
"of",
"reverse",
"engineering",
":",
"having",
"to",
"states",
"of",
"a",
"point",
"cloud",
"and",
"recover",
"what",
"happened",
"our",
"advantage",
"here",
"we",
"know",
"the",
"identity",
"of",
"the",
"vertex",
"there",
"are",
"others",
"methods",
"giving",
"other",
"results",
".",
"lloc",
"lrot",
"lscale",
"are",
"allowed",
"to",
"be",
"NULL",
"just",
"in",
"case",
"you",
"don",
"'",
"t",
"need",
"it",
".",
"should",
"be",
"pretty",
"useful",
"for",
"pythoneers",
":",
")",
"not",
".",
"velocity",
"..",
"2nd",
"order",
"stuff",
"vcloud_estimate_transform_v3",
"see"
] | void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float lscale[3][3])
{
BodyPoint *bp;
ReferenceVert *rp;
SoftBody *sb = NULL;
float(*opos)[3];
float(*rpos)[3];
float com[3], rcom[3];
int a;
if (!ob || !ob->soft) {
return;
}
sb = ob->soft;
if (!sb || !sb->bpoint) {
return;
}
opos = MEM_callocN((sb->totpoint) * 3 * sizeof(float), "SB_OPOS");
rpos = MEM_callocN((sb->totpoint) * 3 * sizeof(float), "SB_RPOS");
for (a = 0, bp = sb->bpoint, rp = sb->scratch->Ref.ivert; a < sb->totpoint; a++, bp++, rp++) {
copy_v3_v3(rpos[a], rp->pos);
copy_v3_v3(opos[a], bp->pos);
}
vcloud_estimate_transform_v3(sb->totpoint, opos, NULL, rpos, NULL, com, rcom, lrot, lscale);
if (lloc) {
copy_v3_v3(lloc, com);
}
copy_v3_v3(sb->lcom, com);
if (lscale) {
copy_m3_m3(sb->lscale, lscale);
}
if (lrot) {
copy_m3_m3(sb->lrot, lrot);
}
MEM_freeN(opos);
MEM_freeN(rpos);
} | [
"void",
"SB_estimate_transform",
"(",
"Object",
"*",
"ob",
",",
"float",
"lloc",
"[",
"3",
"]",
",",
"float",
"lrot",
"[",
"3",
"]",
"[",
"3",
"]",
",",
"float",
"lscale",
"[",
"3",
"]",
"[",
"3",
"]",
")",
"{",
"BodyPoint",
"*",
"bp",
";",
"ReferenceVert",
"*",
"rp",
";",
"SoftBody",
"*",
"sb",
"=",
"NULL",
";",
"float",
"(",
"*",
"opos",
")",
"[",
"3",
"]",
";",
"float",
"(",
"*",
"rpos",
")",
"[",
"3",
"]",
";",
"float",
"com",
"[",
"3",
"]",
",",
"rcom",
"[",
"3",
"]",
";",
"int",
"a",
";",
"if",
"(",
"!",
"ob",
"||",
"!",
"ob",
"->",
"soft",
")",
"{",
"return",
";",
"}",
"sb",
"=",
"ob",
"->",
"soft",
";",
"if",
"(",
"!",
"sb",
"||",
"!",
"sb",
"->",
"bpoint",
")",
"{",
"return",
";",
"}",
"opos",
"=",
"MEM_callocN",
"(",
"(",
"sb",
"->",
"totpoint",
")",
"*",
"3",
"*",
"sizeof",
"(",
"float",
")",
",",
"\"",
"\"",
")",
";",
"rpos",
"=",
"MEM_callocN",
"(",
"(",
"sb",
"->",
"totpoint",
")",
"*",
"3",
"*",
"sizeof",
"(",
"float",
")",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"a",
"=",
"0",
",",
"bp",
"=",
"sb",
"->",
"bpoint",
",",
"rp",
"=",
"sb",
"->",
"scratch",
"->",
"Ref",
".",
"ivert",
";",
"a",
"<",
"sb",
"->",
"totpoint",
";",
"a",
"++",
",",
"bp",
"++",
",",
"rp",
"++",
")",
"{",
"copy_v3_v3",
"(",
"rpos",
"[",
"a",
"]",
",",
"rp",
"->",
"pos",
")",
";",
"copy_v3_v3",
"(",
"opos",
"[",
"a",
"]",
",",
"bp",
"->",
"pos",
")",
";",
"}",
"vcloud_estimate_transform_v3",
"(",
"sb",
"->",
"totpoint",
",",
"opos",
",",
"NULL",
",",
"rpos",
",",
"NULL",
",",
"com",
",",
"rcom",
",",
"lrot",
",",
"lscale",
")",
";",
"if",
"(",
"lloc",
")",
"{",
"copy_v3_v3",
"(",
"lloc",
",",
"com",
")",
";",
"}",
"copy_v3_v3",
"(",
"sb",
"->",
"lcom",
",",
"com",
")",
";",
"if",
"(",
"lscale",
")",
"{",
"copy_m3_m3",
"(",
"sb",
"->",
"lscale",
",",
"lscale",
")",
";",
"}",
"if",
"(",
"lrot",
")",
"{",
"copy_m3_m3",
"(",
"sb",
"->",
"lrot",
",",
"lrot",
")",
";",
"}",
"MEM_freeN",
"(",
"opos",
")",
";",
"MEM_freeN",
"(",
"rpos",
")",
";",
"}"
] | void SB_estimate_transform
input Object *ob out (says any object that can do SB like mesh, lattice, curve )
output float lloc[3], float lrot[3][3], float lscale[3][3]
that is:
a precise position vector denoting the motion of the center of mass
give a rotation/scale matrix using averaging method, that's why estimate and not calculate
see: this is kind of reverse engineering: having to states of a point cloud and recover what
happened our advantage here we know the identity of the vertex there are others methods giving
other results. | [
"void",
"SB_estimate_transform",
"input",
"Object",
"*",
"ob",
"out",
"(",
"says",
"any",
"object",
"that",
"can",
"do",
"SB",
"like",
"mesh",
"lattice",
"curve",
")",
"output",
"float",
"lloc",
"[",
"3",
"]",
"float",
"lrot",
"[",
"3",
"]",
"[",
"3",
"]",
"float",
"lscale",
"[",
"3",
"]",
"[",
"3",
"]",
"that",
"is",
":",
"a",
"precise",
"position",
"vector",
"denoting",
"the",
"motion",
"of",
"the",
"center",
"of",
"mass",
"give",
"a",
"rotation",
"/",
"scale",
"matrix",
"using",
"averaging",
"method",
"that",
"'",
"s",
"why",
"estimate",
"and",
"not",
"calculate",
"see",
":",
"this",
"is",
"kind",
"of",
"reverse",
"engineering",
":",
"having",
"to",
"states",
"of",
"a",
"point",
"cloud",
"and",
"recover",
"what",
"happened",
"our",
"advantage",
"here",
"we",
"know",
"the",
"identity",
"of",
"the",
"vertex",
"there",
"are",
"others",
"methods",
"giving",
"other",
"results",
"."
] | [
"/* why did we get here ? */",
"/* might filter vertex selection with a vertex group */",
"// sub_v3_v3(com, rcom);"
] | [
{
"param": "ob",
"type": "Object"
},
{
"param": "lloc",
"type": "float"
},
{
"param": "lrot",
"type": "float"
},
{
"param": "lscale",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ob",
"type": "Object",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lloc",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lrot",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lscale",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b56403dfb6d6db2754fd8b493d040332354db724 | DemonRem/blender | source/blender/blenkernel/intern/softbody.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | sbObjectStep | void | void sbObjectStep(struct Depsgraph *depsgraph,
Scene *scene,
Object *ob,
float cfra,
float (*vertexCos)[3],
int numVerts)
{
SoftBody *sb = ob->soft;
PointCache *cache;
PTCacheID pid;
float dtime, timescale;
int framedelta, framenr, startframe, endframe;
int cache_result;
cache = sb->shared->pointcache;
framenr = (int)cfra;
framedelta = framenr - cache->simframe;
BKE_ptcache_id_from_softbody(&pid, ob, sb);
BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale);
/* check for changes in mesh, should only happen in case the mesh
* structure changes during an animation */
if (sb->bpoint && numVerts != sb->totpoint) {
BKE_ptcache_invalidate(cache);
return;
}
/* clamp frame ranges */
if (framenr < startframe) {
BKE_ptcache_invalidate(cache);
return;
}
else if (framenr > endframe) {
framenr = endframe;
}
/* verify if we need to create the softbody data */
if (sb->bpoint == NULL ||
((ob->softflag & OB_SB_EDGES) && !ob->soft->bspring && object_has_edges(ob))) {
switch (ob->type) {
case OB_MESH:
mesh_to_softbody(scene, ob);
break;
case OB_LATTICE:
lattice_to_softbody(scene, ob);
break;
case OB_CURVE:
case OB_SURF:
curve_surf_to_softbody(scene, ob);
break;
default:
renew_softbody(scene, ob, numVerts, 0);
break;
}
softbody_update_positions(ob, sb, vertexCos, numVerts);
softbody_reset(ob, sb, vertexCos, numVerts);
}
/* still no points? go away */
if (sb->totpoint == 0) {
return;
}
if (framenr == startframe) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
/* first frame, no simulation to do, just set the positions */
softbody_update_positions(ob, sb, vertexCos, numVerts);
BKE_ptcache_validate(cache, framenr);
cache->flag &= ~PTCACHE_REDO_NEEDED;
sbStoreLastFrame(depsgraph, ob, framenr);
return;
}
/* try to read from cache */
bool can_write_cache = DEG_is_active(depsgraph);
bool can_simulate = (framenr == sb->last_frame + 1) && !(cache->flag & PTCACHE_BAKED) &&
can_write_cache;
cache_result = BKE_ptcache_read(&pid, (float)framenr + scene->r.subframe, can_simulate);
if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED ||
(!can_simulate && cache_result == PTCACHE_READ_OLD)) {
softbody_to_object(ob, vertexCos, numVerts, sb->local);
BKE_ptcache_validate(cache, framenr);
if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED &&
can_write_cache) {
BKE_ptcache_write(&pid, framenr);
}
sbStoreLastFrame(depsgraph, ob, framenr);
return;
}
else if (cache_result == PTCACHE_READ_OLD) {
/* pass */
}
else if (/*ob->id.lib || */
/* "library linking & pointcaches" has to be solved properly at some point */
(cache->flag & PTCACHE_BAKED)) {
/* if baked and nothing in cache, do nothing */
if (can_write_cache) {
BKE_ptcache_invalidate(cache);
}
return;
}
if (!can_simulate) {
return;
}
/* if on second frame, write cache for first frame */
if (cache->simframe == startframe &&
(cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) {
BKE_ptcache_write(&pid, startframe);
}
softbody_update_positions(ob, sb, vertexCos, numVerts);
/* checking time: */
dtime = framedelta * timescale;
/* do simulation */
softbody_step(depsgraph, scene, ob, sb, dtime);
softbody_to_object(ob, vertexCos, numVerts, 0);
BKE_ptcache_validate(cache, framenr);
BKE_ptcache_write(&pid, framenr);
sbStoreLastFrame(depsgraph, ob, framenr);
} | /* simulates one step. framenr is in frames */ | simulates one step. framenr is in frames | [
"simulates",
"one",
"step",
".",
"framenr",
"is",
"in",
"frames"
] | void sbObjectStep(struct Depsgraph *depsgraph,
Scene *scene,
Object *ob,
float cfra,
float (*vertexCos)[3],
int numVerts)
{
SoftBody *sb = ob->soft;
PointCache *cache;
PTCacheID pid;
float dtime, timescale;
int framedelta, framenr, startframe, endframe;
int cache_result;
cache = sb->shared->pointcache;
framenr = (int)cfra;
framedelta = framenr - cache->simframe;
BKE_ptcache_id_from_softbody(&pid, ob, sb);
BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale);
if (sb->bpoint && numVerts != sb->totpoint) {
BKE_ptcache_invalidate(cache);
return;
}
if (framenr < startframe) {
BKE_ptcache_invalidate(cache);
return;
}
else if (framenr > endframe) {
framenr = endframe;
}
if (sb->bpoint == NULL ||
((ob->softflag & OB_SB_EDGES) && !ob->soft->bspring && object_has_edges(ob))) {
switch (ob->type) {
case OB_MESH:
mesh_to_softbody(scene, ob);
break;
case OB_LATTICE:
lattice_to_softbody(scene, ob);
break;
case OB_CURVE:
case OB_SURF:
curve_surf_to_softbody(scene, ob);
break;
default:
renew_softbody(scene, ob, numVerts, 0);
break;
}
softbody_update_positions(ob, sb, vertexCos, numVerts);
softbody_reset(ob, sb, vertexCos, numVerts);
}
if (sb->totpoint == 0) {
return;
}
if (framenr == startframe) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
softbody_update_positions(ob, sb, vertexCos, numVerts);
BKE_ptcache_validate(cache, framenr);
cache->flag &= ~PTCACHE_REDO_NEEDED;
sbStoreLastFrame(depsgraph, ob, framenr);
return;
}
bool can_write_cache = DEG_is_active(depsgraph);
bool can_simulate = (framenr == sb->last_frame + 1) && !(cache->flag & PTCACHE_BAKED) &&
can_write_cache;
cache_result = BKE_ptcache_read(&pid, (float)framenr + scene->r.subframe, can_simulate);
if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED ||
(!can_simulate && cache_result == PTCACHE_READ_OLD)) {
softbody_to_object(ob, vertexCos, numVerts, sb->local);
BKE_ptcache_validate(cache, framenr);
if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED &&
can_write_cache) {
BKE_ptcache_write(&pid, framenr);
}
sbStoreLastFrame(depsgraph, ob, framenr);
return;
}
else if (cache_result == PTCACHE_READ_OLD) {
}
else if (
(cache->flag & PTCACHE_BAKED)) {
if (can_write_cache) {
BKE_ptcache_invalidate(cache);
}
return;
}
if (!can_simulate) {
return;
}
if (cache->simframe == startframe &&
(cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) {
BKE_ptcache_write(&pid, startframe);
}
softbody_update_positions(ob, sb, vertexCos, numVerts);
dtime = framedelta * timescale;
softbody_step(depsgraph, scene, ob, sb, dtime);
softbody_to_object(ob, vertexCos, numVerts, 0);
BKE_ptcache_validate(cache, framenr);
BKE_ptcache_write(&pid, framenr);
sbStoreLastFrame(depsgraph, ob, framenr);
} | [
"void",
"sbObjectStep",
"(",
"struct",
"Depsgraph",
"*",
"depsgraph",
",",
"Scene",
"*",
"scene",
",",
"Object",
"*",
"ob",
",",
"float",
"cfra",
",",
"float",
"(",
"*",
"vertexCos",
")",
"[",
"3",
"]",
",",
"int",
"numVerts",
")",
"{",
"SoftBody",
"*",
"sb",
"=",
"ob",
"->",
"soft",
";",
"PointCache",
"*",
"cache",
";",
"PTCacheID",
"pid",
";",
"float",
"dtime",
",",
"timescale",
";",
"int",
"framedelta",
",",
"framenr",
",",
"startframe",
",",
"endframe",
";",
"int",
"cache_result",
";",
"cache",
"=",
"sb",
"->",
"shared",
"->",
"pointcache",
";",
"framenr",
"=",
"(",
"int",
")",
"cfra",
";",
"framedelta",
"=",
"framenr",
"-",
"cache",
"->",
"simframe",
";",
"BKE_ptcache_id_from_softbody",
"(",
"&",
"pid",
",",
"ob",
",",
"sb",
")",
";",
"BKE_ptcache_id_time",
"(",
"&",
"pid",
",",
"scene",
",",
"framenr",
",",
"&",
"startframe",
",",
"&",
"endframe",
",",
"&",
"timescale",
")",
";",
"if",
"(",
"sb",
"->",
"bpoint",
"&&",
"numVerts",
"!=",
"sb",
"->",
"totpoint",
")",
"{",
"BKE_ptcache_invalidate",
"(",
"cache",
")",
";",
"return",
";",
"}",
"if",
"(",
"framenr",
"<",
"startframe",
")",
"{",
"BKE_ptcache_invalidate",
"(",
"cache",
")",
";",
"return",
";",
"}",
"else",
"if",
"(",
"framenr",
">",
"endframe",
")",
"{",
"framenr",
"=",
"endframe",
";",
"}",
"if",
"(",
"sb",
"->",
"bpoint",
"==",
"NULL",
"||",
"(",
"(",
"ob",
"->",
"softflag",
"&",
"OB_SB_EDGES",
")",
"&&",
"!",
"ob",
"->",
"soft",
"->",
"bspring",
"&&",
"object_has_edges",
"(",
"ob",
")",
")",
")",
"{",
"switch",
"(",
"ob",
"->",
"type",
")",
"{",
"case",
"OB_MESH",
":",
"mesh_to_softbody",
"(",
"scene",
",",
"ob",
")",
";",
"break",
";",
"case",
"OB_LATTICE",
":",
"lattice_to_softbody",
"(",
"scene",
",",
"ob",
")",
";",
"break",
";",
"case",
"OB_CURVE",
":",
"case",
"OB_SURF",
":",
"curve_surf_to_softbody",
"(",
"scene",
",",
"ob",
")",
";",
"break",
";",
"default",
":",
"renew_softbody",
"(",
"scene",
",",
"ob",
",",
"numVerts",
",",
"0",
")",
";",
"break",
";",
"}",
"softbody_update_positions",
"(",
"ob",
",",
"sb",
",",
"vertexCos",
",",
"numVerts",
")",
";",
"softbody_reset",
"(",
"ob",
",",
"sb",
",",
"vertexCos",
",",
"numVerts",
")",
";",
"}",
"if",
"(",
"sb",
"->",
"totpoint",
"==",
"0",
")",
"{",
"return",
";",
"}",
"if",
"(",
"framenr",
"==",
"startframe",
")",
"{",
"BKE_ptcache_id_reset",
"(",
"scene",
",",
"&",
"pid",
",",
"PTCACHE_RESET_OUTDATED",
")",
";",
"softbody_update_positions",
"(",
"ob",
",",
"sb",
",",
"vertexCos",
",",
"numVerts",
")",
";",
"BKE_ptcache_validate",
"(",
"cache",
",",
"framenr",
")",
";",
"cache",
"->",
"flag",
"&=",
"~",
"PTCACHE_REDO_NEEDED",
";",
"sbStoreLastFrame",
"(",
"depsgraph",
",",
"ob",
",",
"framenr",
")",
";",
"return",
";",
"}",
"bool",
"can_write_cache",
"=",
"DEG_is_active",
"(",
"depsgraph",
")",
";",
"bool",
"can_simulate",
"=",
"(",
"framenr",
"==",
"sb",
"->",
"last_frame",
"+",
"1",
")",
"&&",
"!",
"(",
"cache",
"->",
"flag",
"&",
"PTCACHE_BAKED",
")",
"&&",
"can_write_cache",
";",
"cache_result",
"=",
"BKE_ptcache_read",
"(",
"&",
"pid",
",",
"(",
"float",
")",
"framenr",
"+",
"scene",
"->",
"r",
".",
"subframe",
",",
"can_simulate",
")",
";",
"if",
"(",
"cache_result",
"==",
"PTCACHE_READ_EXACT",
"||",
"cache_result",
"==",
"PTCACHE_READ_INTERPOLATED",
"||",
"(",
"!",
"can_simulate",
"&&",
"cache_result",
"==",
"PTCACHE_READ_OLD",
")",
")",
"{",
"softbody_to_object",
"(",
"ob",
",",
"vertexCos",
",",
"numVerts",
",",
"sb",
"->",
"local",
")",
";",
"BKE_ptcache_validate",
"(",
"cache",
",",
"framenr",
")",
";",
"if",
"(",
"cache_result",
"==",
"PTCACHE_READ_INTERPOLATED",
"&&",
"cache",
"->",
"flag",
"&",
"PTCACHE_REDO_NEEDED",
"&&",
"can_write_cache",
")",
"{",
"BKE_ptcache_write",
"(",
"&",
"pid",
",",
"framenr",
")",
";",
"}",
"sbStoreLastFrame",
"(",
"depsgraph",
",",
"ob",
",",
"framenr",
")",
";",
"return",
";",
"}",
"else",
"if",
"(",
"cache_result",
"==",
"PTCACHE_READ_OLD",
")",
"{",
"}",
"else",
"if",
"(",
"(",
"cache",
"->",
"flag",
"&",
"PTCACHE_BAKED",
")",
")",
"{",
"if",
"(",
"can_write_cache",
")",
"{",
"BKE_ptcache_invalidate",
"(",
"cache",
")",
";",
"}",
"return",
";",
"}",
"if",
"(",
"!",
"can_simulate",
")",
"{",
"return",
";",
"}",
"if",
"(",
"cache",
"->",
"simframe",
"==",
"startframe",
"&&",
"(",
"cache",
"->",
"flag",
"&",
"PTCACHE_OUTDATED",
"||",
"cache",
"->",
"last_exact",
"==",
"0",
")",
")",
"{",
"BKE_ptcache_write",
"(",
"&",
"pid",
",",
"startframe",
")",
";",
"}",
"softbody_update_positions",
"(",
"ob",
",",
"sb",
",",
"vertexCos",
",",
"numVerts",
")",
";",
"dtime",
"=",
"framedelta",
"*",
"timescale",
";",
"softbody_step",
"(",
"depsgraph",
",",
"scene",
",",
"ob",
",",
"sb",
",",
"dtime",
")",
";",
"softbody_to_object",
"(",
"ob",
",",
"vertexCos",
",",
"numVerts",
",",
"0",
")",
";",
"BKE_ptcache_validate",
"(",
"cache",
",",
"framenr",
")",
";",
"BKE_ptcache_write",
"(",
"&",
"pid",
",",
"framenr",
")",
";",
"sbStoreLastFrame",
"(",
"depsgraph",
",",
"ob",
",",
"framenr",
")",
";",
"}"
] | simulates one step. | [
"simulates",
"one",
"step",
"."
] | [
"/* check for changes in mesh, should only happen in case the mesh\n * structure changes during an animation */",
"/* clamp frame ranges */",
"/* verify if we need to create the softbody data */",
"/* still no points? go away */",
"/* first frame, no simulation to do, just set the positions */",
"/* try to read from cache */",
"/* pass */",
"/*ob->id.lib || */",
"/* \"library linking & pointcaches\" has to be solved properly at some point */",
"/* if baked and nothing in cache, do nothing */",
"/* if on second frame, write cache for first frame */",
"/* checking time: */",
"/* do simulation */"
] | [
{
"param": "depsgraph",
"type": "struct Depsgraph"
},
{
"param": "scene",
"type": "Scene"
},
{
"param": "ob",
"type": "Object"
},
{
"param": "cfra",
"type": "float"
},
{
"param": "vertexCos",
"type": "float"
},
{
"param": "numVerts",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "depsgraph",
"type": "struct Depsgraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "scene",
"type": "Scene",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ob",
"type": "Object",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cfra",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vertexCos",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "numVerts",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
77e17ad46872e21f3887801f26953f1aa01ce1de | DemonRem/blender | source/blender/windowmanager/intern/wm.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | wm_add_default | void | void wm_add_default(Main *bmain, bContext *C)
{
wmWindowManager *wm = BKE_libblock_alloc(bmain, ID_WM, "WinMan", 0);
wmWindow *win;
bScreen *screen = CTX_wm_screen(C); /* XXX from file read hrmf */
WorkSpace *workspace;
WorkSpaceLayout *layout = BKE_workspace_layout_find_global(bmain, screen, &workspace);
CTX_wm_manager_set(C, wm);
win = wm_window_new(C, NULL);
win->scene = CTX_data_scene(C);
STRNCPY(win->view_layer_name, CTX_data_view_layer(C)->name);
BKE_workspace_active_set(win->workspace_hook, workspace);
BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace, layout);
screen->winid = win->winid;
wm->winactive = win;
wm->file_saved = 1;
wm_window_make_drawable(wm, win);
} | /* on startup, it adds all data, for matching */ | on startup, it adds all data, for matching | [
"on",
"startup",
"it",
"adds",
"all",
"data",
"for",
"matching"
] | void wm_add_default(Main *bmain, bContext *C)
{
wmWindowManager *wm = BKE_libblock_alloc(bmain, ID_WM, "WinMan", 0);
wmWindow *win;
bScreen *screen = CTX_wm_screen(C);
WorkSpace *workspace;
WorkSpaceLayout *layout = BKE_workspace_layout_find_global(bmain, screen, &workspace);
CTX_wm_manager_set(C, wm);
win = wm_window_new(C, NULL);
win->scene = CTX_data_scene(C);
STRNCPY(win->view_layer_name, CTX_data_view_layer(C)->name);
BKE_workspace_active_set(win->workspace_hook, workspace);
BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace, layout);
screen->winid = win->winid;
wm->winactive = win;
wm->file_saved = 1;
wm_window_make_drawable(wm, win);
} | [
"void",
"wm_add_default",
"(",
"Main",
"*",
"bmain",
",",
"bContext",
"*",
"C",
")",
"{",
"wmWindowManager",
"*",
"wm",
"=",
"BKE_libblock_alloc",
"(",
"bmain",
",",
"ID_WM",
",",
"\"",
"\"",
",",
"0",
")",
";",
"wmWindow",
"*",
"win",
";",
"bScreen",
"*",
"screen",
"=",
"CTX_wm_screen",
"(",
"C",
")",
";",
"WorkSpace",
"*",
"workspace",
";",
"WorkSpaceLayout",
"*",
"layout",
"=",
"BKE_workspace_layout_find_global",
"(",
"bmain",
",",
"screen",
",",
"&",
"workspace",
")",
";",
"CTX_wm_manager_set",
"(",
"C",
",",
"wm",
")",
";",
"win",
"=",
"wm_window_new",
"(",
"C",
",",
"NULL",
")",
";",
"win",
"->",
"scene",
"=",
"CTX_data_scene",
"(",
"C",
")",
";",
"STRNCPY",
"(",
"win",
"->",
"view_layer_name",
",",
"CTX_data_view_layer",
"(",
"C",
")",
"->",
"name",
")",
";",
"BKE_workspace_active_set",
"(",
"win",
"->",
"workspace_hook",
",",
"workspace",
")",
";",
"BKE_workspace_hook_layout_for_workspace_set",
"(",
"win",
"->",
"workspace_hook",
",",
"workspace",
",",
"layout",
")",
";",
"screen",
"->",
"winid",
"=",
"win",
"->",
"winid",
";",
"wm",
"->",
"winactive",
"=",
"win",
";",
"wm",
"->",
"file_saved",
"=",
"1",
";",
"wm_window_make_drawable",
"(",
"wm",
",",
"win",
")",
";",
"}"
] | on startup, it adds all data, for matching | [
"on",
"startup",
"it",
"adds",
"all",
"data",
"for",
"matching"
] | [
"/* XXX from file read hrmf */"
] | [
{
"param": "bmain",
"type": "Main"
},
{
"param": "C",
"type": "bContext"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bmain",
"type": "Main",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "C",
"type": "bContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
77e17ad46872e21f3887801f26953f1aa01ce1de | DemonRem/blender | source/blender/windowmanager/intern/wm.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | wm_close_and_free | void | void wm_close_and_free(bContext *C, wmWindowManager *wm)
{
wmWindow *win;
wmOperator *op;
wmKeyConfig *keyconf;
if (wm->autosavetimer) {
wm_autosave_timer_ended(wm);
}
while ((win = BLI_pophead(&wm->windows))) {
/* prevent draw clear to use screen */
BKE_workspace_active_set(win->workspace_hook, NULL);
wm_window_free(C, wm, win);
}
while ((op = BLI_pophead(&wm->operators))) {
WM_operator_free(op);
}
while ((keyconf = BLI_pophead(&wm->keyconfigs))) {
WM_keyconfig_free(keyconf);
}
BLI_freelistN(&wm->queue);
if (wm->message_bus != NULL) {
WM_msgbus_destroy(wm->message_bus);
}
BLI_freelistN(&wm->paintcursors);
WM_drag_free_list(&wm->drags);
wm_reports_free(wm);
if (wm->undo_stack) {
BKE_undosys_stack_destroy(wm->undo_stack);
wm->undo_stack = NULL;
}
if (C && CTX_wm_manager(C) == wm) {
CTX_wm_manager_set(C, NULL);
}
} | /* context is allowed to be NULL, do not free wm itself (library.c) */ | context is allowed to be NULL, do not free wm itself (library.c) | [
"context",
"is",
"allowed",
"to",
"be",
"NULL",
"do",
"not",
"free",
"wm",
"itself",
"(",
"library",
".",
"c",
")"
] | void wm_close_and_free(bContext *C, wmWindowManager *wm)
{
wmWindow *win;
wmOperator *op;
wmKeyConfig *keyconf;
if (wm->autosavetimer) {
wm_autosave_timer_ended(wm);
}
while ((win = BLI_pophead(&wm->windows))) {
BKE_workspace_active_set(win->workspace_hook, NULL);
wm_window_free(C, wm, win);
}
while ((op = BLI_pophead(&wm->operators))) {
WM_operator_free(op);
}
while ((keyconf = BLI_pophead(&wm->keyconfigs))) {
WM_keyconfig_free(keyconf);
}
BLI_freelistN(&wm->queue);
if (wm->message_bus != NULL) {
WM_msgbus_destroy(wm->message_bus);
}
BLI_freelistN(&wm->paintcursors);
WM_drag_free_list(&wm->drags);
wm_reports_free(wm);
if (wm->undo_stack) {
BKE_undosys_stack_destroy(wm->undo_stack);
wm->undo_stack = NULL;
}
if (C && CTX_wm_manager(C) == wm) {
CTX_wm_manager_set(C, NULL);
}
} | [
"void",
"wm_close_and_free",
"(",
"bContext",
"*",
"C",
",",
"wmWindowManager",
"*",
"wm",
")",
"{",
"wmWindow",
"*",
"win",
";",
"wmOperator",
"*",
"op",
";",
"wmKeyConfig",
"*",
"keyconf",
";",
"if",
"(",
"wm",
"->",
"autosavetimer",
")",
"{",
"wm_autosave_timer_ended",
"(",
"wm",
")",
";",
"}",
"while",
"(",
"(",
"win",
"=",
"BLI_pophead",
"(",
"&",
"wm",
"->",
"windows",
")",
")",
")",
"{",
"BKE_workspace_active_set",
"(",
"win",
"->",
"workspace_hook",
",",
"NULL",
")",
";",
"wm_window_free",
"(",
"C",
",",
"wm",
",",
"win",
")",
";",
"}",
"while",
"(",
"(",
"op",
"=",
"BLI_pophead",
"(",
"&",
"wm",
"->",
"operators",
")",
")",
")",
"{",
"WM_operator_free",
"(",
"op",
")",
";",
"}",
"while",
"(",
"(",
"keyconf",
"=",
"BLI_pophead",
"(",
"&",
"wm",
"->",
"keyconfigs",
")",
")",
")",
"{",
"WM_keyconfig_free",
"(",
"keyconf",
")",
";",
"}",
"BLI_freelistN",
"(",
"&",
"wm",
"->",
"queue",
")",
";",
"if",
"(",
"wm",
"->",
"message_bus",
"!=",
"NULL",
")",
"{",
"WM_msgbus_destroy",
"(",
"wm",
"->",
"message_bus",
")",
";",
"}",
"BLI_freelistN",
"(",
"&",
"wm",
"->",
"paintcursors",
")",
";",
"WM_drag_free_list",
"(",
"&",
"wm",
"->",
"drags",
")",
";",
"wm_reports_free",
"(",
"wm",
")",
";",
"if",
"(",
"wm",
"->",
"undo_stack",
")",
"{",
"BKE_undosys_stack_destroy",
"(",
"wm",
"->",
"undo_stack",
")",
";",
"wm",
"->",
"undo_stack",
"=",
"NULL",
";",
"}",
"if",
"(",
"C",
"&&",
"CTX_wm_manager",
"(",
"C",
")",
"==",
"wm",
")",
"{",
"CTX_wm_manager_set",
"(",
"C",
",",
"NULL",
")",
";",
"}",
"}"
] | context is allowed to be NULL, do not free wm itself (library.c) | [
"context",
"is",
"allowed",
"to",
"be",
"NULL",
"do",
"not",
"free",
"wm",
"itself",
"(",
"library",
".",
"c",
")"
] | [
"/* prevent draw clear to use screen */"
] | [
{
"param": "C",
"type": "bContext"
},
{
"param": "wm",
"type": "wmWindowManager"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "C",
"type": "bContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "wm",
"type": "wmWindowManager",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a51b08f7525ac207b26a24a223eb0884b6697b05 | DemonRem/blender | source/blender/editors/space_sequencer/sequencer_select.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | select_active_side | void | static void select_active_side(ListBase *seqbase, int sel_side, int channel, int frame)
{
Sequence *seq;
for (seq = seqbase->first; seq; seq = seq->next) {
if (channel == seq->machine) {
switch (sel_side) {
case SEQ_SIDE_LEFT:
if (frame > (seq->startdisp)) {
seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
seq->flag |= SELECT;
}
break;
case SEQ_SIDE_RIGHT:
if (frame < (seq->startdisp)) {
seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
seq->flag |= SELECT;
}
break;
case SEQ_SIDE_BOTH:
seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
seq->flag |= SELECT;
break;
}
}
}
} | /* Used for mouse selection in SEQUENCER_OT_select. */ | Used for mouse selection in SEQUENCER_OT_select. | [
"Used",
"for",
"mouse",
"selection",
"in",
"SEQUENCER_OT_select",
"."
] | static void select_active_side(ListBase *seqbase, int sel_side, int channel, int frame)
{
Sequence *seq;
for (seq = seqbase->first; seq; seq = seq->next) {
if (channel == seq->machine) {
switch (sel_side) {
case SEQ_SIDE_LEFT:
if (frame > (seq->startdisp)) {
seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
seq->flag |= SELECT;
}
break;
case SEQ_SIDE_RIGHT:
if (frame < (seq->startdisp)) {
seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
seq->flag |= SELECT;
}
break;
case SEQ_SIDE_BOTH:
seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
seq->flag |= SELECT;
break;
}
}
}
} | [
"static",
"void",
"select_active_side",
"(",
"ListBase",
"*",
"seqbase",
",",
"int",
"sel_side",
",",
"int",
"channel",
",",
"int",
"frame",
")",
"{",
"Sequence",
"*",
"seq",
";",
"for",
"(",
"seq",
"=",
"seqbase",
"->",
"first",
";",
"seq",
";",
"seq",
"=",
"seq",
"->",
"next",
")",
"{",
"if",
"(",
"channel",
"==",
"seq",
"->",
"machine",
")",
"{",
"switch",
"(",
"sel_side",
")",
"{",
"case",
"SEQ_SIDE_LEFT",
":",
"if",
"(",
"frame",
">",
"(",
"seq",
"->",
"startdisp",
")",
")",
"{",
"seq",
"->",
"flag",
"&=",
"~",
"(",
"SEQ_RIGHTSEL",
"|",
"SEQ_LEFTSEL",
")",
";",
"seq",
"->",
"flag",
"|=",
"SELECT",
";",
"}",
"break",
";",
"case",
"SEQ_SIDE_RIGHT",
":",
"if",
"(",
"frame",
"<",
"(",
"seq",
"->",
"startdisp",
")",
")",
"{",
"seq",
"->",
"flag",
"&=",
"~",
"(",
"SEQ_RIGHTSEL",
"|",
"SEQ_LEFTSEL",
")",
";",
"seq",
"->",
"flag",
"|=",
"SELECT",
";",
"}",
"break",
";",
"case",
"SEQ_SIDE_BOTH",
":",
"seq",
"->",
"flag",
"&=",
"~",
"(",
"SEQ_RIGHTSEL",
"|",
"SEQ_LEFTSEL",
")",
";",
"seq",
"->",
"flag",
"|=",
"SELECT",
";",
"break",
";",
"}",
"}",
"}",
"}"
] | Used for mouse selection in SEQUENCER_OT_select. | [
"Used",
"for",
"mouse",
"selection",
"in",
"SEQUENCER_OT_select",
"."
] | [] | [
{
"param": "seqbase",
"type": "ListBase"
},
{
"param": "sel_side",
"type": "int"
},
{
"param": "channel",
"type": "int"
},
{
"param": "frame",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "seqbase",
"type": "ListBase",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sel_side",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "channel",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "frame",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a51b08f7525ac207b26a24a223eb0884b6697b05 | DemonRem/blender | source/blender/editors/space_sequencer/sequencer_select.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | select_active_side_range | void | static void select_active_side_range(ListBase *seqbase,
const int sel_side,
const int frame_ranges[MAXSEQ],
const int frame_ignore)
{
Sequence *seq;
for (seq = seqbase->first; seq; seq = seq->next) {
if (seq->machine < MAXSEQ) {
const int frame = frame_ranges[seq->machine];
if (frame == frame_ignore) {
continue;
}
switch (sel_side) {
case SEQ_SIDE_LEFT:
if (frame > (seq->startdisp)) {
seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
seq->flag |= SELECT;
}
break;
case SEQ_SIDE_RIGHT:
if (frame < (seq->startdisp)) {
seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
seq->flag |= SELECT;
}
break;
case SEQ_SIDE_BOTH:
seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
seq->flag |= SELECT;
break;
}
}
}
} | /* Used for mouse selection in SEQUENCER_OT_select_side. */ | Used for mouse selection in SEQUENCER_OT_select_side. | [
"Used",
"for",
"mouse",
"selection",
"in",
"SEQUENCER_OT_select_side",
"."
] | static void select_active_side_range(ListBase *seqbase,
const int sel_side,
const int frame_ranges[MAXSEQ],
const int frame_ignore)
{
Sequence *seq;
for (seq = seqbase->first; seq; seq = seq->next) {
if (seq->machine < MAXSEQ) {
const int frame = frame_ranges[seq->machine];
if (frame == frame_ignore) {
continue;
}
switch (sel_side) {
case SEQ_SIDE_LEFT:
if (frame > (seq->startdisp)) {
seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
seq->flag |= SELECT;
}
break;
case SEQ_SIDE_RIGHT:
if (frame < (seq->startdisp)) {
seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
seq->flag |= SELECT;
}
break;
case SEQ_SIDE_BOTH:
seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
seq->flag |= SELECT;
break;
}
}
}
} | [
"static",
"void",
"select_active_side_range",
"(",
"ListBase",
"*",
"seqbase",
",",
"const",
"int",
"sel_side",
",",
"const",
"int",
"frame_ranges",
"[",
"MAXSEQ",
"]",
",",
"const",
"int",
"frame_ignore",
")",
"{",
"Sequence",
"*",
"seq",
";",
"for",
"(",
"seq",
"=",
"seqbase",
"->",
"first",
";",
"seq",
";",
"seq",
"=",
"seq",
"->",
"next",
")",
"{",
"if",
"(",
"seq",
"->",
"machine",
"<",
"MAXSEQ",
")",
"{",
"const",
"int",
"frame",
"=",
"frame_ranges",
"[",
"seq",
"->",
"machine",
"]",
";",
"if",
"(",
"frame",
"==",
"frame_ignore",
")",
"{",
"continue",
";",
"}",
"switch",
"(",
"sel_side",
")",
"{",
"case",
"SEQ_SIDE_LEFT",
":",
"if",
"(",
"frame",
">",
"(",
"seq",
"->",
"startdisp",
")",
")",
"{",
"seq",
"->",
"flag",
"&=",
"~",
"(",
"SEQ_RIGHTSEL",
"|",
"SEQ_LEFTSEL",
")",
";",
"seq",
"->",
"flag",
"|=",
"SELECT",
";",
"}",
"break",
";",
"case",
"SEQ_SIDE_RIGHT",
":",
"if",
"(",
"frame",
"<",
"(",
"seq",
"->",
"startdisp",
")",
")",
"{",
"seq",
"->",
"flag",
"&=",
"~",
"(",
"SEQ_RIGHTSEL",
"|",
"SEQ_LEFTSEL",
")",
";",
"seq",
"->",
"flag",
"|=",
"SELECT",
";",
"}",
"break",
";",
"case",
"SEQ_SIDE_BOTH",
":",
"seq",
"->",
"flag",
"&=",
"~",
"(",
"SEQ_RIGHTSEL",
"|",
"SEQ_LEFTSEL",
")",
";",
"seq",
"->",
"flag",
"|=",
"SELECT",
";",
"break",
";",
"}",
"}",
"}",
"}"
] | Used for mouse selection in SEQUENCER_OT_select_side. | [
"Used",
"for",
"mouse",
"selection",
"in",
"SEQUENCER_OT_select_side",
"."
] | [] | [
{
"param": "seqbase",
"type": "ListBase"
},
{
"param": "sel_side",
"type": "int"
},
{
"param": "frame_ranges",
"type": "int"
},
{
"param": "frame_ignore",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "seqbase",
"type": "ListBase",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sel_side",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "frame_ranges",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "frame_ignore",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a51b08f7525ac207b26a24a223eb0884b6697b05 | DemonRem/blender | source/blender/editors/space_sequencer/sequencer_select.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | select_linked_time | void | static void select_linked_time(ListBase *seqbase, Sequence *seq_link)
{
Sequence *seq;
for (seq = seqbase->first; seq; seq = seq->next) {
if (seq_link->machine != seq->machine) {
int left_match = (seq->startdisp == seq_link->startdisp) ? 1 : 0;
int right_match = (seq->enddisp == seq_link->enddisp) ? 1 : 0;
if (left_match && right_match) {
/* a direct match, copy the selection settinhs */
seq->flag &= ~(SELECT | SEQ_LEFTSEL | SEQ_RIGHTSEL);
seq->flag |= seq_link->flag & (SELECT | SEQ_LEFTSEL | SEQ_RIGHTSEL);
recurs_sel_seq(seq);
}
else if (seq_link->flag & SELECT && (left_match || right_match)) {
/* clear for reselection */
seq->flag &= ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
if (left_match && seq_link->flag & SEQ_LEFTSEL) {
seq->flag |= SELECT | SEQ_LEFTSEL;
}
if (right_match && seq_link->flag & SEQ_RIGHTSEL) {
seq->flag |= SELECT | SEQ_RIGHTSEL;
}
recurs_sel_seq(seq);
}
}
}
} | /* used for mouse selection in SEQUENCER_OT_select */ | used for mouse selection in SEQUENCER_OT_select | [
"used",
"for",
"mouse",
"selection",
"in",
"SEQUENCER_OT_select"
] | static void select_linked_time(ListBase *seqbase, Sequence *seq_link)
{
Sequence *seq;
for (seq = seqbase->first; seq; seq = seq->next) {
if (seq_link->machine != seq->machine) {
int left_match = (seq->startdisp == seq_link->startdisp) ? 1 : 0;
int right_match = (seq->enddisp == seq_link->enddisp) ? 1 : 0;
if (left_match && right_match) {
seq->flag &= ~(SELECT | SEQ_LEFTSEL | SEQ_RIGHTSEL);
seq->flag |= seq_link->flag & (SELECT | SEQ_LEFTSEL | SEQ_RIGHTSEL);
recurs_sel_seq(seq);
}
else if (seq_link->flag & SELECT && (left_match || right_match)) {
seq->flag &= ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
if (left_match && seq_link->flag & SEQ_LEFTSEL) {
seq->flag |= SELECT | SEQ_LEFTSEL;
}
if (right_match && seq_link->flag & SEQ_RIGHTSEL) {
seq->flag |= SELECT | SEQ_RIGHTSEL;
}
recurs_sel_seq(seq);
}
}
}
} | [
"static",
"void",
"select_linked_time",
"(",
"ListBase",
"*",
"seqbase",
",",
"Sequence",
"*",
"seq_link",
")",
"{",
"Sequence",
"*",
"seq",
";",
"for",
"(",
"seq",
"=",
"seqbase",
"->",
"first",
";",
"seq",
";",
"seq",
"=",
"seq",
"->",
"next",
")",
"{",
"if",
"(",
"seq_link",
"->",
"machine",
"!=",
"seq",
"->",
"machine",
")",
"{",
"int",
"left_match",
"=",
"(",
"seq",
"->",
"startdisp",
"==",
"seq_link",
"->",
"startdisp",
")",
"?",
"1",
":",
"0",
";",
"int",
"right_match",
"=",
"(",
"seq",
"->",
"enddisp",
"==",
"seq_link",
"->",
"enddisp",
")",
"?",
"1",
":",
"0",
";",
"if",
"(",
"left_match",
"&&",
"right_match",
")",
"{",
"seq",
"->",
"flag",
"&=",
"~",
"(",
"SELECT",
"|",
"SEQ_LEFTSEL",
"|",
"SEQ_RIGHTSEL",
")",
";",
"seq",
"->",
"flag",
"|=",
"seq_link",
"->",
"flag",
"&",
"(",
"SELECT",
"|",
"SEQ_LEFTSEL",
"|",
"SEQ_RIGHTSEL",
")",
";",
"recurs_sel_seq",
"(",
"seq",
")",
";",
"}",
"else",
"if",
"(",
"seq_link",
"->",
"flag",
"&",
"SELECT",
"&&",
"(",
"left_match",
"||",
"right_match",
")",
")",
"{",
"seq",
"->",
"flag",
"&=",
"~",
"(",
"SEQ_LEFTSEL",
"|",
"SEQ_RIGHTSEL",
")",
";",
"if",
"(",
"left_match",
"&&",
"seq_link",
"->",
"flag",
"&",
"SEQ_LEFTSEL",
")",
"{",
"seq",
"->",
"flag",
"|=",
"SELECT",
"|",
"SEQ_LEFTSEL",
";",
"}",
"if",
"(",
"right_match",
"&&",
"seq_link",
"->",
"flag",
"&",
"SEQ_RIGHTSEL",
")",
"{",
"seq",
"->",
"flag",
"|=",
"SELECT",
"|",
"SEQ_RIGHTSEL",
";",
"}",
"recurs_sel_seq",
"(",
"seq",
")",
";",
"}",
"}",
"}",
"}"
] | used for mouse selection in SEQUENCER_OT_select | [
"used",
"for",
"mouse",
"selection",
"in",
"SEQUENCER_OT_select"
] | [
"/* a direct match, copy the selection settinhs */",
"/* clear for reselection */"
] | [
{
"param": "seqbase",
"type": "ListBase"
},
{
"param": "seq_link",
"type": "Sequence"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "seqbase",
"type": "ListBase",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "seq_link",
"type": "Sequence",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a51b08f7525ac207b26a24a223eb0884b6697b05 | DemonRem/blender | source/blender/editors/space_sequencer/sequencer_select.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | sequencer_select_linked_pick_invoke | int | static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Scene *scene = CTX_data_scene(C);
View2D *v2d = UI_view2d_fromcontext(C);
bool extend = RNA_boolean_get(op->ptr, "extend");
Sequence *mouse_seq;
int selected, hand;
/* this works like UV, not mesh */
mouse_seq = find_nearest_seq(scene, v2d, &hand, event->mval);
if (!mouse_seq) {
return OPERATOR_FINISHED; /* user error as with mesh?? */
}
if (extend == 0) {
ED_sequencer_deselect_all(scene);
}
mouse_seq->flag |= SELECT;
recurs_sel_seq(mouse_seq);
selected = 1;
while (selected) {
selected = select_more_less_seq__internal(scene, 1, 1);
}
ED_outliner_select_sync_from_sequence_tag(C);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
return OPERATOR_FINISHED;
} | /* select pick linked operator (uses the mouse) */ | select pick linked operator (uses the mouse) | [
"select",
"pick",
"linked",
"operator",
"(",
"uses",
"the",
"mouse",
")"
] | static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Scene *scene = CTX_data_scene(C);
View2D *v2d = UI_view2d_fromcontext(C);
bool extend = RNA_boolean_get(op->ptr, "extend");
Sequence *mouse_seq;
int selected, hand;
mouse_seq = find_nearest_seq(scene, v2d, &hand, event->mval);
if (!mouse_seq) {
return OPERATOR_FINISHED;
}
if (extend == 0) {
ED_sequencer_deselect_all(scene);
}
mouse_seq->flag |= SELECT;
recurs_sel_seq(mouse_seq);
selected = 1;
while (selected) {
selected = select_more_less_seq__internal(scene, 1, 1);
}
ED_outliner_select_sync_from_sequence_tag(C);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
return OPERATOR_FINISHED;
} | [
"static",
"int",
"sequencer_select_linked_pick_invoke",
"(",
"bContext",
"*",
"C",
",",
"wmOperator",
"*",
"op",
",",
"const",
"wmEvent",
"*",
"event",
")",
"{",
"Scene",
"*",
"scene",
"=",
"CTX_data_scene",
"(",
"C",
")",
";",
"View2D",
"*",
"v2d",
"=",
"UI_view2d_fromcontext",
"(",
"C",
")",
";",
"bool",
"extend",
"=",
"RNA_boolean_get",
"(",
"op",
"->",
"ptr",
",",
"\"",
"\"",
")",
";",
"Sequence",
"*",
"mouse_seq",
";",
"int",
"selected",
",",
"hand",
";",
"mouse_seq",
"=",
"find_nearest_seq",
"(",
"scene",
",",
"v2d",
",",
"&",
"hand",
",",
"event",
"->",
"mval",
")",
";",
"if",
"(",
"!",
"mouse_seq",
")",
"{",
"return",
"OPERATOR_FINISHED",
";",
"}",
"if",
"(",
"extend",
"==",
"0",
")",
"{",
"ED_sequencer_deselect_all",
"(",
"scene",
")",
";",
"}",
"mouse_seq",
"->",
"flag",
"|=",
"SELECT",
";",
"recurs_sel_seq",
"(",
"mouse_seq",
")",
";",
"selected",
"=",
"1",
";",
"while",
"(",
"selected",
")",
"{",
"selected",
"=",
"select_more_less_seq__internal",
"(",
"scene",
",",
"1",
",",
"1",
")",
";",
"}",
"ED_outliner_select_sync_from_sequence_tag",
"(",
"C",
")",
";",
"WM_event_add_notifier",
"(",
"C",
",",
"NC_SCENE",
"|",
"ND_SEQUENCER",
"|",
"NA_SELECTED",
",",
"scene",
")",
";",
"return",
"OPERATOR_FINISHED",
";",
"}"
] | select pick linked operator (uses the mouse) | [
"select",
"pick",
"linked",
"operator",
"(",
"uses",
"the",
"mouse",
")"
] | [
"/* this works like UV, not mesh */",
"/* user error as with mesh?? */"
] | [
{
"param": "C",
"type": "bContext"
},
{
"param": "op",
"type": "wmOperator"
},
{
"param": "event",
"type": "wmEvent"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "C",
"type": "bContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "wmOperator",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "event",
"type": "wmEvent",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dc7288234b34327bd933c439a91a943d794a36b7 | DemonRem/blender | source/blender/render/intern/source/imagetexture.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | ibuf_get_color | void | static void ibuf_get_color(float col[4], struct ImBuf *ibuf, int x, int y)
{
int ofs = y * ibuf->x + x;
if (ibuf->rect_float) {
if (ibuf->channels == 4) {
const float *fp = ibuf->rect_float + 4 * ofs;
copy_v4_v4(col, fp);
}
else if (ibuf->channels == 3) {
const float *fp = ibuf->rect_float + 3 * ofs;
copy_v3_v3(col, fp);
col[3] = 1.0f;
}
else {
const float *fp = ibuf->rect_float + ofs;
col[0] = col[1] = col[2] = col[3] = *fp;
}
}
else {
const char *rect = (char *)(ibuf->rect + ofs);
col[0] = ((float)rect[0]) * (1.0f / 255.0f);
col[1] = ((float)rect[1]) * (1.0f / 255.0f);
col[2] = ((float)rect[2]) * (1.0f / 255.0f);
col[3] = ((float)rect[3]) * (1.0f / 255.0f);
/* bytes are internally straight, however render pipeline seems to expect premul */
col[0] *= col[3];
col[1] *= col[3];
col[2] *= col[3];
}
} | /* x and y have to be checked for image size */ | x and y have to be checked for image size | [
"x",
"and",
"y",
"have",
"to",
"be",
"checked",
"for",
"image",
"size"
] | static void ibuf_get_color(float col[4], struct ImBuf *ibuf, int x, int y)
{
int ofs = y * ibuf->x + x;
if (ibuf->rect_float) {
if (ibuf->channels == 4) {
const float *fp = ibuf->rect_float + 4 * ofs;
copy_v4_v4(col, fp);
}
else if (ibuf->channels == 3) {
const float *fp = ibuf->rect_float + 3 * ofs;
copy_v3_v3(col, fp);
col[3] = 1.0f;
}
else {
const float *fp = ibuf->rect_float + ofs;
col[0] = col[1] = col[2] = col[3] = *fp;
}
}
else {
const char *rect = (char *)(ibuf->rect + ofs);
col[0] = ((float)rect[0]) * (1.0f / 255.0f);
col[1] = ((float)rect[1]) * (1.0f / 255.0f);
col[2] = ((float)rect[2]) * (1.0f / 255.0f);
col[3] = ((float)rect[3]) * (1.0f / 255.0f);
col[0] *= col[3];
col[1] *= col[3];
col[2] *= col[3];
}
} | [
"static",
"void",
"ibuf_get_color",
"(",
"float",
"col",
"[",
"4",
"]",
",",
"struct",
"ImBuf",
"*",
"ibuf",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"int",
"ofs",
"=",
"y",
"*",
"ibuf",
"->",
"x",
"+",
"x",
";",
"if",
"(",
"ibuf",
"->",
"rect_float",
")",
"{",
"if",
"(",
"ibuf",
"->",
"channels",
"==",
"4",
")",
"{",
"const",
"float",
"*",
"fp",
"=",
"ibuf",
"->",
"rect_float",
"+",
"4",
"*",
"ofs",
";",
"copy_v4_v4",
"(",
"col",
",",
"fp",
")",
";",
"}",
"else",
"if",
"(",
"ibuf",
"->",
"channels",
"==",
"3",
")",
"{",
"const",
"float",
"*",
"fp",
"=",
"ibuf",
"->",
"rect_float",
"+",
"3",
"*",
"ofs",
";",
"copy_v3_v3",
"(",
"col",
",",
"fp",
")",
";",
"col",
"[",
"3",
"]",
"=",
"1.0f",
";",
"}",
"else",
"{",
"const",
"float",
"*",
"fp",
"=",
"ibuf",
"->",
"rect_float",
"+",
"ofs",
";",
"col",
"[",
"0",
"]",
"=",
"col",
"[",
"1",
"]",
"=",
"col",
"[",
"2",
"]",
"=",
"col",
"[",
"3",
"]",
"=",
"*",
"fp",
";",
"}",
"}",
"else",
"{",
"const",
"char",
"*",
"rect",
"=",
"(",
"char",
"*",
")",
"(",
"ibuf",
"->",
"rect",
"+",
"ofs",
")",
";",
"col",
"[",
"0",
"]",
"=",
"(",
"(",
"float",
")",
"rect",
"[",
"0",
"]",
")",
"*",
"(",
"1.0f",
"/",
"255.0f",
")",
";",
"col",
"[",
"1",
"]",
"=",
"(",
"(",
"float",
")",
"rect",
"[",
"1",
"]",
")",
"*",
"(",
"1.0f",
"/",
"255.0f",
")",
";",
"col",
"[",
"2",
"]",
"=",
"(",
"(",
"float",
")",
"rect",
"[",
"2",
"]",
")",
"*",
"(",
"1.0f",
"/",
"255.0f",
")",
";",
"col",
"[",
"3",
"]",
"=",
"(",
"(",
"float",
")",
"rect",
"[",
"3",
"]",
")",
"*",
"(",
"1.0f",
"/",
"255.0f",
")",
";",
"col",
"[",
"0",
"]",
"*=",
"col",
"[",
"3",
"]",
";",
"col",
"[",
"1",
"]",
"*=",
"col",
"[",
"3",
"]",
";",
"col",
"[",
"2",
"]",
"*=",
"col",
"[",
"3",
"]",
";",
"}",
"}"
] | x and y have to be checked for image size | [
"x",
"and",
"y",
"have",
"to",
"be",
"checked",
"for",
"image",
"size"
] | [
"/* bytes are internally straight, however render pipeline seems to expect premul */"
] | [
{
"param": "col",
"type": "float"
},
{
"param": "ibuf",
"type": "struct ImBuf"
},
{
"param": "x",
"type": "int"
},
{
"param": "y",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "col",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ibuf",
"type": "struct ImBuf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dc7288234b34327bd933c439a91a943d794a36b7 | DemonRem/blender | source/blender/render/intern/source/imagetexture.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | ibuf_get_color_clip | int | static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extflag)
{
int clip = 0;
switch (extflag) {
case TXC_XMIR: /* y rep */
x %= 2 * ibuf->x;
x += x < 0 ? 2 * ibuf->x : 0;
x = x >= ibuf->x ? 2 * ibuf->x - x - 1 : x;
y %= ibuf->y;
y += y < 0 ? ibuf->y : 0;
break;
case TXC_YMIR: /* x rep */
x %= ibuf->x;
x += x < 0 ? ibuf->x : 0;
y %= 2 * ibuf->y;
y += y < 0 ? 2 * ibuf->y : 0;
y = y >= ibuf->y ? 2 * ibuf->y - y - 1 : y;
break;
case TXC_EXTD:
x = (x < 0) ? 0 : ((x >= ibuf->x) ? (ibuf->x - 1) : x);
y = (y < 0) ? 0 : ((y >= ibuf->y) ? (ibuf->y - 1) : y);
break;
case TXC_REPT:
x %= ibuf->x;
x += (x < 0) ? ibuf->x : 0;
y %= ibuf->y;
y += (y < 0) ? ibuf->y : 0;
break;
default: { /* as extend, if clipped, set alpha to 0.0 */
if (x < 0) {
x = 0;
} /* TXF alpha: clip = 1; } */
if (x >= ibuf->x) {
x = ibuf->x - 1;
} /* TXF alpha: clip = 1; } */
if (y < 0) {
y = 0;
} /* TXF alpha: clip = 1; } */
if (y >= ibuf->y) {
y = ibuf->y - 1;
} /* TXF alpha: clip = 1; } */
}
}
if (ibuf->rect_float) {
const float *fp = ibuf->rect_float + (x + y * ibuf->x) * ibuf->channels;
if (ibuf->channels == 1) {
col[0] = col[1] = col[2] = col[3] = *fp;
}
else {
col[0] = fp[0];
col[1] = fp[1];
col[2] = fp[2];
col[3] = clip ? 0.f : (ibuf->channels == 4 ? fp[3] : 1.f);
}
}
else {
const char *rect = (char *)(ibuf->rect + x + y * ibuf->x);
float inv_alpha_fac = (1.0f / 255.0f) * rect[3] * (1.0f / 255.0f);
col[0] = rect[0] * inv_alpha_fac;
col[1] = rect[1] * inv_alpha_fac;
col[2] = rect[2] * inv_alpha_fac;
col[3] = clip ? 0.f : rect[3] * (1.f / 255.f);
}
return clip;
} | /* similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags
* returns true if out of range in clipmode */ | similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags
returns true if out of range in clipmode | [
"similar",
"to",
"ibuf_get_color",
"()",
"but",
"clips",
"/",
"wraps",
"coords",
"according",
"to",
"repeat",
"/",
"extend",
"flags",
"returns",
"true",
"if",
"out",
"of",
"range",
"in",
"clipmode"
] | static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extflag)
{
int clip = 0;
switch (extflag) {
case TXC_XMIR:
x %= 2 * ibuf->x;
x += x < 0 ? 2 * ibuf->x : 0;
x = x >= ibuf->x ? 2 * ibuf->x - x - 1 : x;
y %= ibuf->y;
y += y < 0 ? ibuf->y : 0;
break;
case TXC_YMIR:
x %= ibuf->x;
x += x < 0 ? ibuf->x : 0;
y %= 2 * ibuf->y;
y += y < 0 ? 2 * ibuf->y : 0;
y = y >= ibuf->y ? 2 * ibuf->y - y - 1 : y;
break;
case TXC_EXTD:
x = (x < 0) ? 0 : ((x >= ibuf->x) ? (ibuf->x - 1) : x);
y = (y < 0) ? 0 : ((y >= ibuf->y) ? (ibuf->y - 1) : y);
break;
case TXC_REPT:
x %= ibuf->x;
x += (x < 0) ? ibuf->x : 0;
y %= ibuf->y;
y += (y < 0) ? ibuf->y : 0;
break;
default: {
if (x < 0) {
x = 0;
}
if (x >= ibuf->x) {
x = ibuf->x - 1;
}
if (y < 0) {
y = 0;
}
if (y >= ibuf->y) {
y = ibuf->y - 1;
}
}
}
if (ibuf->rect_float) {
const float *fp = ibuf->rect_float + (x + y * ibuf->x) * ibuf->channels;
if (ibuf->channels == 1) {
col[0] = col[1] = col[2] = col[3] = *fp;
}
else {
col[0] = fp[0];
col[1] = fp[1];
col[2] = fp[2];
col[3] = clip ? 0.f : (ibuf->channels == 4 ? fp[3] : 1.f);
}
}
else {
const char *rect = (char *)(ibuf->rect + x + y * ibuf->x);
float inv_alpha_fac = (1.0f / 255.0f) * rect[3] * (1.0f / 255.0f);
col[0] = rect[0] * inv_alpha_fac;
col[1] = rect[1] * inv_alpha_fac;
col[2] = rect[2] * inv_alpha_fac;
col[3] = clip ? 0.f : rect[3] * (1.f / 255.f);
}
return clip;
} | [
"static",
"int",
"ibuf_get_color_clip",
"(",
"float",
"col",
"[",
"4",
"]",
",",
"ImBuf",
"*",
"ibuf",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"extflag",
")",
"{",
"int",
"clip",
"=",
"0",
";",
"switch",
"(",
"extflag",
")",
"{",
"case",
"TXC_XMIR",
":",
"x",
"%=",
"2",
"*",
"ibuf",
"->",
"x",
";",
"x",
"+=",
"x",
"<",
"0",
"?",
"2",
"*",
"ibuf",
"->",
"x",
":",
"0",
";",
"x",
"=",
"x",
">=",
"ibuf",
"->",
"x",
"?",
"2",
"*",
"ibuf",
"->",
"x",
"-",
"x",
"-",
"1",
":",
"x",
";",
"y",
"%=",
"ibuf",
"->",
"y",
";",
"y",
"+=",
"y",
"<",
"0",
"?",
"ibuf",
"->",
"y",
":",
"0",
";",
"break",
";",
"case",
"TXC_YMIR",
":",
"x",
"%=",
"ibuf",
"->",
"x",
";",
"x",
"+=",
"x",
"<",
"0",
"?",
"ibuf",
"->",
"x",
":",
"0",
";",
"y",
"%=",
"2",
"*",
"ibuf",
"->",
"y",
";",
"y",
"+=",
"y",
"<",
"0",
"?",
"2",
"*",
"ibuf",
"->",
"y",
":",
"0",
";",
"y",
"=",
"y",
">=",
"ibuf",
"->",
"y",
"?",
"2",
"*",
"ibuf",
"->",
"y",
"-",
"y",
"-",
"1",
":",
"y",
";",
"break",
";",
"case",
"TXC_EXTD",
":",
"x",
"=",
"(",
"x",
"<",
"0",
")",
"?",
"0",
":",
"(",
"(",
"x",
">=",
"ibuf",
"->",
"x",
")",
"?",
"(",
"ibuf",
"->",
"x",
"-",
"1",
")",
":",
"x",
")",
";",
"y",
"=",
"(",
"y",
"<",
"0",
")",
"?",
"0",
":",
"(",
"(",
"y",
">=",
"ibuf",
"->",
"y",
")",
"?",
"(",
"ibuf",
"->",
"y",
"-",
"1",
")",
":",
"y",
")",
";",
"break",
";",
"case",
"TXC_REPT",
":",
"x",
"%=",
"ibuf",
"->",
"x",
";",
"x",
"+=",
"(",
"x",
"<",
"0",
")",
"?",
"ibuf",
"->",
"x",
":",
"0",
";",
"y",
"%=",
"ibuf",
"->",
"y",
";",
"y",
"+=",
"(",
"y",
"<",
"0",
")",
"?",
"ibuf",
"->",
"y",
":",
"0",
";",
"break",
";",
"default",
":",
"{",
"if",
"(",
"x",
"<",
"0",
")",
"{",
"x",
"=",
"0",
";",
"}",
"if",
"(",
"x",
">=",
"ibuf",
"->",
"x",
")",
"{",
"x",
"=",
"ibuf",
"->",
"x",
"-",
"1",
";",
"}",
"if",
"(",
"y",
"<",
"0",
")",
"{",
"y",
"=",
"0",
";",
"}",
"if",
"(",
"y",
">=",
"ibuf",
"->",
"y",
")",
"{",
"y",
"=",
"ibuf",
"->",
"y",
"-",
"1",
";",
"}",
"}",
"}",
"if",
"(",
"ibuf",
"->",
"rect_float",
")",
"{",
"const",
"float",
"*",
"fp",
"=",
"ibuf",
"->",
"rect_float",
"+",
"(",
"x",
"+",
"y",
"*",
"ibuf",
"->",
"x",
")",
"*",
"ibuf",
"->",
"channels",
";",
"if",
"(",
"ibuf",
"->",
"channels",
"==",
"1",
")",
"{",
"col",
"[",
"0",
"]",
"=",
"col",
"[",
"1",
"]",
"=",
"col",
"[",
"2",
"]",
"=",
"col",
"[",
"3",
"]",
"=",
"*",
"fp",
";",
"}",
"else",
"{",
"col",
"[",
"0",
"]",
"=",
"fp",
"[",
"0",
"]",
";",
"col",
"[",
"1",
"]",
"=",
"fp",
"[",
"1",
"]",
";",
"col",
"[",
"2",
"]",
"=",
"fp",
"[",
"2",
"]",
";",
"col",
"[",
"3",
"]",
"=",
"clip",
"?",
"0.f",
":",
"(",
"ibuf",
"->",
"channels",
"==",
"4",
"?",
"fp",
"[",
"3",
"]",
":",
"1.f",
")",
";",
"}",
"}",
"else",
"{",
"const",
"char",
"*",
"rect",
"=",
"(",
"char",
"*",
")",
"(",
"ibuf",
"->",
"rect",
"+",
"x",
"+",
"y",
"*",
"ibuf",
"->",
"x",
")",
";",
"float",
"inv_alpha_fac",
"=",
"(",
"1.0f",
"/",
"255.0f",
")",
"*",
"rect",
"[",
"3",
"]",
"*",
"(",
"1.0f",
"/",
"255.0f",
")",
";",
"col",
"[",
"0",
"]",
"=",
"rect",
"[",
"0",
"]",
"*",
"inv_alpha_fac",
";",
"col",
"[",
"1",
"]",
"=",
"rect",
"[",
"1",
"]",
"*",
"inv_alpha_fac",
";",
"col",
"[",
"2",
"]",
"=",
"rect",
"[",
"2",
"]",
"*",
"inv_alpha_fac",
";",
"col",
"[",
"3",
"]",
"=",
"clip",
"?",
"0.f",
":",
"rect",
"[",
"3",
"]",
"*",
"(",
"1.f",
"/",
"255.f",
")",
";",
"}",
"return",
"clip",
";",
"}"
] | similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags
returns true if out of range in clipmode | [
"similar",
"to",
"ibuf_get_color",
"()",
"but",
"clips",
"/",
"wraps",
"coords",
"according",
"to",
"repeat",
"/",
"extend",
"flags",
"returns",
"true",
"if",
"out",
"of",
"range",
"in",
"clipmode"
] | [
"/* y rep */",
"/* x rep */",
"/* as extend, if clipped, set alpha to 0.0 */",
"/* TXF alpha: clip = 1; } */",
"/* TXF alpha: clip = 1; } */",
"/* TXF alpha: clip = 1; } */",
"/* TXF alpha: clip = 1; } */"
] | [
{
"param": "col",
"type": "float"
},
{
"param": "ibuf",
"type": "ImBuf"
},
{
"param": "x",
"type": "int"
},
{
"param": "y",
"type": "int"
},
{
"param": "extflag",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "col",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ibuf",
"type": "ImBuf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "extflag",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c74afd2d8e21de6a62075fc5d22213aedf5c89d | DemonRem/blender | source/blender/gpu/intern/gpu_buffers.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | gpu_pbvh_vert_buf_data_set | bool | static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, uint vert_len)
{
/* Keep so we can test #GPU_USAGE_DYNAMIC buffer use.
* Not that format initialization match in both blocks.
* Do this to keep braces balanced - otherwise indentation breaks. */
#if 0
if (buffers->vert_buf == NULL) {
/* Initialize vertex buffer (match 'VertexBufferFormat'). */
buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&g_vbo_id.format, GPU_USAGE_DYNAMIC);
GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len);
}
else if (vert_len != buffers->vert_buf->vertex_len) {
GPU_vertbuf_data_resize(buffers->vert_buf, vert_len);
}
#else
if (buffers->vert_buf == NULL) {
/* Initialize vertex buffer (match 'VertexBufferFormat'). */
buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&g_vbo_id.format, GPU_USAGE_STATIC);
}
GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len);
#endif
return buffers->vert_buf->data != NULL;
} | /* Allocates a non-initialized buffer to be sent to GPU.
* Return is false it indicates that the memory map failed. */ | Allocates a non-initialized buffer to be sent to GPU.
Return is false it indicates that the memory map failed. | [
"Allocates",
"a",
"non",
"-",
"initialized",
"buffer",
"to",
"be",
"sent",
"to",
"GPU",
".",
"Return",
"is",
"false",
"it",
"indicates",
"that",
"the",
"memory",
"map",
"failed",
"."
] | static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, uint vert_len)
{
#if 0
if (buffers->vert_buf == NULL) {
buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&g_vbo_id.format, GPU_USAGE_DYNAMIC);
GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len);
}
else if (vert_len != buffers->vert_buf->vertex_len) {
GPU_vertbuf_data_resize(buffers->vert_buf, vert_len);
}
#else
if (buffers->vert_buf == NULL) {
buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&g_vbo_id.format, GPU_USAGE_STATIC);
}
GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len);
#endif
return buffers->vert_buf->data != NULL;
} | [
"static",
"bool",
"gpu_pbvh_vert_buf_data_set",
"(",
"GPU_PBVH_Buffers",
"*",
"buffers",
",",
"uint",
"vert_len",
")",
"{",
"#if",
"0",
"\n",
"if",
"(",
"buffers",
"->",
"vert_buf",
"==",
"NULL",
")",
"{",
"buffers",
"->",
"vert_buf",
"=",
"GPU_vertbuf_create_with_format_ex",
"(",
"&",
"g_vbo_id",
".",
"format",
",",
"GPU_USAGE_DYNAMIC",
")",
";",
"GPU_vertbuf_data_alloc",
"(",
"buffers",
"->",
"vert_buf",
",",
"vert_len",
")",
";",
"}",
"else",
"if",
"(",
"vert_len",
"!=",
"buffers",
"->",
"vert_buf",
"->",
"vertex_len",
")",
"{",
"GPU_vertbuf_data_resize",
"(",
"buffers",
"->",
"vert_buf",
",",
"vert_len",
")",
";",
"}",
"#else",
"if",
"(",
"buffers",
"->",
"vert_buf",
"==",
"NULL",
")",
"{",
"buffers",
"->",
"vert_buf",
"=",
"GPU_vertbuf_create_with_format_ex",
"(",
"&",
"g_vbo_id",
".",
"format",
",",
"GPU_USAGE_STATIC",
")",
";",
"}",
"GPU_vertbuf_data_alloc",
"(",
"buffers",
"->",
"vert_buf",
",",
"vert_len",
")",
";",
"#endif",
"return",
"buffers",
"->",
"vert_buf",
"->",
"data",
"!=",
"NULL",
";",
"}"
] | Allocates a non-initialized buffer to be sent to GPU. | [
"Allocates",
"a",
"non",
"-",
"initialized",
"buffer",
"to",
"be",
"sent",
"to",
"GPU",
"."
] | [
"/* Keep so we can test #GPU_USAGE_DYNAMIC buffer use.\n * Not that format initialization match in both blocks.\n * Do this to keep braces balanced - otherwise indentation breaks. */",
"/* Initialize vertex buffer (match 'VertexBufferFormat'). */",
"/* Initialize vertex buffer (match 'VertexBufferFormat'). */"
] | [
{
"param": "buffers",
"type": "GPU_PBVH_Buffers"
},
{
"param": "vert_len",
"type": "uint"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "buffers",
"type": "GPU_PBVH_Buffers",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vert_len",
"type": "uint",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c74afd2d8e21de6a62075fc5d22213aedf5c89d | DemonRem/blender | source/blender/gpu/intern/gpu_buffers.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | GPU_pbvh_mesh_buffers_update | void | void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
const MVert *mvert,
const int *vert_indices,
int totvert,
const float *vmask,
const MLoopCol *vcol,
const int (*face_vert_indices)[3],
const int update_flags)
{
const bool show_mask = vmask && (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0;
const bool show_vcol = vcol && (update_flags & GPU_PBVH_BUFFERS_SHOW_VCOL) != 0;
bool empty_mask = true;
{
int totelem = (buffers->smooth ? totvert : (buffers->tot_tri * 3));
/* Build VBO */
if (gpu_pbvh_vert_buf_data_set(buffers, totelem)) {
GPUVertBufRaw pos_step = {0};
GPUVertBufRaw nor_step = {0};
GPUVertBufRaw msk_step = {0};
GPUVertBufRaw col_step = {0};
GPU_vertbuf_attr_get_raw_data(buffers->vert_buf, g_vbo_id.pos, &pos_step);
GPU_vertbuf_attr_get_raw_data(buffers->vert_buf, g_vbo_id.nor, &nor_step);
if (show_mask) {
GPU_vertbuf_attr_get_raw_data(buffers->vert_buf, g_vbo_id.msk, &msk_step);
}
if (show_vcol) {
GPU_vertbuf_attr_get_raw_data(buffers->vert_buf, g_vbo_id.col, &col_step);
}
/* Vertex data is shared if smooth-shaded, but separate
* copies are made for flat shading because normals
* shouldn't be shared. */
if (buffers->smooth) {
for (uint i = 0; i < totvert; i++) {
const int vidx = vert_indices[i];
const MVert *v = &mvert[vidx];
copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), v->co);
copy_v3_v3_short(GPU_vertbuf_raw_step(&nor_step), v->no);
if (show_mask) {
float mask = vmask[vidx];
*(float *)GPU_vertbuf_raw_step(&msk_step) = mask;
empty_mask = empty_mask && (mask == 0.0f);
}
}
if (show_vcol) {
for (uint i = 0; i < buffers->face_indices_len; i++) {
const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]];
for (int j = 0; j < 3; j++) {
const int loop_index = lt->tri[j];
const int vidx = face_vert_indices[i][j];
const uchar *elem = &vcol[loop_index].r;
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, elem);
}
}
}
}
else {
/* calculate normal for each polygon only once */
uint mpoly_prev = UINT_MAX;
short no[3] = {0, 0, 0};
for (uint i = 0; i < buffers->face_indices_len; i++) {
const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]];
const uint vtri[3] = {
buffers->mloop[lt->tri[0]].v,
buffers->mloop[lt->tri[1]].v,
buffers->mloop[lt->tri[2]].v,
};
if (paint_is_face_hidden(lt, mvert, buffers->mloop)) {
continue;
}
/* Face normal and mask */
if (lt->poly != mpoly_prev) {
const MPoly *mp = &buffers->mpoly[lt->poly];
float fno[3];
BKE_mesh_calc_poly_normal(mp, &buffers->mloop[mp->loopstart], mvert, fno);
normal_float_to_short_v3(no, fno);
mpoly_prev = lt->poly;
}
float fmask = 0.0f;
if (show_mask) {
fmask = (vmask[vtri[0]] + vmask[vtri[1]] + vmask[vtri[2]]) / 3.0f;
}
for (uint j = 0; j < 3; j++) {
const MVert *v = &mvert[vtri[j]];
copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), v->co);
copy_v3_v3_short(GPU_vertbuf_raw_step(&nor_step), no);
if (show_mask) {
*(float *)GPU_vertbuf_raw_step(&msk_step) = fmask;
empty_mask = empty_mask && (fmask == 0.0f);
}
if (show_vcol) {
const uint loop_index = lt->tri[j];
const uchar *elem = &vcol[loop_index].r;
memcpy(GPU_vertbuf_raw_step(&col_step), elem, sizeof(uchar) * 4);
}
}
}
}
gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS);
}
}
/* Get material index from the first face of this buffer. */
const MLoopTri *lt = &buffers->looptri[buffers->face_indices[0]];
const MPoly *mp = &buffers->mpoly[lt->poly];
buffers->material_index = mp->mat_nr;
buffers->show_mask = !empty_mask;
buffers->mvert = mvert;
} | /* Threaded - do not call any functions that use OpenGL calls! */ | do not call any functions that use OpenGL calls! | [
"do",
"not",
"call",
"any",
"functions",
"that",
"use",
"OpenGL",
"calls!"
] | void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
const MVert *mvert,
const int *vert_indices,
int totvert,
const float *vmask,
const MLoopCol *vcol,
const int (*face_vert_indices)[3],
const int update_flags)
{
const bool show_mask = vmask && (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0;
const bool show_vcol = vcol && (update_flags & GPU_PBVH_BUFFERS_SHOW_VCOL) != 0;
bool empty_mask = true;
{
int totelem = (buffers->smooth ? totvert : (buffers->tot_tri * 3));
if (gpu_pbvh_vert_buf_data_set(buffers, totelem)) {
GPUVertBufRaw pos_step = {0};
GPUVertBufRaw nor_step = {0};
GPUVertBufRaw msk_step = {0};
GPUVertBufRaw col_step = {0};
GPU_vertbuf_attr_get_raw_data(buffers->vert_buf, g_vbo_id.pos, &pos_step);
GPU_vertbuf_attr_get_raw_data(buffers->vert_buf, g_vbo_id.nor, &nor_step);
if (show_mask) {
GPU_vertbuf_attr_get_raw_data(buffers->vert_buf, g_vbo_id.msk, &msk_step);
}
if (show_vcol) {
GPU_vertbuf_attr_get_raw_data(buffers->vert_buf, g_vbo_id.col, &col_step);
}
if (buffers->smooth) {
for (uint i = 0; i < totvert; i++) {
const int vidx = vert_indices[i];
const MVert *v = &mvert[vidx];
copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), v->co);
copy_v3_v3_short(GPU_vertbuf_raw_step(&nor_step), v->no);
if (show_mask) {
float mask = vmask[vidx];
*(float *)GPU_vertbuf_raw_step(&msk_step) = mask;
empty_mask = empty_mask && (mask == 0.0f);
}
}
if (show_vcol) {
for (uint i = 0; i < buffers->face_indices_len; i++) {
const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]];
for (int j = 0; j < 3; j++) {
const int loop_index = lt->tri[j];
const int vidx = face_vert_indices[i][j];
const uchar *elem = &vcol[loop_index].r;
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, elem);
}
}
}
}
else {
uint mpoly_prev = UINT_MAX;
short no[3] = {0, 0, 0};
for (uint i = 0; i < buffers->face_indices_len; i++) {
const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]];
const uint vtri[3] = {
buffers->mloop[lt->tri[0]].v,
buffers->mloop[lt->tri[1]].v,
buffers->mloop[lt->tri[2]].v,
};
if (paint_is_face_hidden(lt, mvert, buffers->mloop)) {
continue;
}
if (lt->poly != mpoly_prev) {
const MPoly *mp = &buffers->mpoly[lt->poly];
float fno[3];
BKE_mesh_calc_poly_normal(mp, &buffers->mloop[mp->loopstart], mvert, fno);
normal_float_to_short_v3(no, fno);
mpoly_prev = lt->poly;
}
float fmask = 0.0f;
if (show_mask) {
fmask = (vmask[vtri[0]] + vmask[vtri[1]] + vmask[vtri[2]]) / 3.0f;
}
for (uint j = 0; j < 3; j++) {
const MVert *v = &mvert[vtri[j]];
copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), v->co);
copy_v3_v3_short(GPU_vertbuf_raw_step(&nor_step), no);
if (show_mask) {
*(float *)GPU_vertbuf_raw_step(&msk_step) = fmask;
empty_mask = empty_mask && (fmask == 0.0f);
}
if (show_vcol) {
const uint loop_index = lt->tri[j];
const uchar *elem = &vcol[loop_index].r;
memcpy(GPU_vertbuf_raw_step(&col_step), elem, sizeof(uchar) * 4);
}
}
}
}
gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS);
}
}
const MLoopTri *lt = &buffers->looptri[buffers->face_indices[0]];
const MPoly *mp = &buffers->mpoly[lt->poly];
buffers->material_index = mp->mat_nr;
buffers->show_mask = !empty_mask;
buffers->mvert = mvert;
} | [
"void",
"GPU_pbvh_mesh_buffers_update",
"(",
"GPU_PBVH_Buffers",
"*",
"buffers",
",",
"const",
"MVert",
"*",
"mvert",
",",
"const",
"int",
"*",
"vert_indices",
",",
"int",
"totvert",
",",
"const",
"float",
"*",
"vmask",
",",
"const",
"MLoopCol",
"*",
"vcol",
",",
"const",
"int",
"(",
"*",
"face_vert_indices",
")",
"[",
"3",
"]",
",",
"const",
"int",
"update_flags",
")",
"{",
"const",
"bool",
"show_mask",
"=",
"vmask",
"&&",
"(",
"update_flags",
"&",
"GPU_PBVH_BUFFERS_SHOW_MASK",
")",
"!=",
"0",
";",
"const",
"bool",
"show_vcol",
"=",
"vcol",
"&&",
"(",
"update_flags",
"&",
"GPU_PBVH_BUFFERS_SHOW_VCOL",
")",
"!=",
"0",
";",
"bool",
"empty_mask",
"=",
"true",
";",
"{",
"int",
"totelem",
"=",
"(",
"buffers",
"->",
"smooth",
"?",
"totvert",
":",
"(",
"buffers",
"->",
"tot_tri",
"*",
"3",
")",
")",
";",
"if",
"(",
"gpu_pbvh_vert_buf_data_set",
"(",
"buffers",
",",
"totelem",
")",
")",
"{",
"GPUVertBufRaw",
"pos_step",
"=",
"{",
"0",
"}",
";",
"GPUVertBufRaw",
"nor_step",
"=",
"{",
"0",
"}",
";",
"GPUVertBufRaw",
"msk_step",
"=",
"{",
"0",
"}",
";",
"GPUVertBufRaw",
"col_step",
"=",
"{",
"0",
"}",
";",
"GPU_vertbuf_attr_get_raw_data",
"(",
"buffers",
"->",
"vert_buf",
",",
"g_vbo_id",
".",
"pos",
",",
"&",
"pos_step",
")",
";",
"GPU_vertbuf_attr_get_raw_data",
"(",
"buffers",
"->",
"vert_buf",
",",
"g_vbo_id",
".",
"nor",
",",
"&",
"nor_step",
")",
";",
"if",
"(",
"show_mask",
")",
"{",
"GPU_vertbuf_attr_get_raw_data",
"(",
"buffers",
"->",
"vert_buf",
",",
"g_vbo_id",
".",
"msk",
",",
"&",
"msk_step",
")",
";",
"}",
"if",
"(",
"show_vcol",
")",
"{",
"GPU_vertbuf_attr_get_raw_data",
"(",
"buffers",
"->",
"vert_buf",
",",
"g_vbo_id",
".",
"col",
",",
"&",
"col_step",
")",
";",
"}",
"if",
"(",
"buffers",
"->",
"smooth",
")",
"{",
"for",
"(",
"uint",
"i",
"=",
"0",
";",
"i",
"<",
"totvert",
";",
"i",
"++",
")",
"{",
"const",
"int",
"vidx",
"=",
"vert_indices",
"[",
"i",
"]",
";",
"const",
"MVert",
"*",
"v",
"=",
"&",
"mvert",
"[",
"vidx",
"]",
";",
"copy_v3_v3",
"(",
"GPU_vertbuf_raw_step",
"(",
"&",
"pos_step",
")",
",",
"v",
"->",
"co",
")",
";",
"copy_v3_v3_short",
"(",
"GPU_vertbuf_raw_step",
"(",
"&",
"nor_step",
")",
",",
"v",
"->",
"no",
")",
";",
"if",
"(",
"show_mask",
")",
"{",
"float",
"mask",
"=",
"vmask",
"[",
"vidx",
"]",
";",
"*",
"(",
"float",
"*",
")",
"GPU_vertbuf_raw_step",
"(",
"&",
"msk_step",
")",
"=",
"mask",
";",
"empty_mask",
"=",
"empty_mask",
"&&",
"(",
"mask",
"==",
"0.0f",
")",
";",
"}",
"}",
"if",
"(",
"show_vcol",
")",
"{",
"for",
"(",
"uint",
"i",
"=",
"0",
";",
"i",
"<",
"buffers",
"->",
"face_indices_len",
";",
"i",
"++",
")",
"{",
"const",
"MLoopTri",
"*",
"lt",
"=",
"&",
"buffers",
"->",
"looptri",
"[",
"buffers",
"->",
"face_indices",
"[",
"i",
"]",
"]",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"3",
";",
"j",
"++",
")",
"{",
"const",
"int",
"loop_index",
"=",
"lt",
"->",
"tri",
"[",
"j",
"]",
";",
"const",
"int",
"vidx",
"=",
"face_vert_indices",
"[",
"i",
"]",
"[",
"j",
"]",
";",
"const",
"uchar",
"*",
"elem",
"=",
"&",
"vcol",
"[",
"loop_index",
"]",
".",
"r",
";",
"GPU_vertbuf_attr_set",
"(",
"buffers",
"->",
"vert_buf",
",",
"g_vbo_id",
".",
"col",
",",
"vidx",
",",
"elem",
")",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"uint",
"mpoly_prev",
"=",
"UINT_MAX",
";",
"short",
"no",
"[",
"3",
"]",
"=",
"{",
"0",
",",
"0",
",",
"0",
"}",
";",
"for",
"(",
"uint",
"i",
"=",
"0",
";",
"i",
"<",
"buffers",
"->",
"face_indices_len",
";",
"i",
"++",
")",
"{",
"const",
"MLoopTri",
"*",
"lt",
"=",
"&",
"buffers",
"->",
"looptri",
"[",
"buffers",
"->",
"face_indices",
"[",
"i",
"]",
"]",
";",
"const",
"uint",
"vtri",
"[",
"3",
"]",
"=",
"{",
"buffers",
"->",
"mloop",
"[",
"lt",
"->",
"tri",
"[",
"0",
"]",
"]",
".",
"v",
",",
"buffers",
"->",
"mloop",
"[",
"lt",
"->",
"tri",
"[",
"1",
"]",
"]",
".",
"v",
",",
"buffers",
"->",
"mloop",
"[",
"lt",
"->",
"tri",
"[",
"2",
"]",
"]",
".",
"v",
",",
"}",
";",
"if",
"(",
"paint_is_face_hidden",
"(",
"lt",
",",
"mvert",
",",
"buffers",
"->",
"mloop",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"lt",
"->",
"poly",
"!=",
"mpoly_prev",
")",
"{",
"const",
"MPoly",
"*",
"mp",
"=",
"&",
"buffers",
"->",
"mpoly",
"[",
"lt",
"->",
"poly",
"]",
";",
"float",
"fno",
"[",
"3",
"]",
";",
"BKE_mesh_calc_poly_normal",
"(",
"mp",
",",
"&",
"buffers",
"->",
"mloop",
"[",
"mp",
"->",
"loopstart",
"]",
",",
"mvert",
",",
"fno",
")",
";",
"normal_float_to_short_v3",
"(",
"no",
",",
"fno",
")",
";",
"mpoly_prev",
"=",
"lt",
"->",
"poly",
";",
"}",
"float",
"fmask",
"=",
"0.0f",
";",
"if",
"(",
"show_mask",
")",
"{",
"fmask",
"=",
"(",
"vmask",
"[",
"vtri",
"[",
"0",
"]",
"]",
"+",
"vmask",
"[",
"vtri",
"[",
"1",
"]",
"]",
"+",
"vmask",
"[",
"vtri",
"[",
"2",
"]",
"]",
")",
"/",
"3.0f",
";",
"}",
"for",
"(",
"uint",
"j",
"=",
"0",
";",
"j",
"<",
"3",
";",
"j",
"++",
")",
"{",
"const",
"MVert",
"*",
"v",
"=",
"&",
"mvert",
"[",
"vtri",
"[",
"j",
"]",
"]",
";",
"copy_v3_v3",
"(",
"GPU_vertbuf_raw_step",
"(",
"&",
"pos_step",
")",
",",
"v",
"->",
"co",
")",
";",
"copy_v3_v3_short",
"(",
"GPU_vertbuf_raw_step",
"(",
"&",
"nor_step",
")",
",",
"no",
")",
";",
"if",
"(",
"show_mask",
")",
"{",
"*",
"(",
"float",
"*",
")",
"GPU_vertbuf_raw_step",
"(",
"&",
"msk_step",
")",
"=",
"fmask",
";",
"empty_mask",
"=",
"empty_mask",
"&&",
"(",
"fmask",
"==",
"0.0f",
")",
";",
"}",
"if",
"(",
"show_vcol",
")",
"{",
"const",
"uint",
"loop_index",
"=",
"lt",
"->",
"tri",
"[",
"j",
"]",
";",
"const",
"uchar",
"*",
"elem",
"=",
"&",
"vcol",
"[",
"loop_index",
"]",
".",
"r",
";",
"memcpy",
"(",
"GPU_vertbuf_raw_step",
"(",
"&",
"col_step",
")",
",",
"elem",
",",
"sizeof",
"(",
"uchar",
")",
"*",
"4",
")",
";",
"}",
"}",
"}",
"}",
"gpu_pbvh_batch_init",
"(",
"buffers",
",",
"GPU_PRIM_TRIS",
")",
";",
"}",
"}",
"const",
"MLoopTri",
"*",
"lt",
"=",
"&",
"buffers",
"->",
"looptri",
"[",
"buffers",
"->",
"face_indices",
"[",
"0",
"]",
"]",
";",
"const",
"MPoly",
"*",
"mp",
"=",
"&",
"buffers",
"->",
"mpoly",
"[",
"lt",
"->",
"poly",
"]",
";",
"buffers",
"->",
"material_index",
"=",
"mp",
"->",
"mat_nr",
";",
"buffers",
"->",
"show_mask",
"=",
"!",
"empty_mask",
";",
"buffers",
"->",
"mvert",
"=",
"mvert",
";",
"}"
] | Threaded - do not call any functions that use OpenGL calls! | [
"Threaded",
"-",
"do",
"not",
"call",
"any",
"functions",
"that",
"use",
"OpenGL",
"calls!"
] | [
"/* Build VBO */",
"/* Vertex data is shared if smooth-shaded, but separate\n * copies are made for flat shading because normals\n * shouldn't be shared. */",
"/* calculate normal for each polygon only once */",
"/* Face normal and mask */",
"/* Get material index from the first face of this buffer. */"
] | [
{
"param": "buffers",
"type": "GPU_PBVH_Buffers"
},
{
"param": "mvert",
"type": "MVert"
},
{
"param": "vert_indices",
"type": "int"
},
{
"param": "totvert",
"type": "int"
},
{
"param": "vmask",
"type": "float"
},
{
"param": "vcol",
"type": "MLoopCol"
},
{
"param": "face_vert_indices",
"type": "int"
},
{
"param": "update_flags",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "buffers",
"type": "GPU_PBVH_Buffers",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mvert",
"type": "MVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vert_indices",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "totvert",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vmask",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vcol",
"type": "MLoopCol",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "face_vert_indices",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "update_flags",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c74afd2d8e21de6a62075fc5d22213aedf5c89d | DemonRem/blender | source/blender/gpu/intern/gpu_buffers.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | GPU_pbvh_mesh_buffers_build | GPU_PBVH_Buffers | GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
const MPoly *mpoly,
const MLoop *mloop,
const MLoopTri *looptri,
const MVert *mvert,
const int *face_indices,
const int face_indices_len,
const struct Mesh *mesh)
{
GPU_PBVH_Buffers *buffers;
int i, tottri;
int tot_real_edges = 0;
buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers");
/* smooth or flat for all */
buffers->smooth = mpoly[looptri[face_indices[0]].poly].flag & ME_SMOOTH;
buffers->show_mask = false;
/* Count the number of visible triangles */
for (i = 0, tottri = 0; i < face_indices_len; i++) {
const MLoopTri *lt = &looptri[face_indices[i]];
if (!paint_is_face_hidden(lt, mvert, mloop)) {
int r_edges[3];
BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges);
for (int j = 0; j < 3; j++) {
if (r_edges[j] != -1) {
tot_real_edges++;
}
}
tottri++;
}
}
if (tottri == 0) {
buffers->tot_tri = 0;
buffers->mpoly = mpoly;
buffers->mloop = mloop;
buffers->looptri = looptri;
buffers->face_indices = face_indices;
buffers->face_indices_len = 0;
return buffers;
}
/* An element index buffer is used for smooth shading, but flat
* shading requires separate vertex normals so an index buffer
* can't be used there. */
if (buffers->smooth) {
/* Fill the triangle and line buffers. */
GPUIndexBufBuilder elb, elb_lines;
GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, INT_MAX);
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tot_real_edges, INT_MAX);
for (i = 0; i < face_indices_len; i++) {
const MLoopTri *lt = &looptri[face_indices[i]];
/* Skip hidden faces */
if (paint_is_face_hidden(lt, mvert, mloop)) {
continue;
}
GPU_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i]));
int r_edges[3];
BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges);
if (r_edges[0] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][0], face_vert_indices[i][1]);
}
if (r_edges[1] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][1], face_vert_indices[i][2]);
}
if (r_edges[2] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][2], face_vert_indices[i][0]);
}
}
buffers->index_buf = GPU_indexbuf_build(&elb);
buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
}
else {
/* Fill the only the line buffer. */
GPUIndexBufBuilder elb_lines;
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tot_real_edges, INT_MAX);
int vert_idx = 0;
for (i = 0; i < face_indices_len; i++) {
const MLoopTri *lt = &looptri[face_indices[i]];
/* Skip hidden faces */
if (paint_is_face_hidden(lt, mvert, mloop)) {
continue;
}
int r_edges[3];
BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges);
if (r_edges[0] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 0, vert_idx * 3 + 1);
}
if (r_edges[1] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 1, vert_idx * 3 + 2);
}
if (r_edges[2] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 2, vert_idx * 3 + 0);
}
vert_idx++;
}
buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
}
buffers->tot_tri = tottri;
buffers->mpoly = mpoly;
buffers->mloop = mloop;
buffers->looptri = looptri;
buffers->face_indices = face_indices;
buffers->face_indices_len = face_indices_len;
return buffers;
} | /* Threaded - do not call any functions that use OpenGL calls! */ | do not call any functions that use OpenGL calls! | [
"do",
"not",
"call",
"any",
"functions",
"that",
"use",
"OpenGL",
"calls!"
] | GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
const MPoly *mpoly,
const MLoop *mloop,
const MLoopTri *looptri,
const MVert *mvert,
const int *face_indices,
const int face_indices_len,
const struct Mesh *mesh)
{
GPU_PBVH_Buffers *buffers;
int i, tottri;
int tot_real_edges = 0;
buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers");
buffers->smooth = mpoly[looptri[face_indices[0]].poly].flag & ME_SMOOTH;
buffers->show_mask = false;
for (i = 0, tottri = 0; i < face_indices_len; i++) {
const MLoopTri *lt = &looptri[face_indices[i]];
if (!paint_is_face_hidden(lt, mvert, mloop)) {
int r_edges[3];
BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges);
for (int j = 0; j < 3; j++) {
if (r_edges[j] != -1) {
tot_real_edges++;
}
}
tottri++;
}
}
if (tottri == 0) {
buffers->tot_tri = 0;
buffers->mpoly = mpoly;
buffers->mloop = mloop;
buffers->looptri = looptri;
buffers->face_indices = face_indices;
buffers->face_indices_len = 0;
return buffers;
}
if (buffers->smooth) {
GPUIndexBufBuilder elb, elb_lines;
GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, INT_MAX);
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tot_real_edges, INT_MAX);
for (i = 0; i < face_indices_len; i++) {
const MLoopTri *lt = &looptri[face_indices[i]];
if (paint_is_face_hidden(lt, mvert, mloop)) {
continue;
}
GPU_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i]));
int r_edges[3];
BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges);
if (r_edges[0] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][0], face_vert_indices[i][1]);
}
if (r_edges[1] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][1], face_vert_indices[i][2]);
}
if (r_edges[2] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][2], face_vert_indices[i][0]);
}
}
buffers->index_buf = GPU_indexbuf_build(&elb);
buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
}
else {
GPUIndexBufBuilder elb_lines;
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tot_real_edges, INT_MAX);
int vert_idx = 0;
for (i = 0; i < face_indices_len; i++) {
const MLoopTri *lt = &looptri[face_indices[i]];
if (paint_is_face_hidden(lt, mvert, mloop)) {
continue;
}
int r_edges[3];
BKE_mesh_looptri_get_real_edges(mesh, lt, r_edges);
if (r_edges[0] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 0, vert_idx * 3 + 1);
}
if (r_edges[1] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 1, vert_idx * 3 + 2);
}
if (r_edges[2] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 2, vert_idx * 3 + 0);
}
vert_idx++;
}
buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
}
buffers->tot_tri = tottri;
buffers->mpoly = mpoly;
buffers->mloop = mloop;
buffers->looptri = looptri;
buffers->face_indices = face_indices;
buffers->face_indices_len = face_indices_len;
return buffers;
} | [
"GPU_PBVH_Buffers",
"*",
"GPU_pbvh_mesh_buffers_build",
"(",
"const",
"int",
"(",
"*",
"face_vert_indices",
")",
"[",
"3",
"]",
",",
"const",
"MPoly",
"*",
"mpoly",
",",
"const",
"MLoop",
"*",
"mloop",
",",
"const",
"MLoopTri",
"*",
"looptri",
",",
"const",
"MVert",
"*",
"mvert",
",",
"const",
"int",
"*",
"face_indices",
",",
"const",
"int",
"face_indices_len",
",",
"const",
"struct",
"Mesh",
"*",
"mesh",
")",
"{",
"GPU_PBVH_Buffers",
"*",
"buffers",
";",
"int",
"i",
",",
"tottri",
";",
"int",
"tot_real_edges",
"=",
"0",
";",
"buffers",
"=",
"MEM_callocN",
"(",
"sizeof",
"(",
"GPU_PBVH_Buffers",
")",
",",
"\"",
"\"",
")",
";",
"buffers",
"->",
"smooth",
"=",
"mpoly",
"[",
"looptri",
"[",
"face_indices",
"[",
"0",
"]",
"]",
".",
"poly",
"]",
".",
"flag",
"&",
"ME_SMOOTH",
";",
"buffers",
"->",
"show_mask",
"=",
"false",
";",
"for",
"(",
"i",
"=",
"0",
",",
"tottri",
"=",
"0",
";",
"i",
"<",
"face_indices_len",
";",
"i",
"++",
")",
"{",
"const",
"MLoopTri",
"*",
"lt",
"=",
"&",
"looptri",
"[",
"face_indices",
"[",
"i",
"]",
"]",
";",
"if",
"(",
"!",
"paint_is_face_hidden",
"(",
"lt",
",",
"mvert",
",",
"mloop",
")",
")",
"{",
"int",
"r_edges",
"[",
"3",
"]",
";",
"BKE_mesh_looptri_get_real_edges",
"(",
"mesh",
",",
"lt",
",",
"r_edges",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"3",
";",
"j",
"++",
")",
"{",
"if",
"(",
"r_edges",
"[",
"j",
"]",
"!=",
"-1",
")",
"{",
"tot_real_edges",
"++",
";",
"}",
"}",
"tottri",
"++",
";",
"}",
"}",
"if",
"(",
"tottri",
"==",
"0",
")",
"{",
"buffers",
"->",
"tot_tri",
"=",
"0",
";",
"buffers",
"->",
"mpoly",
"=",
"mpoly",
";",
"buffers",
"->",
"mloop",
"=",
"mloop",
";",
"buffers",
"->",
"looptri",
"=",
"looptri",
";",
"buffers",
"->",
"face_indices",
"=",
"face_indices",
";",
"buffers",
"->",
"face_indices_len",
"=",
"0",
";",
"return",
"buffers",
";",
"}",
"if",
"(",
"buffers",
"->",
"smooth",
")",
"{",
"GPUIndexBufBuilder",
"elb",
",",
"elb_lines",
";",
"GPU_indexbuf_init",
"(",
"&",
"elb",
",",
"GPU_PRIM_TRIS",
",",
"tottri",
",",
"INT_MAX",
")",
";",
"GPU_indexbuf_init",
"(",
"&",
"elb_lines",
",",
"GPU_PRIM_LINES",
",",
"tot_real_edges",
",",
"INT_MAX",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"face_indices_len",
";",
"i",
"++",
")",
"{",
"const",
"MLoopTri",
"*",
"lt",
"=",
"&",
"looptri",
"[",
"face_indices",
"[",
"i",
"]",
"]",
";",
"if",
"(",
"paint_is_face_hidden",
"(",
"lt",
",",
"mvert",
",",
"mloop",
")",
")",
"{",
"continue",
";",
"}",
"GPU_indexbuf_add_tri_verts",
"(",
"&",
"elb",
",",
"UNPACK3",
"(",
"face_vert_indices",
"[",
"i",
"]",
")",
")",
";",
"int",
"r_edges",
"[",
"3",
"]",
";",
"BKE_mesh_looptri_get_real_edges",
"(",
"mesh",
",",
"lt",
",",
"r_edges",
")",
";",
"if",
"(",
"r_edges",
"[",
"0",
"]",
"!=",
"-1",
")",
"{",
"GPU_indexbuf_add_line_verts",
"(",
"&",
"elb_lines",
",",
"face_vert_indices",
"[",
"i",
"]",
"[",
"0",
"]",
",",
"face_vert_indices",
"[",
"i",
"]",
"[",
"1",
"]",
")",
";",
"}",
"if",
"(",
"r_edges",
"[",
"1",
"]",
"!=",
"-1",
")",
"{",
"GPU_indexbuf_add_line_verts",
"(",
"&",
"elb_lines",
",",
"face_vert_indices",
"[",
"i",
"]",
"[",
"1",
"]",
",",
"face_vert_indices",
"[",
"i",
"]",
"[",
"2",
"]",
")",
";",
"}",
"if",
"(",
"r_edges",
"[",
"2",
"]",
"!=",
"-1",
")",
"{",
"GPU_indexbuf_add_line_verts",
"(",
"&",
"elb_lines",
",",
"face_vert_indices",
"[",
"i",
"]",
"[",
"2",
"]",
",",
"face_vert_indices",
"[",
"i",
"]",
"[",
"0",
"]",
")",
";",
"}",
"}",
"buffers",
"->",
"index_buf",
"=",
"GPU_indexbuf_build",
"(",
"&",
"elb",
")",
";",
"buffers",
"->",
"index_lines_buf",
"=",
"GPU_indexbuf_build",
"(",
"&",
"elb_lines",
")",
";",
"}",
"else",
"{",
"GPUIndexBufBuilder",
"elb_lines",
";",
"GPU_indexbuf_init",
"(",
"&",
"elb_lines",
",",
"GPU_PRIM_LINES",
",",
"tot_real_edges",
",",
"INT_MAX",
")",
";",
"int",
"vert_idx",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"face_indices_len",
";",
"i",
"++",
")",
"{",
"const",
"MLoopTri",
"*",
"lt",
"=",
"&",
"looptri",
"[",
"face_indices",
"[",
"i",
"]",
"]",
";",
"if",
"(",
"paint_is_face_hidden",
"(",
"lt",
",",
"mvert",
",",
"mloop",
")",
")",
"{",
"continue",
";",
"}",
"int",
"r_edges",
"[",
"3",
"]",
";",
"BKE_mesh_looptri_get_real_edges",
"(",
"mesh",
",",
"lt",
",",
"r_edges",
")",
";",
"if",
"(",
"r_edges",
"[",
"0",
"]",
"!=",
"-1",
")",
"{",
"GPU_indexbuf_add_line_verts",
"(",
"&",
"elb_lines",
",",
"vert_idx",
"*",
"3",
"+",
"0",
",",
"vert_idx",
"*",
"3",
"+",
"1",
")",
";",
"}",
"if",
"(",
"r_edges",
"[",
"1",
"]",
"!=",
"-1",
")",
"{",
"GPU_indexbuf_add_line_verts",
"(",
"&",
"elb_lines",
",",
"vert_idx",
"*",
"3",
"+",
"1",
",",
"vert_idx",
"*",
"3",
"+",
"2",
")",
";",
"}",
"if",
"(",
"r_edges",
"[",
"2",
"]",
"!=",
"-1",
")",
"{",
"GPU_indexbuf_add_line_verts",
"(",
"&",
"elb_lines",
",",
"vert_idx",
"*",
"3",
"+",
"2",
",",
"vert_idx",
"*",
"3",
"+",
"0",
")",
";",
"}",
"vert_idx",
"++",
";",
"}",
"buffers",
"->",
"index_lines_buf",
"=",
"GPU_indexbuf_build",
"(",
"&",
"elb_lines",
")",
";",
"}",
"buffers",
"->",
"tot_tri",
"=",
"tottri",
";",
"buffers",
"->",
"mpoly",
"=",
"mpoly",
";",
"buffers",
"->",
"mloop",
"=",
"mloop",
";",
"buffers",
"->",
"looptri",
"=",
"looptri",
";",
"buffers",
"->",
"face_indices",
"=",
"face_indices",
";",
"buffers",
"->",
"face_indices_len",
"=",
"face_indices_len",
";",
"return",
"buffers",
";",
"}"
] | Threaded - do not call any functions that use OpenGL calls! | [
"Threaded",
"-",
"do",
"not",
"call",
"any",
"functions",
"that",
"use",
"OpenGL",
"calls!"
] | [
"/* smooth or flat for all */",
"/* Count the number of visible triangles */",
"/* An element index buffer is used for smooth shading, but flat\n * shading requires separate vertex normals so an index buffer\n * can't be used there. */",
"/* Fill the triangle and line buffers. */",
"/* Skip hidden faces */",
"/* Fill the only the line buffer. */",
"/* Skip hidden faces */"
] | [
{
"param": "face_vert_indices",
"type": "int"
},
{
"param": "mpoly",
"type": "MPoly"
},
{
"param": "mloop",
"type": "MLoop"
},
{
"param": "looptri",
"type": "MLoopTri"
},
{
"param": "mvert",
"type": "MVert"
},
{
"param": "face_indices",
"type": "int"
},
{
"param": "face_indices_len",
"type": "int"
},
{
"param": "mesh",
"type": "struct Mesh"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "face_vert_indices",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mpoly",
"type": "MPoly",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mloop",
"type": "MLoop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "looptri",
"type": "MLoopTri",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mvert",
"type": "MVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "face_indices",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "face_indices_len",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mesh",
"type": "struct Mesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c74afd2d8e21de6a62075fc5d22213aedf5c89d | DemonRem/blender | source/blender/gpu/intern/gpu_buffers.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | gpu_bmesh_vert_visible_count | int | static int gpu_bmesh_vert_visible_count(GSet *bm_unique_verts, GSet *bm_other_verts)
{
GSetIterator gs_iter;
int totvert = 0;
GSET_ITER (gs_iter, bm_unique_verts) {
BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
totvert++;
}
}
GSET_ITER (gs_iter, bm_other_verts) {
BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
totvert++;
}
}
return totvert;
} | /* Return the total number of vertices that don't have BM_ELEM_HIDDEN set */ | Return the total number of vertices that don't have BM_ELEM_HIDDEN set | [
"Return",
"the",
"total",
"number",
"of",
"vertices",
"that",
"don",
"'",
"t",
"have",
"BM_ELEM_HIDDEN",
"set"
] | static int gpu_bmesh_vert_visible_count(GSet *bm_unique_verts, GSet *bm_other_verts)
{
GSetIterator gs_iter;
int totvert = 0;
GSET_ITER (gs_iter, bm_unique_verts) {
BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
totvert++;
}
}
GSET_ITER (gs_iter, bm_other_verts) {
BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
totvert++;
}
}
return totvert;
} | [
"static",
"int",
"gpu_bmesh_vert_visible_count",
"(",
"GSet",
"*",
"bm_unique_verts",
",",
"GSet",
"*",
"bm_other_verts",
")",
"{",
"GSetIterator",
"gs_iter",
";",
"int",
"totvert",
"=",
"0",
";",
"GSET_ITER",
"(",
"gs_iter",
",",
"bm_unique_verts",
")",
"",
"{",
"BMVert",
"*",
"v",
"=",
"BLI_gsetIterator_getKey",
"(",
"&",
"gs_iter",
")",
";",
"if",
"(",
"!",
"BM_elem_flag_test",
"(",
"v",
",",
"BM_ELEM_HIDDEN",
")",
")",
"{",
"totvert",
"++",
";",
"}",
"}",
"GSET_ITER",
"(",
"gs_iter",
",",
"bm_other_verts",
")",
"",
"{",
"BMVert",
"*",
"v",
"=",
"BLI_gsetIterator_getKey",
"(",
"&",
"gs_iter",
")",
";",
"if",
"(",
"!",
"BM_elem_flag_test",
"(",
"v",
",",
"BM_ELEM_HIDDEN",
")",
")",
"{",
"totvert",
"++",
";",
"}",
"}",
"return",
"totvert",
";",
"}"
] | Return the total number of vertices that don't have BM_ELEM_HIDDEN set | [
"Return",
"the",
"total",
"number",
"of",
"vertices",
"that",
"don",
"'",
"t",
"have",
"BM_ELEM_HIDDEN",
"set"
] | [] | [
{
"param": "bm_unique_verts",
"type": "GSet"
},
{
"param": "bm_other_verts",
"type": "GSet"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bm_unique_verts",
"type": "GSet",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bm_other_verts",
"type": "GSet",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c74afd2d8e21de6a62075fc5d22213aedf5c89d | DemonRem/blender | source/blender/gpu/intern/gpu_buffers.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | gpu_bmesh_face_visible_count | int | static int gpu_bmesh_face_visible_count(GSet *bm_faces)
{
GSetIterator gh_iter;
int totface = 0;
GSET_ITER (gh_iter, bm_faces) {
BMFace *f = BLI_gsetIterator_getKey(&gh_iter);
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
totface++;
}
}
return totface;
} | /* Return the total number of visible faces */ | Return the total number of visible faces | [
"Return",
"the",
"total",
"number",
"of",
"visible",
"faces"
] | static int gpu_bmesh_face_visible_count(GSet *bm_faces)
{
GSetIterator gh_iter;
int totface = 0;
GSET_ITER (gh_iter, bm_faces) {
BMFace *f = BLI_gsetIterator_getKey(&gh_iter);
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
totface++;
}
}
return totface;
} | [
"static",
"int",
"gpu_bmesh_face_visible_count",
"(",
"GSet",
"*",
"bm_faces",
")",
"{",
"GSetIterator",
"gh_iter",
";",
"int",
"totface",
"=",
"0",
";",
"GSET_ITER",
"(",
"gh_iter",
",",
"bm_faces",
")",
"",
"{",
"BMFace",
"*",
"f",
"=",
"BLI_gsetIterator_getKey",
"(",
"&",
"gh_iter",
")",
";",
"if",
"(",
"!",
"BM_elem_flag_test",
"(",
"f",
",",
"BM_ELEM_HIDDEN",
")",
")",
"{",
"totface",
"++",
";",
"}",
"}",
"return",
"totface",
";",
"}"
] | Return the total number of visible faces | [
"Return",
"the",
"total",
"number",
"of",
"visible",
"faces"
] | [] | [
{
"param": "bm_faces",
"type": "GSet"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bm_faces",
"type": "GSet",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c74afd2d8e21de6a62075fc5d22213aedf5c89d | DemonRem/blender | source/blender/gpu/intern/gpu_buffers.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | GPU_pbvh_bmesh_buffers_update | void | void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
BMesh *bm,
GSet *bm_faces,
GSet *bm_unique_verts,
GSet *bm_other_verts,
const int update_flags)
{
const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0;
const bool show_vcol = (update_flags & GPU_PBVH_BUFFERS_SHOW_VCOL) != 0;
int tottri, totvert;
bool empty_mask = true;
BMFace *f = NULL;
/* Count visible triangles */
tottri = gpu_bmesh_face_visible_count(bm_faces);
if (buffers->smooth) {
/* Count visible vertices */
totvert = gpu_bmesh_vert_visible_count(bm_unique_verts, bm_other_verts);
}
else {
totvert = tottri * 3;
}
if (!tottri) {
if (BLI_gset_len(bm_faces) != 0) {
/* Node is just hidden. */
}
else {
buffers->clear_bmesh_on_flush = true;
}
buffers->tot_tri = 0;
return;
}
/* TODO, make mask layer optional for bmesh buffer */
const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
/* Fill vertex buffer */
if (!gpu_pbvh_vert_buf_data_set(buffers, totvert)) {
/* Memory map failed */
return;
}
int v_index = 0;
if (buffers->smooth) {
/* Fill the vertex and triangle buffer in one pass over faces. */
GPUIndexBufBuilder elb, elb_lines;
GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, totvert);
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, totvert);
GHash *bm_vert_to_index = BLI_ghash_int_new_ex("bm_vert_to_index", totvert);
GSetIterator gs_iter;
GSET_ITER (gs_iter, bm_faces) {
f = BLI_gsetIterator_getKey(&gs_iter);
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
BMVert *v[3];
BM_face_as_array_vert_tri(f, v);
uint idx[3];
for (int i = 0; i < 3; i++) {
void **idx_p;
if (!BLI_ghash_ensure_p(bm_vert_to_index, v[i], &idx_p)) {
/* Add vertex to the vertex buffer each time a new one is encountered */
*idx_p = POINTER_FROM_UINT(v_index);
gpu_bmesh_vert_to_buffer_copy(v[i],
buffers->vert_buf,
v_index,
NULL,
NULL,
cd_vert_mask_offset,
show_mask,
show_vcol,
&empty_mask);
idx[i] = v_index;
v_index++;
}
else {
/* Vertex already in the vertex buffer, just get the index. */
idx[i] = POINTER_AS_UINT(*idx_p);
}
}
GPU_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]);
GPU_indexbuf_add_line_verts(&elb_lines, idx[0], idx[1]);
GPU_indexbuf_add_line_verts(&elb_lines, idx[1], idx[2]);
GPU_indexbuf_add_line_verts(&elb_lines, idx[2], idx[0]);
}
}
BLI_ghash_free(bm_vert_to_index, NULL, NULL);
buffers->tot_tri = tottri;
if (buffers->index_buf == NULL) {
buffers->index_buf = GPU_indexbuf_build(&elb);
}
else {
GPU_indexbuf_build_in_place(&elb, buffers->index_buf);
}
buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
}
else {
GSetIterator gs_iter;
GPUIndexBufBuilder elb_lines;
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, tottri * 3);
GSET_ITER (gs_iter, bm_faces) {
f = BLI_gsetIterator_getKey(&gs_iter);
BLI_assert(f->len == 3);
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
BMVert *v[3];
float fmask = 0.0f;
int i;
BM_face_as_array_vert_tri(f, v);
/* Average mask value */
for (i = 0; i < 3; i++) {
fmask += BM_ELEM_CD_GET_FLOAT(v[i], cd_vert_mask_offset);
}
fmask /= 3.0f;
GPU_indexbuf_add_line_verts(&elb_lines, v_index + 0, v_index + 1);
GPU_indexbuf_add_line_verts(&elb_lines, v_index + 1, v_index + 2);
GPU_indexbuf_add_line_verts(&elb_lines, v_index + 2, v_index + 0);
for (i = 0; i < 3; i++) {
gpu_bmesh_vert_to_buffer_copy(v[i],
buffers->vert_buf,
v_index++,
f->no,
&fmask,
cd_vert_mask_offset,
show_mask,
show_vcol,
&empty_mask);
}
}
}
buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
buffers->tot_tri = tottri;
}
/* Get material index from the last face we iterated on. */
buffers->material_index = (f) ? f->mat_nr : 0;
buffers->show_mask = !empty_mask;
gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS);
} | /* Creates a vertex buffer (coordinate, normal, color) and, if smooth
* shading, an element index buffer.
* Threaded - do not call any functions that use OpenGL calls! */ | Creates a vertex buffer (coordinate, normal, color) and, if smooth
shading, an element index buffer.
Threaded - do not call any functions that use OpenGL calls! | [
"Creates",
"a",
"vertex",
"buffer",
"(",
"coordinate",
"normal",
"color",
")",
"and",
"if",
"smooth",
"shading",
"an",
"element",
"index",
"buffer",
".",
"Threaded",
"-",
"do",
"not",
"call",
"any",
"functions",
"that",
"use",
"OpenGL",
"calls!"
] | void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
BMesh *bm,
GSet *bm_faces,
GSet *bm_unique_verts,
GSet *bm_other_verts,
const int update_flags)
{
const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0;
const bool show_vcol = (update_flags & GPU_PBVH_BUFFERS_SHOW_VCOL) != 0;
int tottri, totvert;
bool empty_mask = true;
BMFace *f = NULL;
tottri = gpu_bmesh_face_visible_count(bm_faces);
if (buffers->smooth) {
totvert = gpu_bmesh_vert_visible_count(bm_unique_verts, bm_other_verts);
}
else {
totvert = tottri * 3;
}
if (!tottri) {
if (BLI_gset_len(bm_faces) != 0) {
}
else {
buffers->clear_bmesh_on_flush = true;
}
buffers->tot_tri = 0;
return;
}
const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
if (!gpu_pbvh_vert_buf_data_set(buffers, totvert)) {
return;
}
int v_index = 0;
if (buffers->smooth) {
GPUIndexBufBuilder elb, elb_lines;
GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, totvert);
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, totvert);
GHash *bm_vert_to_index = BLI_ghash_int_new_ex("bm_vert_to_index", totvert);
GSetIterator gs_iter;
GSET_ITER (gs_iter, bm_faces) {
f = BLI_gsetIterator_getKey(&gs_iter);
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
BMVert *v[3];
BM_face_as_array_vert_tri(f, v);
uint idx[3];
for (int i = 0; i < 3; i++) {
void **idx_p;
if (!BLI_ghash_ensure_p(bm_vert_to_index, v[i], &idx_p)) {
*idx_p = POINTER_FROM_UINT(v_index);
gpu_bmesh_vert_to_buffer_copy(v[i],
buffers->vert_buf,
v_index,
NULL,
NULL,
cd_vert_mask_offset,
show_mask,
show_vcol,
&empty_mask);
idx[i] = v_index;
v_index++;
}
else {
idx[i] = POINTER_AS_UINT(*idx_p);
}
}
GPU_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]);
GPU_indexbuf_add_line_verts(&elb_lines, idx[0], idx[1]);
GPU_indexbuf_add_line_verts(&elb_lines, idx[1], idx[2]);
GPU_indexbuf_add_line_verts(&elb_lines, idx[2], idx[0]);
}
}
BLI_ghash_free(bm_vert_to_index, NULL, NULL);
buffers->tot_tri = tottri;
if (buffers->index_buf == NULL) {
buffers->index_buf = GPU_indexbuf_build(&elb);
}
else {
GPU_indexbuf_build_in_place(&elb, buffers->index_buf);
}
buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
}
else {
GSetIterator gs_iter;
GPUIndexBufBuilder elb_lines;
GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, tottri * 3);
GSET_ITER (gs_iter, bm_faces) {
f = BLI_gsetIterator_getKey(&gs_iter);
BLI_assert(f->len == 3);
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
BMVert *v[3];
float fmask = 0.0f;
int i;
BM_face_as_array_vert_tri(f, v);
for (i = 0; i < 3; i++) {
fmask += BM_ELEM_CD_GET_FLOAT(v[i], cd_vert_mask_offset);
}
fmask /= 3.0f;
GPU_indexbuf_add_line_verts(&elb_lines, v_index + 0, v_index + 1);
GPU_indexbuf_add_line_verts(&elb_lines, v_index + 1, v_index + 2);
GPU_indexbuf_add_line_verts(&elb_lines, v_index + 2, v_index + 0);
for (i = 0; i < 3; i++) {
gpu_bmesh_vert_to_buffer_copy(v[i],
buffers->vert_buf,
v_index++,
f->no,
&fmask,
cd_vert_mask_offset,
show_mask,
show_vcol,
&empty_mask);
}
}
}
buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
buffers->tot_tri = tottri;
}
buffers->material_index = (f) ? f->mat_nr : 0;
buffers->show_mask = !empty_mask;
gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS);
} | [
"void",
"GPU_pbvh_bmesh_buffers_update",
"(",
"GPU_PBVH_Buffers",
"*",
"buffers",
",",
"BMesh",
"*",
"bm",
",",
"GSet",
"*",
"bm_faces",
",",
"GSet",
"*",
"bm_unique_verts",
",",
"GSet",
"*",
"bm_other_verts",
",",
"const",
"int",
"update_flags",
")",
"{",
"const",
"bool",
"show_mask",
"=",
"(",
"update_flags",
"&",
"GPU_PBVH_BUFFERS_SHOW_MASK",
")",
"!=",
"0",
";",
"const",
"bool",
"show_vcol",
"=",
"(",
"update_flags",
"&",
"GPU_PBVH_BUFFERS_SHOW_VCOL",
")",
"!=",
"0",
";",
"int",
"tottri",
",",
"totvert",
";",
"bool",
"empty_mask",
"=",
"true",
";",
"BMFace",
"*",
"f",
"=",
"NULL",
";",
"tottri",
"=",
"gpu_bmesh_face_visible_count",
"(",
"bm_faces",
")",
";",
"if",
"(",
"buffers",
"->",
"smooth",
")",
"{",
"totvert",
"=",
"gpu_bmesh_vert_visible_count",
"(",
"bm_unique_verts",
",",
"bm_other_verts",
")",
";",
"}",
"else",
"{",
"totvert",
"=",
"tottri",
"*",
"3",
";",
"}",
"if",
"(",
"!",
"tottri",
")",
"{",
"if",
"(",
"BLI_gset_len",
"(",
"bm_faces",
")",
"!=",
"0",
")",
"{",
"}",
"else",
"{",
"buffers",
"->",
"clear_bmesh_on_flush",
"=",
"true",
";",
"}",
"buffers",
"->",
"tot_tri",
"=",
"0",
";",
"return",
";",
"}",
"const",
"int",
"cd_vert_mask_offset",
"=",
"CustomData_get_offset",
"(",
"&",
"bm",
"->",
"vdata",
",",
"CD_PAINT_MASK",
")",
";",
"if",
"(",
"!",
"gpu_pbvh_vert_buf_data_set",
"(",
"buffers",
",",
"totvert",
")",
")",
"{",
"return",
";",
"}",
"int",
"v_index",
"=",
"0",
";",
"if",
"(",
"buffers",
"->",
"smooth",
")",
"{",
"GPUIndexBufBuilder",
"elb",
",",
"elb_lines",
";",
"GPU_indexbuf_init",
"(",
"&",
"elb",
",",
"GPU_PRIM_TRIS",
",",
"tottri",
",",
"totvert",
")",
";",
"GPU_indexbuf_init",
"(",
"&",
"elb_lines",
",",
"GPU_PRIM_LINES",
",",
"tottri",
"*",
"3",
",",
"totvert",
")",
";",
"GHash",
"*",
"bm_vert_to_index",
"=",
"BLI_ghash_int_new_ex",
"(",
"\"",
"\"",
",",
"totvert",
")",
";",
"GSetIterator",
"gs_iter",
";",
"GSET_ITER",
"(",
"gs_iter",
",",
"bm_faces",
")",
"",
"{",
"f",
"=",
"BLI_gsetIterator_getKey",
"(",
"&",
"gs_iter",
")",
";",
"if",
"(",
"!",
"BM_elem_flag_test",
"(",
"f",
",",
"BM_ELEM_HIDDEN",
")",
")",
"{",
"BMVert",
"*",
"v",
"[",
"3",
"]",
";",
"BM_face_as_array_vert_tri",
"(",
"f",
",",
"v",
")",
";",
"uint",
"idx",
"[",
"3",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"void",
"*",
"*",
"idx_p",
";",
"if",
"(",
"!",
"BLI_ghash_ensure_p",
"(",
"bm_vert_to_index",
",",
"v",
"[",
"i",
"]",
",",
"&",
"idx_p",
")",
")",
"{",
"*",
"idx_p",
"=",
"POINTER_FROM_UINT",
"(",
"v_index",
")",
";",
"gpu_bmesh_vert_to_buffer_copy",
"(",
"v",
"[",
"i",
"]",
",",
"buffers",
"->",
"vert_buf",
",",
"v_index",
",",
"NULL",
",",
"NULL",
",",
"cd_vert_mask_offset",
",",
"show_mask",
",",
"show_vcol",
",",
"&",
"empty_mask",
")",
";",
"idx",
"[",
"i",
"]",
"=",
"v_index",
";",
"v_index",
"++",
";",
"}",
"else",
"{",
"idx",
"[",
"i",
"]",
"=",
"POINTER_AS_UINT",
"(",
"*",
"idx_p",
")",
";",
"}",
"}",
"GPU_indexbuf_add_tri_verts",
"(",
"&",
"elb",
",",
"idx",
"[",
"0",
"]",
",",
"idx",
"[",
"1",
"]",
",",
"idx",
"[",
"2",
"]",
")",
";",
"GPU_indexbuf_add_line_verts",
"(",
"&",
"elb_lines",
",",
"idx",
"[",
"0",
"]",
",",
"idx",
"[",
"1",
"]",
")",
";",
"GPU_indexbuf_add_line_verts",
"(",
"&",
"elb_lines",
",",
"idx",
"[",
"1",
"]",
",",
"idx",
"[",
"2",
"]",
")",
";",
"GPU_indexbuf_add_line_verts",
"(",
"&",
"elb_lines",
",",
"idx",
"[",
"2",
"]",
",",
"idx",
"[",
"0",
"]",
")",
";",
"}",
"}",
"BLI_ghash_free",
"(",
"bm_vert_to_index",
",",
"NULL",
",",
"NULL",
")",
";",
"buffers",
"->",
"tot_tri",
"=",
"tottri",
";",
"if",
"(",
"buffers",
"->",
"index_buf",
"==",
"NULL",
")",
"{",
"buffers",
"->",
"index_buf",
"=",
"GPU_indexbuf_build",
"(",
"&",
"elb",
")",
";",
"}",
"else",
"{",
"GPU_indexbuf_build_in_place",
"(",
"&",
"elb",
",",
"buffers",
"->",
"index_buf",
")",
";",
"}",
"buffers",
"->",
"index_lines_buf",
"=",
"GPU_indexbuf_build",
"(",
"&",
"elb_lines",
")",
";",
"}",
"else",
"{",
"GSetIterator",
"gs_iter",
";",
"GPUIndexBufBuilder",
"elb_lines",
";",
"GPU_indexbuf_init",
"(",
"&",
"elb_lines",
",",
"GPU_PRIM_LINES",
",",
"tottri",
"*",
"3",
",",
"tottri",
"*",
"3",
")",
";",
"GSET_ITER",
"(",
"gs_iter",
",",
"bm_faces",
")",
"",
"{",
"f",
"=",
"BLI_gsetIterator_getKey",
"(",
"&",
"gs_iter",
")",
";",
"BLI_assert",
"(",
"f",
"->",
"len",
"==",
"3",
")",
";",
"if",
"(",
"!",
"BM_elem_flag_test",
"(",
"f",
",",
"BM_ELEM_HIDDEN",
")",
")",
"{",
"BMVert",
"*",
"v",
"[",
"3",
"]",
";",
"float",
"fmask",
"=",
"0.0f",
";",
"int",
"i",
";",
"BM_face_as_array_vert_tri",
"(",
"f",
",",
"v",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"fmask",
"+=",
"BM_ELEM_CD_GET_FLOAT",
"(",
"v",
"[",
"i",
"]",
",",
"cd_vert_mask_offset",
")",
";",
"}",
"fmask",
"/=",
"3.0f",
";",
"GPU_indexbuf_add_line_verts",
"(",
"&",
"elb_lines",
",",
"v_index",
"+",
"0",
",",
"v_index",
"+",
"1",
")",
";",
"GPU_indexbuf_add_line_verts",
"(",
"&",
"elb_lines",
",",
"v_index",
"+",
"1",
",",
"v_index",
"+",
"2",
")",
";",
"GPU_indexbuf_add_line_verts",
"(",
"&",
"elb_lines",
",",
"v_index",
"+",
"2",
",",
"v_index",
"+",
"0",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"gpu_bmesh_vert_to_buffer_copy",
"(",
"v",
"[",
"i",
"]",
",",
"buffers",
"->",
"vert_buf",
",",
"v_index",
"++",
",",
"f",
"->",
"no",
",",
"&",
"fmask",
",",
"cd_vert_mask_offset",
",",
"show_mask",
",",
"show_vcol",
",",
"&",
"empty_mask",
")",
";",
"}",
"}",
"}",
"buffers",
"->",
"index_lines_buf",
"=",
"GPU_indexbuf_build",
"(",
"&",
"elb_lines",
")",
";",
"buffers",
"->",
"tot_tri",
"=",
"tottri",
";",
"}",
"buffers",
"->",
"material_index",
"=",
"(",
"f",
")",
"?",
"f",
"->",
"mat_nr",
":",
"0",
";",
"buffers",
"->",
"show_mask",
"=",
"!",
"empty_mask",
";",
"gpu_pbvh_batch_init",
"(",
"buffers",
",",
"GPU_PRIM_TRIS",
")",
";",
"}"
] | Creates a vertex buffer (coordinate, normal, color) and, if smooth
shading, an element index buffer. | [
"Creates",
"a",
"vertex",
"buffer",
"(",
"coordinate",
"normal",
"color",
")",
"and",
"if",
"smooth",
"shading",
"an",
"element",
"index",
"buffer",
"."
] | [
"/* Count visible triangles */",
"/* Count visible vertices */",
"/* Node is just hidden. */",
"/* TODO, make mask layer optional for bmesh buffer */",
"/* Fill vertex buffer */",
"/* Memory map failed */",
"/* Fill the vertex and triangle buffer in one pass over faces. */",
"/* Add vertex to the vertex buffer each time a new one is encountered */",
"/* Vertex already in the vertex buffer, just get the index. */",
"/* Average mask value */",
"/* Get material index from the last face we iterated on. */"
] | [
{
"param": "buffers",
"type": "GPU_PBVH_Buffers"
},
{
"param": "bm",
"type": "BMesh"
},
{
"param": "bm_faces",
"type": "GSet"
},
{
"param": "bm_unique_verts",
"type": "GSet"
},
{
"param": "bm_other_verts",
"type": "GSet"
},
{
"param": "update_flags",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "buffers",
"type": "GPU_PBVH_Buffers",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bm",
"type": "BMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bm_faces",
"type": "GSet",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bm_unique_verts",
"type": "GSet",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bm_other_verts",
"type": "GSet",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "update_flags",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2c74afd2d8e21de6a62075fc5d22213aedf5c89d | DemonRem/blender | source/blender/gpu/intern/gpu_buffers.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | GPU_pbvh_bmesh_buffers_build | GPU_PBVH_Buffers | GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading)
{
GPU_PBVH_Buffers *buffers;
buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers");
buffers->use_bmesh = true;
buffers->smooth = smooth_shading;
buffers->show_mask = true;
return buffers;
} | /* Threaded - do not call any functions that use OpenGL calls! */ | do not call any functions that use OpenGL calls! | [
"do",
"not",
"call",
"any",
"functions",
"that",
"use",
"OpenGL",
"calls!"
] | GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading)
{
GPU_PBVH_Buffers *buffers;
buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers");
buffers->use_bmesh = true;
buffers->smooth = smooth_shading;
buffers->show_mask = true;
return buffers;
} | [
"GPU_PBVH_Buffers",
"*",
"GPU_pbvh_bmesh_buffers_build",
"(",
"bool",
"smooth_shading",
")",
"{",
"GPU_PBVH_Buffers",
"*",
"buffers",
";",
"buffers",
"=",
"MEM_callocN",
"(",
"sizeof",
"(",
"GPU_PBVH_Buffers",
")",
",",
"\"",
"\"",
")",
";",
"buffers",
"->",
"use_bmesh",
"=",
"true",
";",
"buffers",
"->",
"smooth",
"=",
"smooth_shading",
";",
"buffers",
"->",
"show_mask",
"=",
"true",
";",
"return",
"buffers",
";",
"}"
] | Threaded - do not call any functions that use OpenGL calls! | [
"Threaded",
"-",
"do",
"not",
"call",
"any",
"functions",
"that",
"use",
"OpenGL",
"calls!"
] | [] | [
{
"param": "smooth_shading",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "smooth_shading",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
95a4771b313609c5b3ae2d91cdad91220d2e359a | DemonRem/blender | source/blender/blenloader/intern/undofile.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | BLO_memfile_merge | void | void BLO_memfile_merge(MemFile *first, MemFile *second)
{
MemFileChunk *fc, *sc;
fc = first->chunks.first;
sc = second->chunks.first;
while (fc || sc) {
if (fc && sc) {
if (sc->is_identical) {
sc->is_identical = false;
fc->is_identical = true;
}
}
if (fc) {
fc = fc->next;
}
if (sc) {
sc = sc->next;
}
}
BLO_memfile_free(first);
} | /* to keep list of memfiles consistent, 'first' is always first in list */
/* result is that 'first' is being freed */ | to keep list of memfiles consistent, 'first' is always first in list
result is that 'first' is being freed | [
"to",
"keep",
"list",
"of",
"memfiles",
"consistent",
"'",
"first",
"'",
"is",
"always",
"first",
"in",
"list",
"result",
"is",
"that",
"'",
"first",
"'",
"is",
"being",
"freed"
] | void BLO_memfile_merge(MemFile *first, MemFile *second)
{
MemFileChunk *fc, *sc;
fc = first->chunks.first;
sc = second->chunks.first;
while (fc || sc) {
if (fc && sc) {
if (sc->is_identical) {
sc->is_identical = false;
fc->is_identical = true;
}
}
if (fc) {
fc = fc->next;
}
if (sc) {
sc = sc->next;
}
}
BLO_memfile_free(first);
} | [
"void",
"BLO_memfile_merge",
"(",
"MemFile",
"*",
"first",
",",
"MemFile",
"*",
"second",
")",
"{",
"MemFileChunk",
"*",
"fc",
",",
"*",
"sc",
";",
"fc",
"=",
"first",
"->",
"chunks",
".",
"first",
";",
"sc",
"=",
"second",
"->",
"chunks",
".",
"first",
";",
"while",
"(",
"fc",
"||",
"sc",
")",
"{",
"if",
"(",
"fc",
"&&",
"sc",
")",
"{",
"if",
"(",
"sc",
"->",
"is_identical",
")",
"{",
"sc",
"->",
"is_identical",
"=",
"false",
";",
"fc",
"->",
"is_identical",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"fc",
")",
"{",
"fc",
"=",
"fc",
"->",
"next",
";",
"}",
"if",
"(",
"sc",
")",
"{",
"sc",
"=",
"sc",
"->",
"next",
";",
"}",
"}",
"BLO_memfile_free",
"(",
"first",
")",
";",
"}"
] | to keep list of memfiles consistent, 'first' is always first in list
result is that 'first' is being freed | [
"to",
"keep",
"list",
"of",
"memfiles",
"consistent",
"'",
"first",
"'",
"is",
"always",
"first",
"in",
"list",
"result",
"is",
"that",
"'",
"first",
"'",
"is",
"being",
"freed"
] | [] | [
{
"param": "first",
"type": "MemFile"
},
{
"param": "second",
"type": "MemFile"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "first",
"type": "MemFile",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "second",
"type": "MemFile",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1db038bef94a442c69ba9efd2681120e2d957a41 | DemonRem/blender | source/blender/editors/uvedit/uvedit_unwrap_ops.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | construct_param_handle | ParamHandle | static ParamHandle *construct_param_handle(Scene *scene,
Object *ob,
BMesh *bm,
const UnwrapOptions *options)
{
ParamHandle *handle;
BMFace *efa;
BMLoop *l;
BMEdge *eed;
BMIter iter, liter;
int i;
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
handle = param_construct_begin();
if (options->correct_aspect) {
float aspx, aspy;
ED_uvedit_get_aspect(scene, ob, bm, &aspx, &aspy);
if (aspx != aspy) {
param_aspect_ratio(handle, aspx, aspy);
}
}
/* we need the vert indices */
BM_mesh_elem_index_ensure(bm, BM_VERT);
BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) {
if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) ||
(options->only_selected && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0)) {
continue;
}
if (options->topology_from_uvs) {
bool is_loopsel = false;
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
is_loopsel = true;
break;
}
}
if (is_loopsel == false) {
continue;
}
}
construct_param_handle_face_add(handle, scene, efa, i, cd_loop_uv_offset);
}
if (!options->topology_from_uvs) {
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(eed, BM_ELEM_SEAM)) {
ParamKey vkeys[2];
vkeys[0] = (ParamKey)BM_elem_index_get(eed->v1);
vkeys[1] = (ParamKey)BM_elem_index_get(eed->v2);
param_edge_set_seam(handle, vkeys);
}
}
}
param_construct_end(handle, options->fill_holes, options->topology_from_uvs);
return handle;
} | /* See: construct_param_handle_multi to handle multiple objects at once. */ | construct_param_handle_multi to handle multiple objects at once. | [
"construct_param_handle_multi",
"to",
"handle",
"multiple",
"objects",
"at",
"once",
"."
] | static ParamHandle *construct_param_handle(Scene *scene,
Object *ob,
BMesh *bm,
const UnwrapOptions *options)
{
ParamHandle *handle;
BMFace *efa;
BMLoop *l;
BMEdge *eed;
BMIter iter, liter;
int i;
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
handle = param_construct_begin();
if (options->correct_aspect) {
float aspx, aspy;
ED_uvedit_get_aspect(scene, ob, bm, &aspx, &aspy);
if (aspx != aspy) {
param_aspect_ratio(handle, aspx, aspy);
}
}
BM_mesh_elem_index_ensure(bm, BM_VERT);
BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) {
if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) ||
(options->only_selected && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0)) {
continue;
}
if (options->topology_from_uvs) {
bool is_loopsel = false;
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
is_loopsel = true;
break;
}
}
if (is_loopsel == false) {
continue;
}
}
construct_param_handle_face_add(handle, scene, efa, i, cd_loop_uv_offset);
}
if (!options->topology_from_uvs) {
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(eed, BM_ELEM_SEAM)) {
ParamKey vkeys[2];
vkeys[0] = (ParamKey)BM_elem_index_get(eed->v1);
vkeys[1] = (ParamKey)BM_elem_index_get(eed->v2);
param_edge_set_seam(handle, vkeys);
}
}
}
param_construct_end(handle, options->fill_holes, options->topology_from_uvs);
return handle;
} | [
"static",
"ParamHandle",
"*",
"construct_param_handle",
"(",
"Scene",
"*",
"scene",
",",
"Object",
"*",
"ob",
",",
"BMesh",
"*",
"bm",
",",
"const",
"UnwrapOptions",
"*",
"options",
")",
"{",
"ParamHandle",
"*",
"handle",
";",
"BMFace",
"*",
"efa",
";",
"BMLoop",
"*",
"l",
";",
"BMEdge",
"*",
"eed",
";",
"BMIter",
"iter",
",",
"liter",
";",
"int",
"i",
";",
"const",
"int",
"cd_loop_uv_offset",
"=",
"CustomData_get_offset",
"(",
"&",
"bm",
"->",
"ldata",
",",
"CD_MLOOPUV",
")",
";",
"handle",
"=",
"param_construct_begin",
"(",
")",
";",
"if",
"(",
"options",
"->",
"correct_aspect",
")",
"{",
"float",
"aspx",
",",
"aspy",
";",
"ED_uvedit_get_aspect",
"(",
"scene",
",",
"ob",
",",
"bm",
",",
"&",
"aspx",
",",
"&",
"aspy",
")",
";",
"if",
"(",
"aspx",
"!=",
"aspy",
")",
"{",
"param_aspect_ratio",
"(",
"handle",
",",
"aspx",
",",
"aspy",
")",
";",
"}",
"}",
"BM_mesh_elem_index_ensure",
"(",
"bm",
",",
"BM_VERT",
")",
";",
"BM_ITER_MESH_INDEX",
"(",
"efa",
",",
"&",
"iter",
",",
"bm",
",",
"BM_FACES_OF_MESH",
",",
"i",
")",
"",
"{",
"if",
"(",
"(",
"BM_elem_flag_test",
"(",
"efa",
",",
"BM_ELEM_HIDDEN",
")",
")",
"||",
"(",
"options",
"->",
"only_selected",
"&&",
"BM_elem_flag_test",
"(",
"efa",
",",
"BM_ELEM_SELECT",
")",
"==",
"0",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"options",
"->",
"topology_from_uvs",
")",
"{",
"bool",
"is_loopsel",
"=",
"false",
";",
"BM_ITER_ELEM",
"(",
"l",
",",
"&",
"liter",
",",
"efa",
",",
"BM_LOOPS_OF_FACE",
")",
"",
"{",
"if",
"(",
"uvedit_uv_select_test",
"(",
"scene",
",",
"l",
",",
"cd_loop_uv_offset",
")",
")",
"{",
"is_loopsel",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"is_loopsel",
"==",
"false",
")",
"{",
"continue",
";",
"}",
"}",
"construct_param_handle_face_add",
"(",
"handle",
",",
"scene",
",",
"efa",
",",
"i",
",",
"cd_loop_uv_offset",
")",
";",
"}",
"if",
"(",
"!",
"options",
"->",
"topology_from_uvs",
")",
"{",
"BM_ITER_MESH",
"(",
"eed",
",",
"&",
"iter",
",",
"bm",
",",
"BM_EDGES_OF_MESH",
")",
"",
"{",
"if",
"(",
"BM_elem_flag_test",
"(",
"eed",
",",
"BM_ELEM_SEAM",
")",
")",
"{",
"ParamKey",
"vkeys",
"[",
"2",
"]",
";",
"vkeys",
"[",
"0",
"]",
"=",
"(",
"ParamKey",
")",
"BM_elem_index_get",
"(",
"eed",
"->",
"v1",
")",
";",
"vkeys",
"[",
"1",
"]",
"=",
"(",
"ParamKey",
")",
"BM_elem_index_get",
"(",
"eed",
"->",
"v2",
")",
";",
"param_edge_set_seam",
"(",
"handle",
",",
"vkeys",
")",
";",
"}",
"}",
"}",
"param_construct_end",
"(",
"handle",
",",
"options",
"->",
"fill_holes",
",",
"options",
"->",
"topology_from_uvs",
")",
";",
"return",
"handle",
";",
"}"
] | See: construct_param_handle_multi to handle multiple objects at once. | [
"See",
":",
"construct_param_handle_multi",
"to",
"handle",
"multiple",
"objects",
"at",
"once",
"."
] | [
"/* we need the vert indices */"
] | [
{
"param": "scene",
"type": "Scene"
},
{
"param": "ob",
"type": "Object"
},
{
"param": "bm",
"type": "BMesh"
},
{
"param": "options",
"type": "UnwrapOptions"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scene",
"type": "Scene",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ob",
"type": "Object",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bm",
"type": "BMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "options",
"type": "UnwrapOptions",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1db038bef94a442c69ba9efd2681120e2d957a41 | DemonRem/blender | source/blender/editors/uvedit/uvedit_unwrap_ops.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | construct_param_handle_multi | ParamHandle | static ParamHandle *construct_param_handle_multi(Scene *scene,
Object **objects,
const uint objects_len,
const UnwrapOptions *options)
{
ParamHandle *handle;
BMFace *efa;
BMLoop *l;
BMEdge *eed;
BMIter iter, liter;
int i;
handle = param_construct_begin();
if (options->correct_aspect) {
Object *ob = objects[0];
BMEditMesh *em = BKE_editmesh_from_object(ob);
BMesh *bm = em->bm;
float aspx, aspy;
ED_uvedit_get_aspect(scene, ob, bm, &aspx, &aspy);
if (aspx != aspy) {
param_aspect_ratio(handle, aspx, aspy);
}
}
/* we need the vert indices */
EDBM_mesh_elem_index_ensure_multi(objects, objects_len, BM_VERT);
int offset = 0;
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMesh *bm = em->bm;
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
if (cd_loop_uv_offset == -1) {
continue;
}
BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) {
if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) ||
(options->only_selected && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0)) {
continue;
}
if (options->topology_from_uvs) {
bool is_loopsel = false;
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
is_loopsel = true;
break;
}
}
if (is_loopsel == false) {
continue;
}
}
construct_param_handle_face_add(handle, scene, efa, i + offset, cd_loop_uv_offset);
}
if (!options->topology_from_uvs) {
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(eed, BM_ELEM_SEAM)) {
ParamKey vkeys[2];
vkeys[0] = (ParamKey)BM_elem_index_get(eed->v1);
vkeys[1] = (ParamKey)BM_elem_index_get(eed->v2);
param_edge_set_seam(handle, vkeys);
}
}
}
offset += bm->totface;
}
param_construct_end(handle, options->fill_holes, options->topology_from_uvs);
return handle;
} | /**
* Version of #construct_param_handle_single that handles multiple objects.
*/ | Version of #construct_param_handle_single that handles multiple objects. | [
"Version",
"of",
"#construct_param_handle_single",
"that",
"handles",
"multiple",
"objects",
"."
] | static ParamHandle *construct_param_handle_multi(Scene *scene,
Object **objects,
const uint objects_len,
const UnwrapOptions *options)
{
ParamHandle *handle;
BMFace *efa;
BMLoop *l;
BMEdge *eed;
BMIter iter, liter;
int i;
handle = param_construct_begin();
if (options->correct_aspect) {
Object *ob = objects[0];
BMEditMesh *em = BKE_editmesh_from_object(ob);
BMesh *bm = em->bm;
float aspx, aspy;
ED_uvedit_get_aspect(scene, ob, bm, &aspx, &aspy);
if (aspx != aspy) {
param_aspect_ratio(handle, aspx, aspy);
}
}
EDBM_mesh_elem_index_ensure_multi(objects, objects_len, BM_VERT);
int offset = 0;
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMesh *bm = em->bm;
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
if (cd_loop_uv_offset == -1) {
continue;
}
BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) {
if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) ||
(options->only_selected && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0)) {
continue;
}
if (options->topology_from_uvs) {
bool is_loopsel = false;
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
is_loopsel = true;
break;
}
}
if (is_loopsel == false) {
continue;
}
}
construct_param_handle_face_add(handle, scene, efa, i + offset, cd_loop_uv_offset);
}
if (!options->topology_from_uvs) {
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(eed, BM_ELEM_SEAM)) {
ParamKey vkeys[2];
vkeys[0] = (ParamKey)BM_elem_index_get(eed->v1);
vkeys[1] = (ParamKey)BM_elem_index_get(eed->v2);
param_edge_set_seam(handle, vkeys);
}
}
}
offset += bm->totface;
}
param_construct_end(handle, options->fill_holes, options->topology_from_uvs);
return handle;
} | [
"static",
"ParamHandle",
"*",
"construct_param_handle_multi",
"(",
"Scene",
"*",
"scene",
",",
"Object",
"*",
"*",
"objects",
",",
"const",
"uint",
"objects_len",
",",
"const",
"UnwrapOptions",
"*",
"options",
")",
"{",
"ParamHandle",
"*",
"handle",
";",
"BMFace",
"*",
"efa",
";",
"BMLoop",
"*",
"l",
";",
"BMEdge",
"*",
"eed",
";",
"BMIter",
"iter",
",",
"liter",
";",
"int",
"i",
";",
"handle",
"=",
"param_construct_begin",
"(",
")",
";",
"if",
"(",
"options",
"->",
"correct_aspect",
")",
"{",
"Object",
"*",
"ob",
"=",
"objects",
"[",
"0",
"]",
";",
"BMEditMesh",
"*",
"em",
"=",
"BKE_editmesh_from_object",
"(",
"ob",
")",
";",
"BMesh",
"*",
"bm",
"=",
"em",
"->",
"bm",
";",
"float",
"aspx",
",",
"aspy",
";",
"ED_uvedit_get_aspect",
"(",
"scene",
",",
"ob",
",",
"bm",
",",
"&",
"aspx",
",",
"&",
"aspy",
")",
";",
"if",
"(",
"aspx",
"!=",
"aspy",
")",
"{",
"param_aspect_ratio",
"(",
"handle",
",",
"aspx",
",",
"aspy",
")",
";",
"}",
"}",
"EDBM_mesh_elem_index_ensure_multi",
"(",
"objects",
",",
"objects_len",
",",
"BM_VERT",
")",
";",
"int",
"offset",
"=",
"0",
";",
"for",
"(",
"uint",
"ob_index",
"=",
"0",
";",
"ob_index",
"<",
"objects_len",
";",
"ob_index",
"++",
")",
"{",
"Object",
"*",
"obedit",
"=",
"objects",
"[",
"ob_index",
"]",
";",
"BMEditMesh",
"*",
"em",
"=",
"BKE_editmesh_from_object",
"(",
"obedit",
")",
";",
"BMesh",
"*",
"bm",
"=",
"em",
"->",
"bm",
";",
"const",
"int",
"cd_loop_uv_offset",
"=",
"CustomData_get_offset",
"(",
"&",
"bm",
"->",
"ldata",
",",
"CD_MLOOPUV",
")",
";",
"if",
"(",
"cd_loop_uv_offset",
"==",
"-1",
")",
"{",
"continue",
";",
"}",
"BM_ITER_MESH_INDEX",
"(",
"efa",
",",
"&",
"iter",
",",
"bm",
",",
"BM_FACES_OF_MESH",
",",
"i",
")",
"",
"{",
"if",
"(",
"(",
"BM_elem_flag_test",
"(",
"efa",
",",
"BM_ELEM_HIDDEN",
")",
")",
"||",
"(",
"options",
"->",
"only_selected",
"&&",
"BM_elem_flag_test",
"(",
"efa",
",",
"BM_ELEM_SELECT",
")",
"==",
"0",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"options",
"->",
"topology_from_uvs",
")",
"{",
"bool",
"is_loopsel",
"=",
"false",
";",
"BM_ITER_ELEM",
"(",
"l",
",",
"&",
"liter",
",",
"efa",
",",
"BM_LOOPS_OF_FACE",
")",
"",
"{",
"if",
"(",
"uvedit_uv_select_test",
"(",
"scene",
",",
"l",
",",
"cd_loop_uv_offset",
")",
")",
"{",
"is_loopsel",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"is_loopsel",
"==",
"false",
")",
"{",
"continue",
";",
"}",
"}",
"construct_param_handle_face_add",
"(",
"handle",
",",
"scene",
",",
"efa",
",",
"i",
"+",
"offset",
",",
"cd_loop_uv_offset",
")",
";",
"}",
"if",
"(",
"!",
"options",
"->",
"topology_from_uvs",
")",
"{",
"BM_ITER_MESH",
"(",
"eed",
",",
"&",
"iter",
",",
"bm",
",",
"BM_EDGES_OF_MESH",
")",
"",
"{",
"if",
"(",
"BM_elem_flag_test",
"(",
"eed",
",",
"BM_ELEM_SEAM",
")",
")",
"{",
"ParamKey",
"vkeys",
"[",
"2",
"]",
";",
"vkeys",
"[",
"0",
"]",
"=",
"(",
"ParamKey",
")",
"BM_elem_index_get",
"(",
"eed",
"->",
"v1",
")",
";",
"vkeys",
"[",
"1",
"]",
"=",
"(",
"ParamKey",
")",
"BM_elem_index_get",
"(",
"eed",
"->",
"v2",
")",
";",
"param_edge_set_seam",
"(",
"handle",
",",
"vkeys",
")",
";",
"}",
"}",
"}",
"offset",
"+=",
"bm",
"->",
"totface",
";",
"}",
"param_construct_end",
"(",
"handle",
",",
"options",
"->",
"fill_holes",
",",
"options",
"->",
"topology_from_uvs",
")",
";",
"return",
"handle",
";",
"}"
] | Version of #construct_param_handle_single that handles multiple objects. | [
"Version",
"of",
"#construct_param_handle_single",
"that",
"handles",
"multiple",
"objects",
"."
] | [
"/* we need the vert indices */"
] | [
{
"param": "scene",
"type": "Scene"
},
{
"param": "objects",
"type": "Object"
},
{
"param": "objects_len",
"type": "uint"
},
{
"param": "options",
"type": "UnwrapOptions"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scene",
"type": "Scene",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "objects",
"type": "Object",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "objects_len",
"type": "uint",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "options",
"type": "UnwrapOptions",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1db038bef94a442c69ba9efd2681120e2d957a41 | DemonRem/blender | source/blender/editors/uvedit/uvedit_unwrap_ops.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | uvedit_unwrap | void | static void uvedit_unwrap(Scene *scene, Object *obedit, const UnwrapOptions *options)
{
BMEditMesh *em = BKE_editmesh_from_object(obedit);
if (!CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV)) {
return;
}
bool use_subsurf;
modifier_unwrap_state(obedit, scene, &use_subsurf);
ParamHandle *handle;
if (use_subsurf) {
handle = construct_param_handle_subsurfed(scene, obedit, em, options);
}
else {
handle = construct_param_handle(scene, obedit, em->bm, options);
}
param_lscm_begin(handle, PARAM_FALSE, scene->toolsettings->unwrapper == 0);
param_lscm_solve(handle);
param_lscm_end(handle);
param_average(handle, true);
param_flush(handle);
param_delete(handle);
} | /* Assumes UV Map exists, doesn't run update funcs. */ | Assumes UV Map exists, doesn't run update funcs. | [
"Assumes",
"UV",
"Map",
"exists",
"doesn",
"'",
"t",
"run",
"update",
"funcs",
"."
] | static void uvedit_unwrap(Scene *scene, Object *obedit, const UnwrapOptions *options)
{
BMEditMesh *em = BKE_editmesh_from_object(obedit);
if (!CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV)) {
return;
}
bool use_subsurf;
modifier_unwrap_state(obedit, scene, &use_subsurf);
ParamHandle *handle;
if (use_subsurf) {
handle = construct_param_handle_subsurfed(scene, obedit, em, options);
}
else {
handle = construct_param_handle(scene, obedit, em->bm, options);
}
param_lscm_begin(handle, PARAM_FALSE, scene->toolsettings->unwrapper == 0);
param_lscm_solve(handle);
param_lscm_end(handle);
param_average(handle, true);
param_flush(handle);
param_delete(handle);
} | [
"static",
"void",
"uvedit_unwrap",
"(",
"Scene",
"*",
"scene",
",",
"Object",
"*",
"obedit",
",",
"const",
"UnwrapOptions",
"*",
"options",
")",
"{",
"BMEditMesh",
"*",
"em",
"=",
"BKE_editmesh_from_object",
"(",
"obedit",
")",
";",
"if",
"(",
"!",
"CustomData_has_layer",
"(",
"&",
"em",
"->",
"bm",
"->",
"ldata",
",",
"CD_MLOOPUV",
")",
")",
"{",
"return",
";",
"}",
"bool",
"use_subsurf",
";",
"modifier_unwrap_state",
"(",
"obedit",
",",
"scene",
",",
"&",
"use_subsurf",
")",
";",
"ParamHandle",
"*",
"handle",
";",
"if",
"(",
"use_subsurf",
")",
"{",
"handle",
"=",
"construct_param_handle_subsurfed",
"(",
"scene",
",",
"obedit",
",",
"em",
",",
"options",
")",
";",
"}",
"else",
"{",
"handle",
"=",
"construct_param_handle",
"(",
"scene",
",",
"obedit",
",",
"em",
"->",
"bm",
",",
"options",
")",
";",
"}",
"param_lscm_begin",
"(",
"handle",
",",
"PARAM_FALSE",
",",
"scene",
"->",
"toolsettings",
"->",
"unwrapper",
"==",
"0",
")",
";",
"param_lscm_solve",
"(",
"handle",
")",
";",
"param_lscm_end",
"(",
"handle",
")",
";",
"param_average",
"(",
"handle",
",",
"true",
")",
";",
"param_flush",
"(",
"handle",
")",
";",
"param_delete",
"(",
"handle",
")",
";",
"}"
] | Assumes UV Map exists, doesn't run update funcs. | [
"Assumes",
"UV",
"Map",
"exists",
"doesn",
"'",
"t",
"run",
"update",
"funcs",
"."
] | [] | [
{
"param": "scene",
"type": "Scene"
},
{
"param": "obedit",
"type": "Object"
},
{
"param": "options",
"type": "UnwrapOptions"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scene",
"type": "Scene",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "obedit",
"type": "Object",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "options",
"type": "UnwrapOptions",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_copy_subset | void | void defvert_copy_subset(MDeformVert *dvert_dst,
const MDeformVert *dvert_src,
const bool *vgroup_subset,
const int vgroup_tot)
{
int defgroup;
for (defgroup = 0; defgroup < vgroup_tot; defgroup++) {
if (vgroup_subset[defgroup]) {
defvert_copy_index(dvert_dst, defgroup, dvert_src, defgroup);
}
}
} | /**
* Overwrite weights filtered by vgroup_subset.
* - do nothing if neither are set.
* - add destination weight if needed
*/ | Overwrite weights filtered by vgroup_subset.
- do nothing if neither are set.
- add destination weight if needed | [
"Overwrite",
"weights",
"filtered",
"by",
"vgroup_subset",
".",
"-",
"do",
"nothing",
"if",
"neither",
"are",
"set",
".",
"-",
"add",
"destination",
"weight",
"if",
"needed"
] | void defvert_copy_subset(MDeformVert *dvert_dst,
const MDeformVert *dvert_src,
const bool *vgroup_subset,
const int vgroup_tot)
{
int defgroup;
for (defgroup = 0; defgroup < vgroup_tot; defgroup++) {
if (vgroup_subset[defgroup]) {
defvert_copy_index(dvert_dst, defgroup, dvert_src, defgroup);
}
}
} | [
"void",
"defvert_copy_subset",
"(",
"MDeformVert",
"*",
"dvert_dst",
",",
"const",
"MDeformVert",
"*",
"dvert_src",
",",
"const",
"bool",
"*",
"vgroup_subset",
",",
"const",
"int",
"vgroup_tot",
")",
"{",
"int",
"defgroup",
";",
"for",
"(",
"defgroup",
"=",
"0",
";",
"defgroup",
"<",
"vgroup_tot",
";",
"defgroup",
"++",
")",
"{",
"if",
"(",
"vgroup_subset",
"[",
"defgroup",
"]",
")",
"{",
"defvert_copy_index",
"(",
"dvert_dst",
",",
"defgroup",
",",
"dvert_src",
",",
"defgroup",
")",
";",
"}",
"}",
"}"
] | Overwrite weights filtered by vgroup_subset. | [
"Overwrite",
"weights",
"filtered",
"by",
"vgroup_subset",
"."
] | [] | [
{
"param": "dvert_dst",
"type": "MDeformVert"
},
{
"param": "dvert_src",
"type": "MDeformVert"
},
{
"param": "vgroup_subset",
"type": "bool"
},
{
"param": "vgroup_tot",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert_dst",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dvert_src",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vgroup_subset",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vgroup_tot",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_mirror_subset | void | void defvert_mirror_subset(MDeformVert *dvert_dst,
const MDeformVert *dvert_src,
const bool *vgroup_subset,
const int vgroup_tot,
const int *flip_map,
const int flip_map_len)
{
int defgroup;
for (defgroup = 0; defgroup < vgroup_tot && defgroup < flip_map_len; defgroup++) {
if (vgroup_subset[defgroup] && (dvert_dst != dvert_src || flip_map[defgroup] != defgroup)) {
defvert_copy_index(dvert_dst, flip_map[defgroup], dvert_src, defgroup);
}
}
} | /**
* Overwrite weights filtered by vgroup_subset and with mirroring specified by the flip map
* - do nothing if neither are set.
* - add destination weight if needed
*/ | Overwrite weights filtered by vgroup_subset and with mirroring specified by the flip map
- do nothing if neither are set.
- add destination weight if needed | [
"Overwrite",
"weights",
"filtered",
"by",
"vgroup_subset",
"and",
"with",
"mirroring",
"specified",
"by",
"the",
"flip",
"map",
"-",
"do",
"nothing",
"if",
"neither",
"are",
"set",
".",
"-",
"add",
"destination",
"weight",
"if",
"needed"
] | void defvert_mirror_subset(MDeformVert *dvert_dst,
const MDeformVert *dvert_src,
const bool *vgroup_subset,
const int vgroup_tot,
const int *flip_map,
const int flip_map_len)
{
int defgroup;
for (defgroup = 0; defgroup < vgroup_tot && defgroup < flip_map_len; defgroup++) {
if (vgroup_subset[defgroup] && (dvert_dst != dvert_src || flip_map[defgroup] != defgroup)) {
defvert_copy_index(dvert_dst, flip_map[defgroup], dvert_src, defgroup);
}
}
} | [
"void",
"defvert_mirror_subset",
"(",
"MDeformVert",
"*",
"dvert_dst",
",",
"const",
"MDeformVert",
"*",
"dvert_src",
",",
"const",
"bool",
"*",
"vgroup_subset",
",",
"const",
"int",
"vgroup_tot",
",",
"const",
"int",
"*",
"flip_map",
",",
"const",
"int",
"flip_map_len",
")",
"{",
"int",
"defgroup",
";",
"for",
"(",
"defgroup",
"=",
"0",
";",
"defgroup",
"<",
"vgroup_tot",
"&&",
"defgroup",
"<",
"flip_map_len",
";",
"defgroup",
"++",
")",
"{",
"if",
"(",
"vgroup_subset",
"[",
"defgroup",
"]",
"&&",
"(",
"dvert_dst",
"!=",
"dvert_src",
"||",
"flip_map",
"[",
"defgroup",
"]",
"!=",
"defgroup",
")",
")",
"{",
"defvert_copy_index",
"(",
"dvert_dst",
",",
"flip_map",
"[",
"defgroup",
"]",
",",
"dvert_src",
",",
"defgroup",
")",
";",
"}",
"}",
"}"
] | Overwrite weights filtered by vgroup_subset and with mirroring specified by the flip map
- do nothing if neither are set. | [
"Overwrite",
"weights",
"filtered",
"by",
"vgroup_subset",
"and",
"with",
"mirroring",
"specified",
"by",
"the",
"flip",
"map",
"-",
"do",
"nothing",
"if",
"neither",
"are",
"set",
"."
] | [] | [
{
"param": "dvert_dst",
"type": "MDeformVert"
},
{
"param": "dvert_src",
"type": "MDeformVert"
},
{
"param": "vgroup_subset",
"type": "bool"
},
{
"param": "vgroup_tot",
"type": "int"
},
{
"param": "flip_map",
"type": "int"
},
{
"param": "flip_map_len",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert_dst",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dvert_src",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vgroup_subset",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vgroup_tot",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flip_map",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flip_map_len",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_copy_index | void | void defvert_copy_index(MDeformVert *dvert_dst,
const int defgroup_dst,
const MDeformVert *dvert_src,
const int defgroup_src)
{
MDeformWeight *dw_src, *dw_dst;
dw_src = defvert_find_index(dvert_src, defgroup_src);
if (dw_src) {
/* source is valid, verify destination */
dw_dst = defvert_verify_index(dvert_dst, defgroup_dst);
dw_dst->weight = dw_src->weight;
}
else {
/* source was NULL, assign zero, could also remove */
dw_dst = defvert_find_index(dvert_dst, defgroup_dst);
if (dw_dst) {
dw_dst->weight = 0.0f;
}
}
} | /**
* Copy an index from one dvert to another.
* - do nothing if neither are set.
* - add destination weight if needed.
*/ | Copy an index from one dvert to another.
- do nothing if neither are set.
- add destination weight if needed. | [
"Copy",
"an",
"index",
"from",
"one",
"dvert",
"to",
"another",
".",
"-",
"do",
"nothing",
"if",
"neither",
"are",
"set",
".",
"-",
"add",
"destination",
"weight",
"if",
"needed",
"."
] | void defvert_copy_index(MDeformVert *dvert_dst,
const int defgroup_dst,
const MDeformVert *dvert_src,
const int defgroup_src)
{
MDeformWeight *dw_src, *dw_dst;
dw_src = defvert_find_index(dvert_src, defgroup_src);
if (dw_src) {
dw_dst = defvert_verify_index(dvert_dst, defgroup_dst);
dw_dst->weight = dw_src->weight;
}
else {
dw_dst = defvert_find_index(dvert_dst, defgroup_dst);
if (dw_dst) {
dw_dst->weight = 0.0f;
}
}
} | [
"void",
"defvert_copy_index",
"(",
"MDeformVert",
"*",
"dvert_dst",
",",
"const",
"int",
"defgroup_dst",
",",
"const",
"MDeformVert",
"*",
"dvert_src",
",",
"const",
"int",
"defgroup_src",
")",
"{",
"MDeformWeight",
"*",
"dw_src",
",",
"*",
"dw_dst",
";",
"dw_src",
"=",
"defvert_find_index",
"(",
"dvert_src",
",",
"defgroup_src",
")",
";",
"if",
"(",
"dw_src",
")",
"{",
"dw_dst",
"=",
"defvert_verify_index",
"(",
"dvert_dst",
",",
"defgroup_dst",
")",
";",
"dw_dst",
"->",
"weight",
"=",
"dw_src",
"->",
"weight",
";",
"}",
"else",
"{",
"dw_dst",
"=",
"defvert_find_index",
"(",
"dvert_dst",
",",
"defgroup_dst",
")",
";",
"if",
"(",
"dw_dst",
")",
"{",
"dw_dst",
"->",
"weight",
"=",
"0.0f",
";",
"}",
"}",
"}"
] | Copy an index from one dvert to another. | [
"Copy",
"an",
"index",
"from",
"one",
"dvert",
"to",
"another",
"."
] | [
"/* source is valid, verify destination */",
"/* source was NULL, assign zero, could also remove */"
] | [
{
"param": "dvert_dst",
"type": "MDeformVert"
},
{
"param": "defgroup_dst",
"type": "int"
},
{
"param": "dvert_src",
"type": "MDeformVert"
},
{
"param": "defgroup_src",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert_dst",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defgroup_dst",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dvert_src",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defgroup_src",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_sync | void | void defvert_sync(MDeformVert *dvert_dst, const MDeformVert *dvert_src, const bool use_verify)
{
if (dvert_src->totweight && dvert_dst->totweight) {
int i;
MDeformWeight *dw_src;
for (i = 0, dw_src = dvert_src->dw; i < dvert_src->totweight; i++, dw_src++) {
MDeformWeight *dw_dst;
if (use_verify) {
dw_dst = defvert_verify_index(dvert_dst, dw_src->def_nr);
}
else {
dw_dst = defvert_find_index(dvert_dst, dw_src->def_nr);
}
if (dw_dst) {
dw_dst->weight = dw_src->weight;
}
}
}
} | /**
* Only sync over matching weights, don't add or remove groups
* warning, loop within loop.
*/ | Only sync over matching weights, don't add or remove groups
warning, loop within loop. | [
"Only",
"sync",
"over",
"matching",
"weights",
"don",
"'",
"t",
"add",
"or",
"remove",
"groups",
"warning",
"loop",
"within",
"loop",
"."
] | void defvert_sync(MDeformVert *dvert_dst, const MDeformVert *dvert_src, const bool use_verify)
{
if (dvert_src->totweight && dvert_dst->totweight) {
int i;
MDeformWeight *dw_src;
for (i = 0, dw_src = dvert_src->dw; i < dvert_src->totweight; i++, dw_src++) {
MDeformWeight *dw_dst;
if (use_verify) {
dw_dst = defvert_verify_index(dvert_dst, dw_src->def_nr);
}
else {
dw_dst = defvert_find_index(dvert_dst, dw_src->def_nr);
}
if (dw_dst) {
dw_dst->weight = dw_src->weight;
}
}
}
} | [
"void",
"defvert_sync",
"(",
"MDeformVert",
"*",
"dvert_dst",
",",
"const",
"MDeformVert",
"*",
"dvert_src",
",",
"const",
"bool",
"use_verify",
")",
"{",
"if",
"(",
"dvert_src",
"->",
"totweight",
"&&",
"dvert_dst",
"->",
"totweight",
")",
"{",
"int",
"i",
";",
"MDeformWeight",
"*",
"dw_src",
";",
"for",
"(",
"i",
"=",
"0",
",",
"dw_src",
"=",
"dvert_src",
"->",
"dw",
";",
"i",
"<",
"dvert_src",
"->",
"totweight",
";",
"i",
"++",
",",
"dw_src",
"++",
")",
"{",
"MDeformWeight",
"*",
"dw_dst",
";",
"if",
"(",
"use_verify",
")",
"{",
"dw_dst",
"=",
"defvert_verify_index",
"(",
"dvert_dst",
",",
"dw_src",
"->",
"def_nr",
")",
";",
"}",
"else",
"{",
"dw_dst",
"=",
"defvert_find_index",
"(",
"dvert_dst",
",",
"dw_src",
"->",
"def_nr",
")",
";",
"}",
"if",
"(",
"dw_dst",
")",
"{",
"dw_dst",
"->",
"weight",
"=",
"dw_src",
"->",
"weight",
";",
"}",
"}",
"}",
"}"
] | Only sync over matching weights, don't add or remove groups
warning, loop within loop. | [
"Only",
"sync",
"over",
"matching",
"weights",
"don",
"'",
"t",
"add",
"or",
"remove",
"groups",
"warning",
"loop",
"within",
"loop",
"."
] | [] | [
{
"param": "dvert_dst",
"type": "MDeformVert"
},
{
"param": "dvert_src",
"type": "MDeformVert"
},
{
"param": "use_verify",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert_dst",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dvert_src",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_verify",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_sync_mapped | void | void defvert_sync_mapped(MDeformVert *dvert_dst,
const MDeformVert *dvert_src,
const int *flip_map,
const int flip_map_len,
const bool use_verify)
{
if (dvert_src->totweight && dvert_dst->totweight) {
int i;
MDeformWeight *dw_src;
for (i = 0, dw_src = dvert_src->dw; i < dvert_src->totweight; i++, dw_src++) {
if (dw_src->def_nr < flip_map_len) {
MDeformWeight *dw_dst;
if (use_verify) {
dw_dst = defvert_verify_index(dvert_dst, flip_map[dw_src->def_nr]);
}
else {
dw_dst = defvert_find_index(dvert_dst, flip_map[dw_src->def_nr]);
}
if (dw_dst) {
dw_dst->weight = dw_src->weight;
}
}
}
}
} | /**
* be sure all flip_map values are valid
*/ | be sure all flip_map values are valid | [
"be",
"sure",
"all",
"flip_map",
"values",
"are",
"valid"
] | void defvert_sync_mapped(MDeformVert *dvert_dst,
const MDeformVert *dvert_src,
const int *flip_map,
const int flip_map_len,
const bool use_verify)
{
if (dvert_src->totweight && dvert_dst->totweight) {
int i;
MDeformWeight *dw_src;
for (i = 0, dw_src = dvert_src->dw; i < dvert_src->totweight; i++, dw_src++) {
if (dw_src->def_nr < flip_map_len) {
MDeformWeight *dw_dst;
if (use_verify) {
dw_dst = defvert_verify_index(dvert_dst, flip_map[dw_src->def_nr]);
}
else {
dw_dst = defvert_find_index(dvert_dst, flip_map[dw_src->def_nr]);
}
if (dw_dst) {
dw_dst->weight = dw_src->weight;
}
}
}
}
} | [
"void",
"defvert_sync_mapped",
"(",
"MDeformVert",
"*",
"dvert_dst",
",",
"const",
"MDeformVert",
"*",
"dvert_src",
",",
"const",
"int",
"*",
"flip_map",
",",
"const",
"int",
"flip_map_len",
",",
"const",
"bool",
"use_verify",
")",
"{",
"if",
"(",
"dvert_src",
"->",
"totweight",
"&&",
"dvert_dst",
"->",
"totweight",
")",
"{",
"int",
"i",
";",
"MDeformWeight",
"*",
"dw_src",
";",
"for",
"(",
"i",
"=",
"0",
",",
"dw_src",
"=",
"dvert_src",
"->",
"dw",
";",
"i",
"<",
"dvert_src",
"->",
"totweight",
";",
"i",
"++",
",",
"dw_src",
"++",
")",
"{",
"if",
"(",
"dw_src",
"->",
"def_nr",
"<",
"flip_map_len",
")",
"{",
"MDeformWeight",
"*",
"dw_dst",
";",
"if",
"(",
"use_verify",
")",
"{",
"dw_dst",
"=",
"defvert_verify_index",
"(",
"dvert_dst",
",",
"flip_map",
"[",
"dw_src",
"->",
"def_nr",
"]",
")",
";",
"}",
"else",
"{",
"dw_dst",
"=",
"defvert_find_index",
"(",
"dvert_dst",
",",
"flip_map",
"[",
"dw_src",
"->",
"def_nr",
"]",
")",
";",
"}",
"if",
"(",
"dw_dst",
")",
"{",
"dw_dst",
"->",
"weight",
"=",
"dw_src",
"->",
"weight",
";",
"}",
"}",
"}",
"}",
"}"
] | be sure all flip_map values are valid | [
"be",
"sure",
"all",
"flip_map",
"values",
"are",
"valid"
] | [] | [
{
"param": "dvert_dst",
"type": "MDeformVert"
},
{
"param": "dvert_src",
"type": "MDeformVert"
},
{
"param": "flip_map",
"type": "int"
},
{
"param": "flip_map_len",
"type": "int"
},
{
"param": "use_verify",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert_dst",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dvert_src",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flip_map",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flip_map_len",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_verify",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_remap | void | void defvert_remap(MDeformVert *dvert, int *map, const int map_len)
{
MDeformWeight *dw = dvert->dw;
unsigned int i;
for (i = dvert->totweight; i != 0; i--, dw++) {
if (dw->def_nr < map_len) {
dw->def_nr = map[dw->def_nr];
/* just in case */
BLI_assert(dw->def_nr >= 0);
}
}
} | /**
* be sure all flip_map values are valid
*/ | be sure all flip_map values are valid | [
"be",
"sure",
"all",
"flip_map",
"values",
"are",
"valid"
] | void defvert_remap(MDeformVert *dvert, int *map, const int map_len)
{
MDeformWeight *dw = dvert->dw;
unsigned int i;
for (i = dvert->totweight; i != 0; i--, dw++) {
if (dw->def_nr < map_len) {
dw->def_nr = map[dw->def_nr];
BLI_assert(dw->def_nr >= 0);
}
}
} | [
"void",
"defvert_remap",
"(",
"MDeformVert",
"*",
"dvert",
",",
"int",
"*",
"map",
",",
"const",
"int",
"map_len",
")",
"{",
"MDeformWeight",
"*",
"dw",
"=",
"dvert",
"->",
"dw",
";",
"unsigned",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"dvert",
"->",
"totweight",
";",
"i",
"!=",
"0",
";",
"i",
"--",
",",
"dw",
"++",
")",
"{",
"if",
"(",
"dw",
"->",
"def_nr",
"<",
"map_len",
")",
"{",
"dw",
"->",
"def_nr",
"=",
"map",
"[",
"dw",
"->",
"def_nr",
"]",
";",
"BLI_assert",
"(",
"dw",
"->",
"def_nr",
">=",
"0",
")",
";",
"}",
"}",
"}"
] | be sure all flip_map values are valid | [
"be",
"sure",
"all",
"flip_map",
"values",
"are",
"valid"
] | [
"/* just in case */"
] | [
{
"param": "dvert",
"type": "MDeformVert"
},
{
"param": "map",
"type": "int"
},
{
"param": "map_len",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "map",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "map_len",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_normalize_subset | void | void defvert_normalize_subset(MDeformVert *dvert, const bool *vgroup_subset, const int vgroup_tot)
{
if (dvert->totweight == 0) {
/* nothing */
}
else if (dvert->totweight == 1) {
MDeformWeight *dw = dvert->dw;
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
dw->weight = 1.0f;
}
}
else {
MDeformWeight *dw;
unsigned int i;
float tot_weight = 0.0f;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
tot_weight += dw->weight;
}
}
if (tot_weight > 0.0f) {
float scalar = 1.0f / tot_weight;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
dw->weight *= scalar;
/* in case of division errors with very low weights */
CLAMP(dw->weight, 0.0f, 1.0f);
}
}
}
}
} | /**
* Same as #defvert_normalize but takes a bool array.
*/ | Same as #defvert_normalize but takes a bool array. | [
"Same",
"as",
"#defvert_normalize",
"but",
"takes",
"a",
"bool",
"array",
"."
] | void defvert_normalize_subset(MDeformVert *dvert, const bool *vgroup_subset, const int vgroup_tot)
{
if (dvert->totweight == 0) {
}
else if (dvert->totweight == 1) {
MDeformWeight *dw = dvert->dw;
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
dw->weight = 1.0f;
}
}
else {
MDeformWeight *dw;
unsigned int i;
float tot_weight = 0.0f;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
tot_weight += dw->weight;
}
}
if (tot_weight > 0.0f) {
float scalar = 1.0f / tot_weight;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
dw->weight *= scalar;
CLAMP(dw->weight, 0.0f, 1.0f);
}
}
}
}
} | [
"void",
"defvert_normalize_subset",
"(",
"MDeformVert",
"*",
"dvert",
",",
"const",
"bool",
"*",
"vgroup_subset",
",",
"const",
"int",
"vgroup_tot",
")",
"{",
"if",
"(",
"dvert",
"->",
"totweight",
"==",
"0",
")",
"{",
"}",
"else",
"if",
"(",
"dvert",
"->",
"totweight",
"==",
"1",
")",
"{",
"MDeformWeight",
"*",
"dw",
"=",
"dvert",
"->",
"dw",
";",
"if",
"(",
"(",
"dw",
"->",
"def_nr",
"<",
"vgroup_tot",
")",
"&&",
"vgroup_subset",
"[",
"dw",
"->",
"def_nr",
"]",
")",
"{",
"dw",
"->",
"weight",
"=",
"1.0f",
";",
"}",
"}",
"else",
"{",
"MDeformWeight",
"*",
"dw",
";",
"unsigned",
"int",
"i",
";",
"float",
"tot_weight",
"=",
"0.0f",
";",
"for",
"(",
"i",
"=",
"dvert",
"->",
"totweight",
",",
"dw",
"=",
"dvert",
"->",
"dw",
";",
"i",
"!=",
"0",
";",
"i",
"--",
",",
"dw",
"++",
")",
"{",
"if",
"(",
"(",
"dw",
"->",
"def_nr",
"<",
"vgroup_tot",
")",
"&&",
"vgroup_subset",
"[",
"dw",
"->",
"def_nr",
"]",
")",
"{",
"tot_weight",
"+=",
"dw",
"->",
"weight",
";",
"}",
"}",
"if",
"(",
"tot_weight",
">",
"0.0f",
")",
"{",
"float",
"scalar",
"=",
"1.0f",
"/",
"tot_weight",
";",
"for",
"(",
"i",
"=",
"dvert",
"->",
"totweight",
",",
"dw",
"=",
"dvert",
"->",
"dw",
";",
"i",
"!=",
"0",
";",
"i",
"--",
",",
"dw",
"++",
")",
"{",
"if",
"(",
"(",
"dw",
"->",
"def_nr",
"<",
"vgroup_tot",
")",
"&&",
"vgroup_subset",
"[",
"dw",
"->",
"def_nr",
"]",
")",
"{",
"dw",
"->",
"weight",
"*=",
"scalar",
";",
"CLAMP",
"(",
"dw",
"->",
"weight",
",",
"0.0f",
",",
"1.0f",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Same as #defvert_normalize but takes a bool array. | [
"Same",
"as",
"#defvert_normalize",
"but",
"takes",
"a",
"bool",
"array",
"."
] | [
"/* nothing */",
"/* in case of division errors with very low weights */"
] | [
{
"param": "dvert",
"type": "MDeformVert"
},
{
"param": "vgroup_subset",
"type": "bool"
},
{
"param": "vgroup_tot",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vgroup_subset",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vgroup_tot",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_normalize_lock_single | void | void defvert_normalize_lock_single(MDeformVert *dvert,
const bool *vgroup_subset,
const int vgroup_tot,
const int def_nr_lock)
{
if (dvert->totweight == 0) {
/* nothing */
}
else if (dvert->totweight == 1) {
MDeformWeight *dw = dvert->dw;
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
if (def_nr_lock != 0) {
dw->weight = 1.0f;
}
}
}
else {
MDeformWeight *dw_lock = NULL;
MDeformWeight *dw;
unsigned int i;
float tot_weight = 0.0f;
float lock_iweight = 1.0f;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
if (dw->def_nr != def_nr_lock) {
tot_weight += dw->weight;
}
else {
dw_lock = dw;
lock_iweight = (1.0f - dw_lock->weight);
CLAMP(lock_iweight, 0.0f, 1.0f);
}
}
}
if (tot_weight > 0.0f) {
/* paranoid, should be 1.0 but in case of float error clamp anyway */
float scalar = (1.0f / tot_weight) * lock_iweight;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
if (dw != dw_lock) {
dw->weight *= scalar;
/* in case of division errors with very low weights */
CLAMP(dw->weight, 0.0f, 1.0f);
}
}
}
}
}
} | /**
* Same as defvert_normalize() if the locked vgroup is not a member of the subset
*/ | Same as defvert_normalize() if the locked vgroup is not a member of the subset | [
"Same",
"as",
"defvert_normalize",
"()",
"if",
"the",
"locked",
"vgroup",
"is",
"not",
"a",
"member",
"of",
"the",
"subset"
] | void defvert_normalize_lock_single(MDeformVert *dvert,
const bool *vgroup_subset,
const int vgroup_tot,
const int def_nr_lock)
{
if (dvert->totweight == 0) {
}
else if (dvert->totweight == 1) {
MDeformWeight *dw = dvert->dw;
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
if (def_nr_lock != 0) {
dw->weight = 1.0f;
}
}
}
else {
MDeformWeight *dw_lock = NULL;
MDeformWeight *dw;
unsigned int i;
float tot_weight = 0.0f;
float lock_iweight = 1.0f;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
if (dw->def_nr != def_nr_lock) {
tot_weight += dw->weight;
}
else {
dw_lock = dw;
lock_iweight = (1.0f - dw_lock->weight);
CLAMP(lock_iweight, 0.0f, 1.0f);
}
}
}
if (tot_weight > 0.0f) {
float scalar = (1.0f / tot_weight) * lock_iweight;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
if (dw != dw_lock) {
dw->weight *= scalar;
CLAMP(dw->weight, 0.0f, 1.0f);
}
}
}
}
}
} | [
"void",
"defvert_normalize_lock_single",
"(",
"MDeformVert",
"*",
"dvert",
",",
"const",
"bool",
"*",
"vgroup_subset",
",",
"const",
"int",
"vgroup_tot",
",",
"const",
"int",
"def_nr_lock",
")",
"{",
"if",
"(",
"dvert",
"->",
"totweight",
"==",
"0",
")",
"{",
"}",
"else",
"if",
"(",
"dvert",
"->",
"totweight",
"==",
"1",
")",
"{",
"MDeformWeight",
"*",
"dw",
"=",
"dvert",
"->",
"dw",
";",
"if",
"(",
"(",
"dw",
"->",
"def_nr",
"<",
"vgroup_tot",
")",
"&&",
"vgroup_subset",
"[",
"dw",
"->",
"def_nr",
"]",
")",
"{",
"if",
"(",
"def_nr_lock",
"!=",
"0",
")",
"{",
"dw",
"->",
"weight",
"=",
"1.0f",
";",
"}",
"}",
"}",
"else",
"{",
"MDeformWeight",
"*",
"dw_lock",
"=",
"NULL",
";",
"MDeformWeight",
"*",
"dw",
";",
"unsigned",
"int",
"i",
";",
"float",
"tot_weight",
"=",
"0.0f",
";",
"float",
"lock_iweight",
"=",
"1.0f",
";",
"for",
"(",
"i",
"=",
"dvert",
"->",
"totweight",
",",
"dw",
"=",
"dvert",
"->",
"dw",
";",
"i",
"!=",
"0",
";",
"i",
"--",
",",
"dw",
"++",
")",
"{",
"if",
"(",
"(",
"dw",
"->",
"def_nr",
"<",
"vgroup_tot",
")",
"&&",
"vgroup_subset",
"[",
"dw",
"->",
"def_nr",
"]",
")",
"{",
"if",
"(",
"dw",
"->",
"def_nr",
"!=",
"def_nr_lock",
")",
"{",
"tot_weight",
"+=",
"dw",
"->",
"weight",
";",
"}",
"else",
"{",
"dw_lock",
"=",
"dw",
";",
"lock_iweight",
"=",
"(",
"1.0f",
"-",
"dw_lock",
"->",
"weight",
")",
";",
"CLAMP",
"(",
"lock_iweight",
",",
"0.0f",
",",
"1.0f",
")",
";",
"}",
"}",
"}",
"if",
"(",
"tot_weight",
">",
"0.0f",
")",
"{",
"float",
"scalar",
"=",
"(",
"1.0f",
"/",
"tot_weight",
")",
"*",
"lock_iweight",
";",
"for",
"(",
"i",
"=",
"dvert",
"->",
"totweight",
",",
"dw",
"=",
"dvert",
"->",
"dw",
";",
"i",
"!=",
"0",
";",
"i",
"--",
",",
"dw",
"++",
")",
"{",
"if",
"(",
"(",
"dw",
"->",
"def_nr",
"<",
"vgroup_tot",
")",
"&&",
"vgroup_subset",
"[",
"dw",
"->",
"def_nr",
"]",
")",
"{",
"if",
"(",
"dw",
"!=",
"dw_lock",
")",
"{",
"dw",
"->",
"weight",
"*=",
"scalar",
";",
"CLAMP",
"(",
"dw",
"->",
"weight",
",",
"0.0f",
",",
"1.0f",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] | Same as defvert_normalize() if the locked vgroup is not a member of the subset | [
"Same",
"as",
"defvert_normalize",
"()",
"if",
"the",
"locked",
"vgroup",
"is",
"not",
"a",
"member",
"of",
"the",
"subset"
] | [
"/* nothing */",
"/* paranoid, should be 1.0 but in case of float error clamp anyway */",
"/* in case of division errors with very low weights */"
] | [
{
"param": "dvert",
"type": "MDeformVert"
},
{
"param": "vgroup_subset",
"type": "bool"
},
{
"param": "vgroup_tot",
"type": "int"
},
{
"param": "def_nr_lock",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vgroup_subset",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vgroup_tot",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "def_nr_lock",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_normalize_lock_map | void | void defvert_normalize_lock_map(MDeformVert *dvert,
const bool *vgroup_subset,
const int vgroup_tot,
const bool *lock_flags,
const int defbase_tot)
{
if (dvert->totweight == 0) {
/* nothing */
}
else if (dvert->totweight == 1) {
MDeformWeight *dw = dvert->dw;
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
if ((dw->def_nr < defbase_tot) && (lock_flags[dw->def_nr] == false)) {
dw->weight = 1.0f;
}
}
}
else {
MDeformWeight *dw;
unsigned int i;
float tot_weight = 0.0f;
float lock_iweight = 0.0f;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
if ((dw->def_nr < defbase_tot) && (lock_flags[dw->def_nr] == false)) {
tot_weight += dw->weight;
}
else {
/* invert after */
lock_iweight += dw->weight;
}
}
}
lock_iweight = max_ff(0.0f, 1.0f - lock_iweight);
if (tot_weight > 0.0f) {
/* paranoid, should be 1.0 but in case of float error clamp anyway */
float scalar = (1.0f / tot_weight) * lock_iweight;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
if ((dw->def_nr < defbase_tot) && (lock_flags[dw->def_nr] == false)) {
dw->weight *= scalar;
/* in case of division errors with very low weights */
CLAMP(dw->weight, 0.0f, 1.0f);
}
}
}
}
}
} | /**
* Same as defvert_normalize() if no locked vgroup is a member of the subset
*/ | Same as defvert_normalize() if no locked vgroup is a member of the subset | [
"Same",
"as",
"defvert_normalize",
"()",
"if",
"no",
"locked",
"vgroup",
"is",
"a",
"member",
"of",
"the",
"subset"
] | void defvert_normalize_lock_map(MDeformVert *dvert,
const bool *vgroup_subset,
const int vgroup_tot,
const bool *lock_flags,
const int defbase_tot)
{
if (dvert->totweight == 0) {
}
else if (dvert->totweight == 1) {
MDeformWeight *dw = dvert->dw;
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
if ((dw->def_nr < defbase_tot) && (lock_flags[dw->def_nr] == false)) {
dw->weight = 1.0f;
}
}
}
else {
MDeformWeight *dw;
unsigned int i;
float tot_weight = 0.0f;
float lock_iweight = 0.0f;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
if ((dw->def_nr < defbase_tot) && (lock_flags[dw->def_nr] == false)) {
tot_weight += dw->weight;
}
else {
lock_iweight += dw->weight;
}
}
}
lock_iweight = max_ff(0.0f, 1.0f - lock_iweight);
if (tot_weight > 0.0f) {
float scalar = (1.0f / tot_weight) * lock_iweight;
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if ((dw->def_nr < vgroup_tot) && vgroup_subset[dw->def_nr]) {
if ((dw->def_nr < defbase_tot) && (lock_flags[dw->def_nr] == false)) {
dw->weight *= scalar;
CLAMP(dw->weight, 0.0f, 1.0f);
}
}
}
}
}
} | [
"void",
"defvert_normalize_lock_map",
"(",
"MDeformVert",
"*",
"dvert",
",",
"const",
"bool",
"*",
"vgroup_subset",
",",
"const",
"int",
"vgroup_tot",
",",
"const",
"bool",
"*",
"lock_flags",
",",
"const",
"int",
"defbase_tot",
")",
"{",
"if",
"(",
"dvert",
"->",
"totweight",
"==",
"0",
")",
"{",
"}",
"else",
"if",
"(",
"dvert",
"->",
"totweight",
"==",
"1",
")",
"{",
"MDeformWeight",
"*",
"dw",
"=",
"dvert",
"->",
"dw",
";",
"if",
"(",
"(",
"dw",
"->",
"def_nr",
"<",
"vgroup_tot",
")",
"&&",
"vgroup_subset",
"[",
"dw",
"->",
"def_nr",
"]",
")",
"{",
"if",
"(",
"(",
"dw",
"->",
"def_nr",
"<",
"defbase_tot",
")",
"&&",
"(",
"lock_flags",
"[",
"dw",
"->",
"def_nr",
"]",
"==",
"false",
")",
")",
"{",
"dw",
"->",
"weight",
"=",
"1.0f",
";",
"}",
"}",
"}",
"else",
"{",
"MDeformWeight",
"*",
"dw",
";",
"unsigned",
"int",
"i",
";",
"float",
"tot_weight",
"=",
"0.0f",
";",
"float",
"lock_iweight",
"=",
"0.0f",
";",
"for",
"(",
"i",
"=",
"dvert",
"->",
"totweight",
",",
"dw",
"=",
"dvert",
"->",
"dw",
";",
"i",
"!=",
"0",
";",
"i",
"--",
",",
"dw",
"++",
")",
"{",
"if",
"(",
"(",
"dw",
"->",
"def_nr",
"<",
"vgroup_tot",
")",
"&&",
"vgroup_subset",
"[",
"dw",
"->",
"def_nr",
"]",
")",
"{",
"if",
"(",
"(",
"dw",
"->",
"def_nr",
"<",
"defbase_tot",
")",
"&&",
"(",
"lock_flags",
"[",
"dw",
"->",
"def_nr",
"]",
"==",
"false",
")",
")",
"{",
"tot_weight",
"+=",
"dw",
"->",
"weight",
";",
"}",
"else",
"{",
"lock_iweight",
"+=",
"dw",
"->",
"weight",
";",
"}",
"}",
"}",
"lock_iweight",
"=",
"max_ff",
"(",
"0.0f",
",",
"1.0f",
"-",
"lock_iweight",
")",
";",
"if",
"(",
"tot_weight",
">",
"0.0f",
")",
"{",
"float",
"scalar",
"=",
"(",
"1.0f",
"/",
"tot_weight",
")",
"*",
"lock_iweight",
";",
"for",
"(",
"i",
"=",
"dvert",
"->",
"totweight",
",",
"dw",
"=",
"dvert",
"->",
"dw",
";",
"i",
"!=",
"0",
";",
"i",
"--",
",",
"dw",
"++",
")",
"{",
"if",
"(",
"(",
"dw",
"->",
"def_nr",
"<",
"vgroup_tot",
")",
"&&",
"vgroup_subset",
"[",
"dw",
"->",
"def_nr",
"]",
")",
"{",
"if",
"(",
"(",
"dw",
"->",
"def_nr",
"<",
"defbase_tot",
")",
"&&",
"(",
"lock_flags",
"[",
"dw",
"->",
"def_nr",
"]",
"==",
"false",
")",
")",
"{",
"dw",
"->",
"weight",
"*=",
"scalar",
";",
"CLAMP",
"(",
"dw",
"->",
"weight",
",",
"0.0f",
",",
"1.0f",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] | Same as defvert_normalize() if no locked vgroup is a member of the subset | [
"Same",
"as",
"defvert_normalize",
"()",
"if",
"no",
"locked",
"vgroup",
"is",
"a",
"member",
"of",
"the",
"subset"
] | [
"/* nothing */",
"/* invert after */",
"/* paranoid, should be 1.0 but in case of float error clamp anyway */",
"/* in case of division errors with very low weights */"
] | [
{
"param": "dvert",
"type": "MDeformVert"
},
{
"param": "vgroup_subset",
"type": "bool"
},
{
"param": "vgroup_tot",
"type": "int"
},
{
"param": "lock_flags",
"type": "bool"
},
{
"param": "defbase_tot",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vgroup_subset",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vgroup_tot",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lock_flags",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defbase_tot",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_array_find_weight_safe | float | float defvert_array_find_weight_safe(const struct MDeformVert *dvert,
const int index,
const int defgroup)
{
/* Invalid defgroup index means the vgroup selected is invalid,
* does not exist, in that case it is OK to return 1.0
* (i.e. maximum weight, as if no vgroup was selected).
* But in case of valid defgroup and NULL dvert data pointer, it means that vgroup **is** valid,
* and just totally empty, so we shall return '0.0' value then! */
if (defgroup == -1) {
return 1.0f;
}
else if (dvert == NULL) {
return 0.0f;
}
return defvert_find_weight(dvert + index, defgroup);
} | /**
* Take care with this the rationale is:
* - if the object has no vertex group. act like vertex group isn't set and return 1.0,
* - if the vertex group exists but the 'defgroup' isn't found on this vertex, _still_ return 0.0
*
* This is a bit confusing, just saves some checks from the caller.
*/ | Take care with this the rationale is:
- if the object has no vertex group. act like vertex group isn't set and return 1.0,
- if the vertex group exists but the 'defgroup' isn't found on this vertex, _still_ return 0.0
This is a bit confusing, just saves some checks from the caller. | [
"Take",
"care",
"with",
"this",
"the",
"rationale",
"is",
":",
"-",
"if",
"the",
"object",
"has",
"no",
"vertex",
"group",
".",
"act",
"like",
"vertex",
"group",
"isn",
"'",
"t",
"set",
"and",
"return",
"1",
".",
"0",
"-",
"if",
"the",
"vertex",
"group",
"exists",
"but",
"the",
"'",
"defgroup",
"'",
"isn",
"'",
"t",
"found",
"on",
"this",
"vertex",
"_still_",
"return",
"0",
".",
"0",
"This",
"is",
"a",
"bit",
"confusing",
"just",
"saves",
"some",
"checks",
"from",
"the",
"caller",
"."
] | float defvert_array_find_weight_safe(const struct MDeformVert *dvert,
const int index,
const int defgroup)
{
if (defgroup == -1) {
return 1.0f;
}
else if (dvert == NULL) {
return 0.0f;
}
return defvert_find_weight(dvert + index, defgroup);
} | [
"float",
"defvert_array_find_weight_safe",
"(",
"const",
"struct",
"MDeformVert",
"*",
"dvert",
",",
"const",
"int",
"index",
",",
"const",
"int",
"defgroup",
")",
"{",
"if",
"(",
"defgroup",
"==",
"-1",
")",
"{",
"return",
"1.0f",
";",
"}",
"else",
"if",
"(",
"dvert",
"==",
"NULL",
")",
"{",
"return",
"0.0f",
";",
"}",
"return",
"defvert_find_weight",
"(",
"dvert",
"+",
"index",
",",
"defgroup",
")",
";",
"}"
] | Take care with this the rationale is:
- if the object has no vertex group. | [
"Take",
"care",
"with",
"this",
"the",
"rationale",
"is",
":",
"-",
"if",
"the",
"object",
"has",
"no",
"vertex",
"group",
"."
] | [
"/* Invalid defgroup index means the vgroup selected is invalid,\n * does not exist, in that case it is OK to return 1.0\n * (i.e. maximum weight, as if no vgroup was selected).\n * But in case of valid defgroup and NULL dvert data pointer, it means that vgroup **is** valid,\n * and just totally empty, so we shall return '0.0' value then! */"
] | [
{
"param": "dvert",
"type": "struct MDeformVert"
},
{
"param": "index",
"type": "int"
},
{
"param": "defgroup",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert",
"type": "struct MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "index",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defgroup",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_verify_index | MDeformWeight | MDeformWeight *defvert_verify_index(MDeformVert *dvert, const int defgroup)
{
MDeformWeight *dw_new;
/* do this check always, this function is used to check for it */
if (!dvert || defgroup < 0) {
BLI_assert(0);
return NULL;
}
dw_new = defvert_find_index(dvert, defgroup);
if (dw_new) {
return dw_new;
}
dw_new = MEM_mallocN(sizeof(MDeformWeight) * (dvert->totweight + 1), "deformWeight");
if (dvert->dw) {
memcpy(dw_new, dvert->dw, sizeof(MDeformWeight) * dvert->totweight);
MEM_freeN(dvert->dw);
}
dvert->dw = dw_new;
dw_new += dvert->totweight;
dw_new->weight = 0.0f;
dw_new->def_nr = defgroup;
/* Group index */
dvert->totweight++;
return dw_new;
} | /**
* Ensures that mv has a deform weight entry for the specified defweight group.
*
* \note this function is mirrored in editmesh_tools.c, for use for editvertices.
*/ | Ensures that mv has a deform weight entry for the specified defweight group.
\note this function is mirrored in editmesh_tools.c, for use for editvertices. | [
"Ensures",
"that",
"mv",
"has",
"a",
"deform",
"weight",
"entry",
"for",
"the",
"specified",
"defweight",
"group",
".",
"\\",
"note",
"this",
"function",
"is",
"mirrored",
"in",
"editmesh_tools",
".",
"c",
"for",
"use",
"for",
"editvertices",
"."
] | MDeformWeight *defvert_verify_index(MDeformVert *dvert, const int defgroup)
{
MDeformWeight *dw_new;
if (!dvert || defgroup < 0) {
BLI_assert(0);
return NULL;
}
dw_new = defvert_find_index(dvert, defgroup);
if (dw_new) {
return dw_new;
}
dw_new = MEM_mallocN(sizeof(MDeformWeight) * (dvert->totweight + 1), "deformWeight");
if (dvert->dw) {
memcpy(dw_new, dvert->dw, sizeof(MDeformWeight) * dvert->totweight);
MEM_freeN(dvert->dw);
}
dvert->dw = dw_new;
dw_new += dvert->totweight;
dw_new->weight = 0.0f;
dw_new->def_nr = defgroup;
dvert->totweight++;
return dw_new;
} | [
"MDeformWeight",
"*",
"defvert_verify_index",
"(",
"MDeformVert",
"*",
"dvert",
",",
"const",
"int",
"defgroup",
")",
"{",
"MDeformWeight",
"*",
"dw_new",
";",
"if",
"(",
"!",
"dvert",
"||",
"defgroup",
"<",
"0",
")",
"{",
"BLI_assert",
"(",
"0",
")",
";",
"return",
"NULL",
";",
"}",
"dw_new",
"=",
"defvert_find_index",
"(",
"dvert",
",",
"defgroup",
")",
";",
"if",
"(",
"dw_new",
")",
"{",
"return",
"dw_new",
";",
"}",
"dw_new",
"=",
"MEM_mallocN",
"(",
"sizeof",
"(",
"MDeformWeight",
")",
"*",
"(",
"dvert",
"->",
"totweight",
"+",
"1",
")",
",",
"\"",
"\"",
")",
";",
"if",
"(",
"dvert",
"->",
"dw",
")",
"{",
"memcpy",
"(",
"dw_new",
",",
"dvert",
"->",
"dw",
",",
"sizeof",
"(",
"MDeformWeight",
")",
"*",
"dvert",
"->",
"totweight",
")",
";",
"MEM_freeN",
"(",
"dvert",
"->",
"dw",
")",
";",
"}",
"dvert",
"->",
"dw",
"=",
"dw_new",
";",
"dw_new",
"+=",
"dvert",
"->",
"totweight",
";",
"dw_new",
"->",
"weight",
"=",
"0.0f",
";",
"dw_new",
"->",
"def_nr",
"=",
"defgroup",
";",
"dvert",
"->",
"totweight",
"++",
";",
"return",
"dw_new",
";",
"}"
] | Ensures that mv has a deform weight entry for the specified defweight group. | [
"Ensures",
"that",
"mv",
"has",
"a",
"deform",
"weight",
"entry",
"for",
"the",
"specified",
"defweight",
"group",
"."
] | [
"/* do this check always, this function is used to check for it */",
"/* Group index */"
] | [
{
"param": "dvert",
"type": "MDeformVert"
},
{
"param": "defgroup",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defgroup",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_add_index_notest | void | void defvert_add_index_notest(MDeformVert *dvert, int defgroup, const float weight)
{
MDeformWeight *dw_new;
/* do this check always, this function is used to check for it */
if (!dvert || defgroup < 0) {
BLI_assert(0);
return;
}
dw_new = MEM_callocN(sizeof(MDeformWeight) * (dvert->totweight + 1),
"defvert_add_to group, new deformWeight");
if (dvert->dw) {
memcpy(dw_new, dvert->dw, sizeof(MDeformWeight) * dvert->totweight);
MEM_freeN(dvert->dw);
}
dvert->dw = dw_new;
dw_new += dvert->totweight;
dw_new->weight = weight;
dw_new->def_nr = defgroup;
dvert->totweight++;
} | /**
* Adds the given vertex to the specified vertex group, with given weight.
*
* \warning this does NOT check for existing, assume caller already knows its not there.
*/ | Adds the given vertex to the specified vertex group, with given weight.
\warning this does NOT check for existing, assume caller already knows its not there. | [
"Adds",
"the",
"given",
"vertex",
"to",
"the",
"specified",
"vertex",
"group",
"with",
"given",
"weight",
".",
"\\",
"warning",
"this",
"does",
"NOT",
"check",
"for",
"existing",
"assume",
"caller",
"already",
"knows",
"its",
"not",
"there",
"."
] | void defvert_add_index_notest(MDeformVert *dvert, int defgroup, const float weight)
{
MDeformWeight *dw_new;
if (!dvert || defgroup < 0) {
BLI_assert(0);
return;
}
dw_new = MEM_callocN(sizeof(MDeformWeight) * (dvert->totweight + 1),
"defvert_add_to group, new deformWeight");
if (dvert->dw) {
memcpy(dw_new, dvert->dw, sizeof(MDeformWeight) * dvert->totweight);
MEM_freeN(dvert->dw);
}
dvert->dw = dw_new;
dw_new += dvert->totweight;
dw_new->weight = weight;
dw_new->def_nr = defgroup;
dvert->totweight++;
} | [
"void",
"defvert_add_index_notest",
"(",
"MDeformVert",
"*",
"dvert",
",",
"int",
"defgroup",
",",
"const",
"float",
"weight",
")",
"{",
"MDeformWeight",
"*",
"dw_new",
";",
"if",
"(",
"!",
"dvert",
"||",
"defgroup",
"<",
"0",
")",
"{",
"BLI_assert",
"(",
"0",
")",
";",
"return",
";",
"}",
"dw_new",
"=",
"MEM_callocN",
"(",
"sizeof",
"(",
"MDeformWeight",
")",
"*",
"(",
"dvert",
"->",
"totweight",
"+",
"1",
")",
",",
"\"",
"\"",
")",
";",
"if",
"(",
"dvert",
"->",
"dw",
")",
"{",
"memcpy",
"(",
"dw_new",
",",
"dvert",
"->",
"dw",
",",
"sizeof",
"(",
"MDeformWeight",
")",
"*",
"dvert",
"->",
"totweight",
")",
";",
"MEM_freeN",
"(",
"dvert",
"->",
"dw",
")",
";",
"}",
"dvert",
"->",
"dw",
"=",
"dw_new",
";",
"dw_new",
"+=",
"dvert",
"->",
"totweight",
";",
"dw_new",
"->",
"weight",
"=",
"weight",
";",
"dw_new",
"->",
"def_nr",
"=",
"defgroup",
";",
"dvert",
"->",
"totweight",
"++",
";",
"}"
] | Adds the given vertex to the specified vertex group, with given weight. | [
"Adds",
"the",
"given",
"vertex",
"to",
"the",
"specified",
"vertex",
"group",
"with",
"given",
"weight",
"."
] | [
"/* do this check always, this function is used to check for it */"
] | [
{
"param": "dvert",
"type": "MDeformVert"
},
{
"param": "defgroup",
"type": "int"
},
{
"param": "weight",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defgroup",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "weight",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_remove_group | void | void defvert_remove_group(MDeformVert *dvert, MDeformWeight *dw)
{
if (dvert && dw) {
int i = dw - dvert->dw;
/* Security check! */
if (i < 0 || i >= dvert->totweight) {
return;
}
dvert->totweight--;
/* If there are still other deform weights attached to this vert then remove
* this deform weight, and reshuffle the others.
*/
if (dvert->totweight) {
BLI_assert(dvert->dw != NULL);
if (i != dvert->totweight) {
dvert->dw[i] = dvert->dw[dvert->totweight];
}
dvert->dw = MEM_reallocN(dvert->dw, sizeof(MDeformWeight) * dvert->totweight);
}
else {
/* If there are no other deform weights left then just remove this one. */
MEM_freeN(dvert->dw);
dvert->dw = NULL;
}
}
} | /**
* Removes the given vertex from the vertex group.
*
* \warning This function frees the given MDeformWeight, do not use it afterward!
*/ | Removes the given vertex from the vertex group.
\warning This function frees the given MDeformWeight, do not use it afterward! | [
"Removes",
"the",
"given",
"vertex",
"from",
"the",
"vertex",
"group",
".",
"\\",
"warning",
"This",
"function",
"frees",
"the",
"given",
"MDeformWeight",
"do",
"not",
"use",
"it",
"afterward!"
] | void defvert_remove_group(MDeformVert *dvert, MDeformWeight *dw)
{
if (dvert && dw) {
int i = dw - dvert->dw;
if (i < 0 || i >= dvert->totweight) {
return;
}
dvert->totweight--;
if (dvert->totweight) {
BLI_assert(dvert->dw != NULL);
if (i != dvert->totweight) {
dvert->dw[i] = dvert->dw[dvert->totweight];
}
dvert->dw = MEM_reallocN(dvert->dw, sizeof(MDeformWeight) * dvert->totweight);
}
else {
MEM_freeN(dvert->dw);
dvert->dw = NULL;
}
}
} | [
"void",
"defvert_remove_group",
"(",
"MDeformVert",
"*",
"dvert",
",",
"MDeformWeight",
"*",
"dw",
")",
"{",
"if",
"(",
"dvert",
"&&",
"dw",
")",
"{",
"int",
"i",
"=",
"dw",
"-",
"dvert",
"->",
"dw",
";",
"if",
"(",
"i",
"<",
"0",
"||",
"i",
">=",
"dvert",
"->",
"totweight",
")",
"{",
"return",
";",
"}",
"dvert",
"->",
"totweight",
"--",
";",
"if",
"(",
"dvert",
"->",
"totweight",
")",
"{",
"BLI_assert",
"(",
"dvert",
"->",
"dw",
"!=",
"NULL",
")",
";",
"if",
"(",
"i",
"!=",
"dvert",
"->",
"totweight",
")",
"{",
"dvert",
"->",
"dw",
"[",
"i",
"]",
"=",
"dvert",
"->",
"dw",
"[",
"dvert",
"->",
"totweight",
"]",
";",
"}",
"dvert",
"->",
"dw",
"=",
"MEM_reallocN",
"(",
"dvert",
"->",
"dw",
",",
"sizeof",
"(",
"MDeformWeight",
")",
"*",
"dvert",
"->",
"totweight",
")",
";",
"}",
"else",
"{",
"MEM_freeN",
"(",
"dvert",
"->",
"dw",
")",
";",
"dvert",
"->",
"dw",
"=",
"NULL",
";",
"}",
"}",
"}"
] | Removes the given vertex from the vertex group. | [
"Removes",
"the",
"given",
"vertex",
"from",
"the",
"vertex",
"group",
"."
] | [
"/* Security check! */",
"/* If there are still other deform weights attached to this vert then remove\n * this deform weight, and reshuffle the others.\n */",
"/* If there are no other deform weights left then just remove this one. */"
] | [
{
"param": "dvert",
"type": "MDeformVert"
},
{
"param": "dw",
"type": "MDeformWeight"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dw",
"type": "MDeformWeight",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_find_shared | int | int defvert_find_shared(const MDeformVert *dvert_a, const MDeformVert *dvert_b)
{
if (dvert_a->totweight && dvert_b->totweight) {
MDeformWeight *dw = dvert_a->dw;
unsigned int i;
for (i = dvert_a->totweight; i != 0; i--, dw++) {
if (dw->weight > 0.0f && defvert_find_weight(dvert_b, dw->def_nr) > 0.0f) {
return dw->def_nr;
}
}
}
return -1;
} | /**
* \return The first group index shared by both deform verts
* or -1 if none are found.
*/ | \return The first group index shared by both deform verts
or -1 if none are found. | [
"\\",
"return",
"The",
"first",
"group",
"index",
"shared",
"by",
"both",
"deform",
"verts",
"or",
"-",
"1",
"if",
"none",
"are",
"found",
"."
] | int defvert_find_shared(const MDeformVert *dvert_a, const MDeformVert *dvert_b)
{
if (dvert_a->totweight && dvert_b->totweight) {
MDeformWeight *dw = dvert_a->dw;
unsigned int i;
for (i = dvert_a->totweight; i != 0; i--, dw++) {
if (dw->weight > 0.0f && defvert_find_weight(dvert_b, dw->def_nr) > 0.0f) {
return dw->def_nr;
}
}
}
return -1;
} | [
"int",
"defvert_find_shared",
"(",
"const",
"MDeformVert",
"*",
"dvert_a",
",",
"const",
"MDeformVert",
"*",
"dvert_b",
")",
"{",
"if",
"(",
"dvert_a",
"->",
"totweight",
"&&",
"dvert_b",
"->",
"totweight",
")",
"{",
"MDeformWeight",
"*",
"dw",
"=",
"dvert_a",
"->",
"dw",
";",
"unsigned",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"dvert_a",
"->",
"totweight",
";",
"i",
"!=",
"0",
";",
"i",
"--",
",",
"dw",
"++",
")",
"{",
"if",
"(",
"dw",
"->",
"weight",
">",
"0.0f",
"&&",
"defvert_find_weight",
"(",
"dvert_b",
",",
"dw",
"->",
"def_nr",
")",
">",
"0.0f",
")",
"{",
"return",
"dw",
"->",
"def_nr",
";",
"}",
"}",
"}",
"return",
"-1",
";",
"}"
] | \return The first group index shared by both deform verts
or -1 if none are found. | [
"\\",
"return",
"The",
"first",
"group",
"index",
"shared",
"by",
"both",
"deform",
"verts",
"or",
"-",
"1",
"if",
"none",
"are",
"found",
"."
] | [] | [
{
"param": "dvert_a",
"type": "MDeformVert"
},
{
"param": "dvert_b",
"type": "MDeformVert"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert_a",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dvert_b",
"type": "MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | defvert_is_weight_zero | bool | bool defvert_is_weight_zero(const struct MDeformVert *dvert, const int defgroup_tot)
{
MDeformWeight *dw = dvert->dw;
unsigned int i;
for (i = dvert->totweight; i != 0; i--, dw++) {
if (dw->weight != 0.0f) {
/* check the group is in-range, happens on rare situations */
if (LIKELY(dw->def_nr < defgroup_tot)) {
return false;
}
}
}
return true;
} | /**
* return true if has no weights
*/ | return true if has no weights | [
"return",
"true",
"if",
"has",
"no",
"weights"
] | bool defvert_is_weight_zero(const struct MDeformVert *dvert, const int defgroup_tot)
{
MDeformWeight *dw = dvert->dw;
unsigned int i;
for (i = dvert->totweight; i != 0; i--, dw++) {
if (dw->weight != 0.0f) {
if (LIKELY(dw->def_nr < defgroup_tot)) {
return false;
}
}
}
return true;
} | [
"bool",
"defvert_is_weight_zero",
"(",
"const",
"struct",
"MDeformVert",
"*",
"dvert",
",",
"const",
"int",
"defgroup_tot",
")",
"{",
"MDeformWeight",
"*",
"dw",
"=",
"dvert",
"->",
"dw",
";",
"unsigned",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"dvert",
"->",
"totweight",
";",
"i",
"!=",
"0",
";",
"i",
"--",
",",
"dw",
"++",
")",
"{",
"if",
"(",
"dw",
"->",
"weight",
"!=",
"0.0f",
")",
"{",
"if",
"(",
"LIKELY",
"(",
"dw",
"->",
"def_nr",
"<",
"defgroup_tot",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | return true if has no weights | [
"return",
"true",
"if",
"has",
"no",
"weights"
] | [
"/* check the group is in-range, happens on rare situations */"
] | [
{
"param": "dvert",
"type": "struct MDeformVert"
},
{
"param": "defgroup_tot",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dvert",
"type": "struct MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defgroup_tot",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a964cab3fa51cb24ab095c3abd4d5185c5e56920 | DemonRem/blender | source/blender/blenkernel/intern/deform.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | BKE_defvert_multipaint_collective_weight | float | float BKE_defvert_multipaint_collective_weight(const struct MDeformVert *dv,
int defbase_tot,
const bool *defbase_sel,
int defbase_tot_sel,
bool do_autonormalize)
{
int i;
float total = 0.0f;
const MDeformWeight *dw = dv->dw;
for (i = dv->totweight; i != 0; i--, dw++) {
/* in multipaint, get the average if auto normalize is inactive
* get the sum if it is active */
if (dw->def_nr < defbase_tot) {
if (defbase_sel[dw->def_nr]) {
total += dw->weight;
}
}
}
if (do_autonormalize == false) {
total /= defbase_tot_sel;
}
return total;
} | /**
* \return The representative weight of a multipaint group, used for
* viewport colors and actual painting.
*
* Result equal to sum of weights with auto normalize, and average otherwise.
* Value is not clamped, since painting relies on multiplication being always
* commutative with the collective weight function.
*/ | \return The representative weight of a multipaint group, used for
viewport colors and actual painting.
Result equal to sum of weights with auto normalize, and average otherwise.
Value is not clamped, since painting relies on multiplication being always
commutative with the collective weight function. | [
"\\",
"return",
"The",
"representative",
"weight",
"of",
"a",
"multipaint",
"group",
"used",
"for",
"viewport",
"colors",
"and",
"actual",
"painting",
".",
"Result",
"equal",
"to",
"sum",
"of",
"weights",
"with",
"auto",
"normalize",
"and",
"average",
"otherwise",
".",
"Value",
"is",
"not",
"clamped",
"since",
"painting",
"relies",
"on",
"multiplication",
"being",
"always",
"commutative",
"with",
"the",
"collective",
"weight",
"function",
"."
] | float BKE_defvert_multipaint_collective_weight(const struct MDeformVert *dv,
int defbase_tot,
const bool *defbase_sel,
int defbase_tot_sel,
bool do_autonormalize)
{
int i;
float total = 0.0f;
const MDeformWeight *dw = dv->dw;
for (i = dv->totweight; i != 0; i--, dw++) {
if (dw->def_nr < defbase_tot) {
if (defbase_sel[dw->def_nr]) {
total += dw->weight;
}
}
}
if (do_autonormalize == false) {
total /= defbase_tot_sel;
}
return total;
} | [
"float",
"BKE_defvert_multipaint_collective_weight",
"(",
"const",
"struct",
"MDeformVert",
"*",
"dv",
",",
"int",
"defbase_tot",
",",
"const",
"bool",
"*",
"defbase_sel",
",",
"int",
"defbase_tot_sel",
",",
"bool",
"do_autonormalize",
")",
"{",
"int",
"i",
";",
"float",
"total",
"=",
"0.0f",
";",
"const",
"MDeformWeight",
"*",
"dw",
"=",
"dv",
"->",
"dw",
";",
"for",
"(",
"i",
"=",
"dv",
"->",
"totweight",
";",
"i",
"!=",
"0",
";",
"i",
"--",
",",
"dw",
"++",
")",
"{",
"if",
"(",
"dw",
"->",
"def_nr",
"<",
"defbase_tot",
")",
"{",
"if",
"(",
"defbase_sel",
"[",
"dw",
"->",
"def_nr",
"]",
")",
"{",
"total",
"+=",
"dw",
"->",
"weight",
";",
"}",
"}",
"}",
"if",
"(",
"do_autonormalize",
"==",
"false",
")",
"{",
"total",
"/=",
"defbase_tot_sel",
";",
"}",
"return",
"total",
";",
"}"
] | \return The representative weight of a multipaint group, used for
viewport colors and actual painting. | [
"\\",
"return",
"The",
"representative",
"weight",
"of",
"a",
"multipaint",
"group",
"used",
"for",
"viewport",
"colors",
"and",
"actual",
"painting",
"."
] | [
"/* in multipaint, get the average if auto normalize is inactive\n * get the sum if it is active */"
] | [
{
"param": "dv",
"type": "struct MDeformVert"
},
{
"param": "defbase_tot",
"type": "int"
},
{
"param": "defbase_sel",
"type": "bool"
},
{
"param": "defbase_tot_sel",
"type": "int"
},
{
"param": "do_autonormalize",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dv",
"type": "struct MDeformVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defbase_tot",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defbase_sel",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defbase_tot_sel",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "do_autonormalize",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | annotation_draw_stroke_buffer | void | static void annotation_draw_stroke_buffer(const tGPspoint *points,
int totpoints,
short thickness,
short dflag,
short sflag,
const float ink[4])
{
int draw_points = 0;
/* error checking */
if ((points == NULL) || (totpoints <= 0)) {
return;
}
/* check if buffer can be drawn */
if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D)) {
return;
}
if (sflag & GP_STROKE_ERASER) {
/* don't draw stroke at all! */
return;
}
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
const tGPspoint *pt = points;
if (totpoints == 1) {
/* if drawing a single point, draw it larger */
GPU_point_size((float)(thickness + 2) * points->pressure);
immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
immUniformColor3fvAlpha(ink, ink[3]);
immBegin(GPU_PRIM_POINTS, 1);
immVertex2fv(pos, &pt->x);
}
else {
float oldpressure = points[0].pressure;
/* draw stroke curve */
GPU_line_width(max_ff(oldpressure * thickness, 1.0));
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3fvAlpha(ink, ink[3]);
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints);
for (int i = 0; i < totpoints; i++, pt++) {
/* If there was a significant pressure change,
* stop the curve, change the thickness of the stroke,
* and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP).
*/
if (fabsf(pt->pressure - oldpressure) > 0.2f) {
/* need to have 2 points to avoid immEnd assert error */
if (draw_points < 2) {
immVertex2fv(pos, &(pt - 1)->x);
}
immEnd();
draw_points = 0;
GPU_line_width(max_ff(pt->pressure * thickness, 1.0f));
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
if (i != 0) {
immVertex2fv(pos, &(pt - 1)->x);
draw_points++;
}
oldpressure = pt->pressure; /* reset our threshold */
}
/* now the point we want */
immVertex2fv(pos, &pt->x);
draw_points++;
}
/* need to have 2 points to avoid immEnd assert error */
if (draw_points < 2) {
immVertex2fv(pos, &(pt - 1)->x);
}
}
immEnd();
immUnbindProgram();
} | /* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */ | draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) | [
"draw",
"stroke",
"defined",
"in",
"buffer",
"(",
"simple",
"ogl",
"lines",
"/",
"points",
"for",
"now",
"as",
"dotted",
"lines",
")"
] | static void annotation_draw_stroke_buffer(const tGPspoint *points,
int totpoints,
short thickness,
short dflag,
short sflag,
const float ink[4])
{
int draw_points = 0;
if ((points == NULL) || (totpoints <= 0)) {
return;
}
if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D)) {
return;
}
if (sflag & GP_STROKE_ERASER) {
return;
}
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
const tGPspoint *pt = points;
if (totpoints == 1) {
GPU_point_size((float)(thickness + 2) * points->pressure);
immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
immUniformColor3fvAlpha(ink, ink[3]);
immBegin(GPU_PRIM_POINTS, 1);
immVertex2fv(pos, &pt->x);
}
else {
float oldpressure = points[0].pressure;
GPU_line_width(max_ff(oldpressure * thickness, 1.0));
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3fvAlpha(ink, ink[3]);
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints);
for (int i = 0; i < totpoints; i++, pt++) {
if (fabsf(pt->pressure - oldpressure) > 0.2f) {
if (draw_points < 2) {
immVertex2fv(pos, &(pt - 1)->x);
}
immEnd();
draw_points = 0;
GPU_line_width(max_ff(pt->pressure * thickness, 1.0f));
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1);
if (i != 0) {
immVertex2fv(pos, &(pt - 1)->x);
draw_points++;
}
oldpressure = pt->pressure;
}
immVertex2fv(pos, &pt->x);
draw_points++;
}
if (draw_points < 2) {
immVertex2fv(pos, &(pt - 1)->x);
}
}
immEnd();
immUnbindProgram();
} | [
"static",
"void",
"annotation_draw_stroke_buffer",
"(",
"const",
"tGPspoint",
"*",
"points",
",",
"int",
"totpoints",
",",
"short",
"thickness",
",",
"short",
"dflag",
",",
"short",
"sflag",
",",
"const",
"float",
"ink",
"[",
"4",
"]",
")",
"{",
"int",
"draw_points",
"=",
"0",
";",
"if",
"(",
"(",
"points",
"==",
"NULL",
")",
"||",
"(",
"totpoints",
"<=",
"0",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"dflag",
"&",
"(",
"GP_DRAWDATA_ONLY3D",
"|",
"GP_DRAWDATA_ONLYV2D",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"sflag",
"&",
"GP_STROKE_ERASER",
")",
"{",
"return",
";",
"}",
"GPUVertFormat",
"*",
"format",
"=",
"immVertexFormat",
"(",
")",
";",
"uint",
"pos",
"=",
"GPU_vertformat_attr_add",
"(",
"format",
",",
"\"",
"\"",
",",
"GPU_COMP_F32",
",",
"2",
",",
"GPU_FETCH_FLOAT",
")",
";",
"const",
"tGPspoint",
"*",
"pt",
"=",
"points",
";",
"if",
"(",
"totpoints",
"==",
"1",
")",
"{",
"GPU_point_size",
"(",
"(",
"float",
")",
"(",
"thickness",
"+",
"2",
")",
"*",
"points",
"->",
"pressure",
")",
";",
"immBindBuiltinProgram",
"(",
"GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA",
")",
";",
"immUniformColor3fvAlpha",
"(",
"ink",
",",
"ink",
"[",
"3",
"]",
")",
";",
"immBegin",
"(",
"GPU_PRIM_POINTS",
",",
"1",
")",
";",
"immVertex2fv",
"(",
"pos",
",",
"&",
"pt",
"->",
"x",
")",
";",
"}",
"else",
"{",
"float",
"oldpressure",
"=",
"points",
"[",
"0",
"]",
".",
"pressure",
";",
"GPU_line_width",
"(",
"max_ff",
"(",
"oldpressure",
"*",
"thickness",
",",
"1.0",
")",
")",
";",
"immBindBuiltinProgram",
"(",
"GPU_SHADER_2D_UNIFORM_COLOR",
")",
";",
"immUniformColor3fvAlpha",
"(",
"ink",
",",
"ink",
"[",
"3",
"]",
")",
";",
"immBeginAtMost",
"(",
"GPU_PRIM_LINE_STRIP",
",",
"totpoints",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"totpoints",
";",
"i",
"++",
",",
"pt",
"++",
")",
"{",
"if",
"(",
"fabsf",
"(",
"pt",
"->",
"pressure",
"-",
"oldpressure",
")",
">",
"0.2f",
")",
"{",
"if",
"(",
"draw_points",
"<",
"2",
")",
"{",
"immVertex2fv",
"(",
"pos",
",",
"&",
"(",
"pt",
"-",
"1",
")",
"->",
"x",
")",
";",
"}",
"immEnd",
"(",
")",
";",
"draw_points",
"=",
"0",
";",
"GPU_line_width",
"(",
"max_ff",
"(",
"pt",
"->",
"pressure",
"*",
"thickness",
",",
"1.0f",
")",
")",
";",
"immBeginAtMost",
"(",
"GPU_PRIM_LINE_STRIP",
",",
"totpoints",
"-",
"i",
"+",
"1",
")",
";",
"if",
"(",
"i",
"!=",
"0",
")",
"{",
"immVertex2fv",
"(",
"pos",
",",
"&",
"(",
"pt",
"-",
"1",
")",
"->",
"x",
")",
";",
"draw_points",
"++",
";",
"}",
"oldpressure",
"=",
"pt",
"->",
"pressure",
";",
"}",
"immVertex2fv",
"(",
"pos",
",",
"&",
"pt",
"->",
"x",
")",
";",
"draw_points",
"++",
";",
"}",
"if",
"(",
"draw_points",
"<",
"2",
")",
"{",
"immVertex2fv",
"(",
"pos",
",",
"&",
"(",
"pt",
"-",
"1",
")",
"->",
"x",
")",
";",
"}",
"}",
"immEnd",
"(",
")",
";",
"immUnbindProgram",
"(",
")",
";",
"}"
] | draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) | [
"draw",
"stroke",
"defined",
"in",
"buffer",
"(",
"simple",
"ogl",
"lines",
"/",
"points",
"for",
"now",
"as",
"dotted",
"lines",
")"
] | [
"/* error checking */",
"/* check if buffer can be drawn */",
"/* don't draw stroke at all! */",
"/* if drawing a single point, draw it larger */",
"/* draw stroke curve */",
"/* If there was a significant pressure change,\n * stop the curve, change the thickness of the stroke,\n * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP).\n */",
"/* need to have 2 points to avoid immEnd assert error */",
"/* need to roll-back one point to ensure that there are no gaps in the stroke */",
"/* reset our threshold */",
"/* now the point we want */",
"/* need to have 2 points to avoid immEnd assert error */"
] | [
{
"param": "points",
"type": "tGPspoint"
},
{
"param": "totpoints",
"type": "int"
},
{
"param": "thickness",
"type": "short"
},
{
"param": "dflag",
"type": "short"
},
{
"param": "sflag",
"type": "short"
},
{
"param": "ink",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "points",
"type": "tGPspoint",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "totpoints",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "thickness",
"type": "short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dflag",
"type": "short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sflag",
"type": "short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ink",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | annotation_calc_2d_stroke_fxy | void | static void annotation_calc_2d_stroke_fxy(
const float pt[3], short sflag, int offsx, int offsy, int winx, int winy, float r_co[2])
{
if (sflag & GP_STROKE_2DSPACE) {
r_co[0] = pt[0];
r_co[1] = pt[1];
}
else if (sflag & GP_STROKE_2DIMAGE) {
const float x = (float)((pt[0] * winx) + offsx);
const float y = (float)((pt[1] * winy) + offsy);
r_co[0] = x;
r_co[1] = y;
}
else {
const float x = (float)(pt[0] / 100 * winx) + offsx;
const float y = (float)(pt[1] / 100 * winy) + offsy;
r_co[0] = x;
r_co[1] = y;
}
} | /* --------- 2D Stroke Drawing Helpers --------- */
/* change in parameter list */ | 2D Stroke Drawing Helpers
change in parameter list | [
"2D",
"Stroke",
"Drawing",
"Helpers",
"change",
"in",
"parameter",
"list"
] | static void annotation_calc_2d_stroke_fxy(
const float pt[3], short sflag, int offsx, int offsy, int winx, int winy, float r_co[2])
{
if (sflag & GP_STROKE_2DSPACE) {
r_co[0] = pt[0];
r_co[1] = pt[1];
}
else if (sflag & GP_STROKE_2DIMAGE) {
const float x = (float)((pt[0] * winx) + offsx);
const float y = (float)((pt[1] * winy) + offsy);
r_co[0] = x;
r_co[1] = y;
}
else {
const float x = (float)(pt[0] / 100 * winx) + offsx;
const float y = (float)(pt[1] / 100 * winy) + offsy;
r_co[0] = x;
r_co[1] = y;
}
} | [
"static",
"void",
"annotation_calc_2d_stroke_fxy",
"(",
"const",
"float",
"pt",
"[",
"3",
"]",
",",
"short",
"sflag",
",",
"int",
"offsx",
",",
"int",
"offsy",
",",
"int",
"winx",
",",
"int",
"winy",
",",
"float",
"r_co",
"[",
"2",
"]",
")",
"{",
"if",
"(",
"sflag",
"&",
"GP_STROKE_2DSPACE",
")",
"{",
"r_co",
"[",
"0",
"]",
"=",
"pt",
"[",
"0",
"]",
";",
"r_co",
"[",
"1",
"]",
"=",
"pt",
"[",
"1",
"]",
";",
"}",
"else",
"if",
"(",
"sflag",
"&",
"GP_STROKE_2DIMAGE",
")",
"{",
"const",
"float",
"x",
"=",
"(",
"float",
")",
"(",
"(",
"pt",
"[",
"0",
"]",
"*",
"winx",
")",
"+",
"offsx",
")",
";",
"const",
"float",
"y",
"=",
"(",
"float",
")",
"(",
"(",
"pt",
"[",
"1",
"]",
"*",
"winy",
")",
"+",
"offsy",
")",
";",
"r_co",
"[",
"0",
"]",
"=",
"x",
";",
"r_co",
"[",
"1",
"]",
"=",
"y",
";",
"}",
"else",
"{",
"const",
"float",
"x",
"=",
"(",
"float",
")",
"(",
"pt",
"[",
"0",
"]",
"/",
"100",
"*",
"winx",
")",
"+",
"offsx",
";",
"const",
"float",
"y",
"=",
"(",
"float",
")",
"(",
"pt",
"[",
"1",
"]",
"/",
"100",
"*",
"winy",
")",
"+",
"offsy",
";",
"r_co",
"[",
"0",
"]",
"=",
"x",
";",
"r_co",
"[",
"1",
"]",
"=",
"y",
";",
"}",
"}"
] | 2D Stroke Drawing Helpers
change in parameter list | [
"2D",
"Stroke",
"Drawing",
"Helpers",
"change",
"in",
"parameter",
"list"
] | [] | [
{
"param": "pt",
"type": "float"
},
{
"param": "sflag",
"type": "short"
},
{
"param": "offsx",
"type": "int"
},
{
"param": "offsy",
"type": "int"
},
{
"param": "winx",
"type": "int"
},
{
"param": "winy",
"type": "int"
},
{
"param": "r_co",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pt",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sflag",
"type": "short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offsx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offsy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "winx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "winy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r_co",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | annotation_draw_stroke_point | void | static void annotation_draw_stroke_point(const bGPDspoint *points,
short thickness,
short UNUSED(dflag),
short sflag,
int offsx,
int offsy,
int winx,
int winy,
const float ink[4])
{
const bGPDspoint *pt = points;
/* get final position using parent matrix */
float fpt[3];
copy_v3_v3(fpt, &pt->x);
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
if (sflag & GP_STROKE_3DSPACE) {
immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
}
else {
immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
/* get 2D coordinates of point */
float co[3] = {0.0f};
annotation_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co);
copy_v3_v3(fpt, co);
}
/* set color */
immUniformColor3fvAlpha(ink, ink[3]);
/* set point thickness (since there's only one of these) */
immUniform1f("size", (float)(thickness + 2) * pt->pressure);
immBegin(GPU_PRIM_POINTS, 1);
immVertex3fv(pos, fpt);
immEnd();
immUnbindProgram();
} | /* draw a given stroke - just a single dot (only one point) */ | draw a given stroke - just a single dot (only one point) | [
"draw",
"a",
"given",
"stroke",
"-",
"just",
"a",
"single",
"dot",
"(",
"only",
"one",
"point",
")"
] | static void annotation_draw_stroke_point(const bGPDspoint *points,
short thickness,
short UNUSED(dflag),
short sflag,
int offsx,
int offsy,
int winx,
int winy,
const float ink[4])
{
const bGPDspoint *pt = points;
float fpt[3];
copy_v3_v3(fpt, &pt->x);
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
if (sflag & GP_STROKE_3DSPACE) {
immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
}
else {
immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
float co[3] = {0.0f};
annotation_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co);
copy_v3_v3(fpt, co);
}
immUniformColor3fvAlpha(ink, ink[3]);
immUniform1f("size", (float)(thickness + 2) * pt->pressure);
immBegin(GPU_PRIM_POINTS, 1);
immVertex3fv(pos, fpt);
immEnd();
immUnbindProgram();
} | [
"static",
"void",
"annotation_draw_stroke_point",
"(",
"const",
"bGPDspoint",
"*",
"points",
",",
"short",
"thickness",
",",
"short",
"UNUSED",
"(",
"dflag",
")",
",",
"short",
"sflag",
",",
"int",
"offsx",
",",
"int",
"offsy",
",",
"int",
"winx",
",",
"int",
"winy",
",",
"const",
"float",
"ink",
"[",
"4",
"]",
")",
"{",
"const",
"bGPDspoint",
"*",
"pt",
"=",
"points",
";",
"float",
"fpt",
"[",
"3",
"]",
";",
"copy_v3_v3",
"(",
"fpt",
",",
"&",
"pt",
"->",
"x",
")",
";",
"GPUVertFormat",
"*",
"format",
"=",
"immVertexFormat",
"(",
")",
";",
"uint",
"pos",
"=",
"GPU_vertformat_attr_add",
"(",
"format",
",",
"\"",
"\"",
",",
"GPU_COMP_F32",
",",
"3",
",",
"GPU_FETCH_FLOAT",
")",
";",
"if",
"(",
"sflag",
"&",
"GP_STROKE_3DSPACE",
")",
"{",
"immBindBuiltinProgram",
"(",
"GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA",
")",
";",
"}",
"else",
"{",
"immBindBuiltinProgram",
"(",
"GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA",
")",
";",
"float",
"co",
"[",
"3",
"]",
"=",
"{",
"0.0f",
"}",
";",
"annotation_calc_2d_stroke_fxy",
"(",
"fpt",
",",
"sflag",
",",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
",",
"co",
")",
";",
"copy_v3_v3",
"(",
"fpt",
",",
"co",
")",
";",
"}",
"immUniformColor3fvAlpha",
"(",
"ink",
",",
"ink",
"[",
"3",
"]",
")",
";",
"immUniform1f",
"(",
"\"",
"\"",
",",
"(",
"float",
")",
"(",
"thickness",
"+",
"2",
")",
"*",
"pt",
"->",
"pressure",
")",
";",
"immBegin",
"(",
"GPU_PRIM_POINTS",
",",
"1",
")",
";",
"immVertex3fv",
"(",
"pos",
",",
"fpt",
")",
";",
"immEnd",
"(",
")",
";",
"immUnbindProgram",
"(",
")",
";",
"}"
] | draw a given stroke - just a single dot (only one point) | [
"draw",
"a",
"given",
"stroke",
"-",
"just",
"a",
"single",
"dot",
"(",
"only",
"one",
"point",
")"
] | [
"/* get final position using parent matrix */",
"/* get 2D coordinates of point */",
"/* set color */",
"/* set point thickness (since there's only one of these) */"
] | [
{
"param": "points",
"type": "bGPDspoint"
},
{
"param": "thickness",
"type": "short"
},
{
"param": "UNUSED",
"type": "short"
},
{
"param": "sflag",
"type": "short"
},
{
"param": "offsx",
"type": "int"
},
{
"param": "offsy",
"type": "int"
},
{
"param": "winx",
"type": "int"
},
{
"param": "winy",
"type": "int"
},
{
"param": "ink",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "points",
"type": "bGPDspoint",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "thickness",
"type": "short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "UNUSED",
"type": "short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sflag",
"type": "short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offsx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offsy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "winx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "winy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ink",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | annotation_draw_stroke_3d | void | static void annotation_draw_stroke_3d(const bGPDspoint *points,
int totpoints,
short thickness,
short UNUSED(sflag),
const float ink[4],
bool cyclic)
{
float curpressure = points[0].pressure;
float cyclic_fpt[3];
int draw_points = 0;
/* if cyclic needs one vertex more */
int cyclic_add = 0;
if (cyclic) {
cyclic_add++;
}
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor3fvAlpha(ink, ink[3]);
/* draw stroke curve */
GPU_line_width(max_ff(curpressure * thickness, 1.0f));
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints + cyclic_add);
const bGPDspoint *pt = points;
for (int i = 0; i < totpoints; i++, pt++) {
/* If there was a significant pressure change, stop the curve,
* change the thickness of the stroke, and continue drawing again
* (since line-width cannot change in middle of GL_LINE_STRIP)
* Note: we want more visible levels of pressures when thickness is bigger.
*/
if (fabsf(pt->pressure - curpressure) > 0.2f / (float)thickness) {
/* if the pressure changes before get at least 2 vertices,
* need to repeat last point to avoid assert in immEnd() */
if (draw_points < 2) {
const bGPDspoint *pt2 = pt - 1;
immVertex3fv(pos, &pt2->x);
}
immEnd();
draw_points = 0;
curpressure = pt->pressure;
GPU_line_width(max_ff(curpressure * thickness, 1.0f));
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
if (i != 0) {
const bGPDspoint *pt2 = pt - 1;
immVertex3fv(pos, &pt2->x);
draw_points++;
}
}
/* now the point we want */
immVertex3fv(pos, &pt->x);
draw_points++;
if (cyclic && i == 0) {
/* save first point to use in cyclic */
copy_v3_v3(cyclic_fpt, &pt->x);
}
}
if (cyclic) {
/* draw line to first point to complete the cycle */
immVertex3fv(pos, cyclic_fpt);
draw_points++;
}
/* if less of two points, need to repeat last point to avoid assert in immEnd() */
if (draw_points < 2) {
const bGPDspoint *pt2 = pt - 1;
immVertex3fv(pos, &pt2->x);
}
immEnd();
immUnbindProgram();
} | /* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */ | draw a given stroke in 3d , using simple ogl lines | [
"draw",
"a",
"given",
"stroke",
"in",
"3d",
"using",
"simple",
"ogl",
"lines"
] | static void annotation_draw_stroke_3d(const bGPDspoint *points,
int totpoints,
short thickness,
short UNUSED(sflag),
const float ink[4],
bool cyclic)
{
float curpressure = points[0].pressure;
float cyclic_fpt[3];
int draw_points = 0;
int cyclic_add = 0;
if (cyclic) {
cyclic_add++;
}
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor3fvAlpha(ink, ink[3]);
GPU_line_width(max_ff(curpressure * thickness, 1.0f));
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints + cyclic_add);
const bGPDspoint *pt = points;
for (int i = 0; i < totpoints; i++, pt++) {
if (fabsf(pt->pressure - curpressure) > 0.2f / (float)thickness) {
if (draw_points < 2) {
const bGPDspoint *pt2 = pt - 1;
immVertex3fv(pos, &pt2->x);
}
immEnd();
draw_points = 0;
curpressure = pt->pressure;
GPU_line_width(max_ff(curpressure * thickness, 1.0f));
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add);
if (i != 0) {
const bGPDspoint *pt2 = pt - 1;
immVertex3fv(pos, &pt2->x);
draw_points++;
}
}
immVertex3fv(pos, &pt->x);
draw_points++;
if (cyclic && i == 0) {
copy_v3_v3(cyclic_fpt, &pt->x);
}
}
if (cyclic) {
immVertex3fv(pos, cyclic_fpt);
draw_points++;
}
if (draw_points < 2) {
const bGPDspoint *pt2 = pt - 1;
immVertex3fv(pos, &pt2->x);
}
immEnd();
immUnbindProgram();
} | [
"static",
"void",
"annotation_draw_stroke_3d",
"(",
"const",
"bGPDspoint",
"*",
"points",
",",
"int",
"totpoints",
",",
"short",
"thickness",
",",
"short",
"UNUSED",
"(",
"sflag",
")",
",",
"const",
"float",
"ink",
"[",
"4",
"]",
",",
"bool",
"cyclic",
")",
"{",
"float",
"curpressure",
"=",
"points",
"[",
"0",
"]",
".",
"pressure",
";",
"float",
"cyclic_fpt",
"[",
"3",
"]",
";",
"int",
"draw_points",
"=",
"0",
";",
"int",
"cyclic_add",
"=",
"0",
";",
"if",
"(",
"cyclic",
")",
"{",
"cyclic_add",
"++",
";",
"}",
"GPUVertFormat",
"*",
"format",
"=",
"immVertexFormat",
"(",
")",
";",
"uint",
"pos",
"=",
"GPU_vertformat_attr_add",
"(",
"format",
",",
"\"",
"\"",
",",
"GPU_COMP_F32",
",",
"3",
",",
"GPU_FETCH_FLOAT",
")",
";",
"immBindBuiltinProgram",
"(",
"GPU_SHADER_3D_UNIFORM_COLOR",
")",
";",
"immUniformColor3fvAlpha",
"(",
"ink",
",",
"ink",
"[",
"3",
"]",
")",
";",
"GPU_line_width",
"(",
"max_ff",
"(",
"curpressure",
"*",
"thickness",
",",
"1.0f",
")",
")",
";",
"immBeginAtMost",
"(",
"GPU_PRIM_LINE_STRIP",
",",
"totpoints",
"+",
"cyclic_add",
")",
";",
"const",
"bGPDspoint",
"*",
"pt",
"=",
"points",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"totpoints",
";",
"i",
"++",
",",
"pt",
"++",
")",
"{",
"if",
"(",
"fabsf",
"(",
"pt",
"->",
"pressure",
"-",
"curpressure",
")",
">",
"0.2f",
"/",
"(",
"float",
")",
"thickness",
")",
"{",
"if",
"(",
"draw_points",
"<",
"2",
")",
"{",
"const",
"bGPDspoint",
"*",
"pt2",
"=",
"pt",
"-",
"1",
";",
"immVertex3fv",
"(",
"pos",
",",
"&",
"pt2",
"->",
"x",
")",
";",
"}",
"immEnd",
"(",
")",
";",
"draw_points",
"=",
"0",
";",
"curpressure",
"=",
"pt",
"->",
"pressure",
";",
"GPU_line_width",
"(",
"max_ff",
"(",
"curpressure",
"*",
"thickness",
",",
"1.0f",
")",
")",
";",
"immBeginAtMost",
"(",
"GPU_PRIM_LINE_STRIP",
",",
"totpoints",
"-",
"i",
"+",
"1",
"+",
"cyclic_add",
")",
";",
"if",
"(",
"i",
"!=",
"0",
")",
"{",
"const",
"bGPDspoint",
"*",
"pt2",
"=",
"pt",
"-",
"1",
";",
"immVertex3fv",
"(",
"pos",
",",
"&",
"pt2",
"->",
"x",
")",
";",
"draw_points",
"++",
";",
"}",
"}",
"immVertex3fv",
"(",
"pos",
",",
"&",
"pt",
"->",
"x",
")",
";",
"draw_points",
"++",
";",
"if",
"(",
"cyclic",
"&&",
"i",
"==",
"0",
")",
"{",
"copy_v3_v3",
"(",
"cyclic_fpt",
",",
"&",
"pt",
"->",
"x",
")",
";",
"}",
"}",
"if",
"(",
"cyclic",
")",
"{",
"immVertex3fv",
"(",
"pos",
",",
"cyclic_fpt",
")",
";",
"draw_points",
"++",
";",
"}",
"if",
"(",
"draw_points",
"<",
"2",
")",
"{",
"const",
"bGPDspoint",
"*",
"pt2",
"=",
"pt",
"-",
"1",
";",
"immVertex3fv",
"(",
"pos",
",",
"&",
"pt2",
"->",
"x",
")",
";",
"}",
"immEnd",
"(",
")",
";",
"immUnbindProgram",
"(",
")",
";",
"}"
] | draw a given stroke in 3d (i.e. | [
"draw",
"a",
"given",
"stroke",
"in",
"3d",
"(",
"i",
".",
"e",
"."
] | [
"/* if cyclic needs one vertex more */",
"/* draw stroke curve */",
"/* If there was a significant pressure change, stop the curve,\n * change the thickness of the stroke, and continue drawing again\n * (since line-width cannot change in middle of GL_LINE_STRIP)\n * Note: we want more visible levels of pressures when thickness is bigger.\n */",
"/* if the pressure changes before get at least 2 vertices,\n * need to repeat last point to avoid assert in immEnd() */",
"/* need to roll-back one point to ensure that there are no gaps in the stroke */",
"/* now the point we want */",
"/* save first point to use in cyclic */",
"/* draw line to first point to complete the cycle */",
"/* if less of two points, need to repeat last point to avoid assert in immEnd() */"
] | [
{
"param": "points",
"type": "bGPDspoint"
},
{
"param": "totpoints",
"type": "int"
},
{
"param": "thickness",
"type": "short"
},
{
"param": "UNUSED",
"type": "short"
},
{
"param": "ink",
"type": "float"
},
{
"param": "cyclic",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "points",
"type": "bGPDspoint",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "totpoints",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "thickness",
"type": "short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "UNUSED",
"type": "short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ink",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cyclic",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | annotation_can_draw_stroke | bool | static bool annotation_can_draw_stroke(const bGPDstroke *gps, const int dflag)
{
/* skip stroke if it isn't in the right display space for this drawing context */
/* 1) 3D Strokes */
if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE)) {
return false;
}
if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE)) {
return false;
}
/* 2) Screen Space 2D Strokes */
if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE)) {
return false;
}
if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE)) {
return false;
}
/* 3) Image Space (2D) */
if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE)) {
return false;
}
if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE)) {
return false;
}
/* skip stroke if it doesn't have any valid data */
if ((gps->points == NULL) || (gps->totpoints < 1)) {
return false;
}
/* stroke can be drawn */
return true;
} | /* Helper for doing all the checks on whether a stroke can be drawn */ | Helper for doing all the checks on whether a stroke can be drawn | [
"Helper",
"for",
"doing",
"all",
"the",
"checks",
"on",
"whether",
"a",
"stroke",
"can",
"be",
"drawn"
] | static bool annotation_can_draw_stroke(const bGPDstroke *gps, const int dflag)
{
if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE)) {
return false;
}
if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE)) {
return false;
}
if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE)) {
return false;
}
if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE)) {
return false;
}
if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE)) {
return false;
}
if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE)) {
return false;
}
if ((gps->points == NULL) || (gps->totpoints < 1)) {
return false;
}
return true;
} | [
"static",
"bool",
"annotation_can_draw_stroke",
"(",
"const",
"bGPDstroke",
"*",
"gps",
",",
"const",
"int",
"dflag",
")",
"{",
"if",
"(",
"(",
"dflag",
"&",
"GP_DRAWDATA_ONLY3D",
")",
"&&",
"!",
"(",
"gps",
"->",
"flag",
"&",
"GP_STROKE_3DSPACE",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"(",
"dflag",
"&",
"GP_DRAWDATA_ONLY3D",
")",
"&&",
"(",
"gps",
"->",
"flag",
"&",
"GP_STROKE_3DSPACE",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"dflag",
"&",
"GP_DRAWDATA_ONLYV2D",
")",
"&&",
"!",
"(",
"gps",
"->",
"flag",
"&",
"GP_STROKE_2DSPACE",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"(",
"dflag",
"&",
"GP_DRAWDATA_ONLYV2D",
")",
"&&",
"(",
"gps",
"->",
"flag",
"&",
"GP_STROKE_2DSPACE",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"dflag",
"&",
"GP_DRAWDATA_ONLYI2D",
")",
"&&",
"!",
"(",
"gps",
"->",
"flag",
"&",
"GP_STROKE_2DIMAGE",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"(",
"dflag",
"&",
"GP_DRAWDATA_ONLYI2D",
")",
"&&",
"(",
"gps",
"->",
"flag",
"&",
"GP_STROKE_2DIMAGE",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"gps",
"->",
"points",
"==",
"NULL",
")",
"||",
"(",
"gps",
"->",
"totpoints",
"<",
"1",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Helper for doing all the checks on whether a stroke can be drawn | [
"Helper",
"for",
"doing",
"all",
"the",
"checks",
"on",
"whether",
"a",
"stroke",
"can",
"be",
"drawn"
] | [
"/* skip stroke if it isn't in the right display space for this drawing context */",
"/* 1) 3D Strokes */",
"/* 2) Screen Space 2D Strokes */",
"/* 3) Image Space (2D) */",
"/* skip stroke if it doesn't have any valid data */",
"/* stroke can be drawn */"
] | [
{
"param": "gps",
"type": "bGPDstroke"
},
{
"param": "dflag",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gps",
"type": "bGPDstroke",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dflag",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | annotation_draw_strokes_edit | void | static void annotation_draw_strokes_edit(bGPdata *gpd,
bGPDlayer *gpl,
const bGPDframe *gpf,
int offsx,
int offsy,
int winx,
int winy,
short dflag,
short UNUSED(lflag),
float alpha)
{
/* if alpha 0 do not draw */
if (alpha == 0.0f) {
return;
}
const bool no_xray = (dflag & GP_DRAWDATA_NO_XRAY) != 0;
int mask_orig = 0;
/* set up depth masks... */
if (dflag & GP_DRAWDATA_ONLY3D) {
if (no_xray) {
glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
glDepthMask(0);
GPU_depth_test(true);
/* first arg is normally rv3d->dist, but this isn't
* available here and seems to work quite well without */
bglPolygonOffset(1.0f, 1.0f);
}
}
GPU_program_point_size(true);
/* draw stroke verts */
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* check if stroke can be drawn */
if (annotation_can_draw_stroke(gps, dflag) == false) {
continue;
}
/* Optimization: only draw points for selected strokes
* We assume that selected points can only occur in
* strokes that are selected too.
*/
if ((gps->flag & GP_STROKE_SELECT) == 0) {
continue;
}
/* Get size of verts:
* - The selected state needs to be larger than the unselected state so that
* they stand out more.
* - We use the theme setting for size of the unselected verts
*/
float bsize = UI_GetThemeValuef(TH_GP_VERTEX_SIZE);
float vsize;
if ((int)bsize > 8) {
vsize = 10.0f;
bsize = 8.0f;
}
else {
vsize = bsize + 2;
}
float selectColor[4];
UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, selectColor);
selectColor[3] = alpha;
GPUVertFormat *format = immVertexFormat();
uint pos; /* specified later */
uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
if (gps->flag & GP_STROKE_3DSPACE) {
pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
}
else {
pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR);
}
immBegin(GPU_PRIM_POINTS, gps->totpoints);
/* Draw start and end point differently if enabled stroke direction hint */
bool show_direction_hint = (gpd->flag & GP_DATA_SHOW_DIRECTION) && (gps->totpoints > 1);
/* Draw all the stroke points (selected or not) */
bGPDspoint *pt = gps->points;
for (int i = 0; i < gps->totpoints; i++, pt++) {
/* size and color first */
if (show_direction_hint && i == 0) {
/* start point in green bigger */
immAttr3f(color, 0.0f, 1.0f, 0.0f);
immAttr1f(size, vsize + 4);
}
else if (show_direction_hint && (i == gps->totpoints - 1)) {
/* end point in red smaller */
immAttr3f(color, 1.0f, 0.0f, 0.0f);
immAttr1f(size, vsize + 1);
}
else if (pt->flag & GP_SPOINT_SELECT) {
immAttr3fv(color, selectColor);
immAttr1f(size, vsize);
}
else {
immAttr3fv(color, gpl->color);
immAttr1f(size, bsize);
}
/* then position */
if (gps->flag & GP_STROKE_3DSPACE) {
immVertex3fv(pos, &pt->x);
}
else {
float co[2];
annotation_calc_2d_stroke_fxy(&pt->x, gps->flag, offsx, offsy, winx, winy, co);
immVertex2fv(pos, co);
}
}
immEnd();
immUnbindProgram();
}
GPU_program_point_size(false);
/* clear depth mask */
if (dflag & GP_DRAWDATA_ONLY3D) {
if (no_xray) {
glDepthMask(mask_orig);
GPU_depth_test(false);
bglPolygonOffset(0.0, 0.0);
#if 0
glDisable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset(0, 0);
#endif
}
}
} | /* Draw selected verts for strokes being edited */ | Draw selected verts for strokes being edited | [
"Draw",
"selected",
"verts",
"for",
"strokes",
"being",
"edited"
] | static void annotation_draw_strokes_edit(bGPdata *gpd,
bGPDlayer *gpl,
const bGPDframe *gpf,
int offsx,
int offsy,
int winx,
int winy,
short dflag,
short UNUSED(lflag),
float alpha)
{
if (alpha == 0.0f) {
return;
}
const bool no_xray = (dflag & GP_DRAWDATA_NO_XRAY) != 0;
int mask_orig = 0;
if (dflag & GP_DRAWDATA_ONLY3D) {
if (no_xray) {
glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
glDepthMask(0);
GPU_depth_test(true);
bglPolygonOffset(1.0f, 1.0f);
}
}
GPU_program_point_size(true);
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
if (annotation_can_draw_stroke(gps, dflag) == false) {
continue;
}
if ((gps->flag & GP_STROKE_SELECT) == 0) {
continue;
}
float bsize = UI_GetThemeValuef(TH_GP_VERTEX_SIZE);
float vsize;
if ((int)bsize > 8) {
vsize = 10.0f;
bsize = 8.0f;
}
else {
vsize = bsize + 2;
}
float selectColor[4];
UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, selectColor);
selectColor[3] = alpha;
GPUVertFormat *format = immVertexFormat();
uint pos;
uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
if (gps->flag & GP_STROKE_3DSPACE) {
pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
}
else {
pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR);
}
immBegin(GPU_PRIM_POINTS, gps->totpoints);
bool show_direction_hint = (gpd->flag & GP_DATA_SHOW_DIRECTION) && (gps->totpoints > 1);
bGPDspoint *pt = gps->points;
for (int i = 0; i < gps->totpoints; i++, pt++) {
if (show_direction_hint && i == 0) {
immAttr3f(color, 0.0f, 1.0f, 0.0f);
immAttr1f(size, vsize + 4);
}
else if (show_direction_hint && (i == gps->totpoints - 1)) {
immAttr3f(color, 1.0f, 0.0f, 0.0f);
immAttr1f(size, vsize + 1);
}
else if (pt->flag & GP_SPOINT_SELECT) {
immAttr3fv(color, selectColor);
immAttr1f(size, vsize);
}
else {
immAttr3fv(color, gpl->color);
immAttr1f(size, bsize);
}
if (gps->flag & GP_STROKE_3DSPACE) {
immVertex3fv(pos, &pt->x);
}
else {
float co[2];
annotation_calc_2d_stroke_fxy(&pt->x, gps->flag, offsx, offsy, winx, winy, co);
immVertex2fv(pos, co);
}
}
immEnd();
immUnbindProgram();
}
GPU_program_point_size(false);
if (dflag & GP_DRAWDATA_ONLY3D) {
if (no_xray) {
glDepthMask(mask_orig);
GPU_depth_test(false);
bglPolygonOffset(0.0, 0.0);
#if 0
glDisable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset(0, 0);
#endif
}
}
} | [
"static",
"void",
"annotation_draw_strokes_edit",
"(",
"bGPdata",
"*",
"gpd",
",",
"bGPDlayer",
"*",
"gpl",
",",
"const",
"bGPDframe",
"*",
"gpf",
",",
"int",
"offsx",
",",
"int",
"offsy",
",",
"int",
"winx",
",",
"int",
"winy",
",",
"short",
"dflag",
",",
"short",
"UNUSED",
"(",
"lflag",
")",
",",
"float",
"alpha",
")",
"{",
"if",
"(",
"alpha",
"==",
"0.0f",
")",
"{",
"return",
";",
"}",
"const",
"bool",
"no_xray",
"=",
"(",
"dflag",
"&",
"GP_DRAWDATA_NO_XRAY",
")",
"!=",
"0",
";",
"int",
"mask_orig",
"=",
"0",
";",
"if",
"(",
"dflag",
"&",
"GP_DRAWDATA_ONLY3D",
")",
"{",
"if",
"(",
"no_xray",
")",
"{",
"glGetIntegerv",
"(",
"GL_DEPTH_WRITEMASK",
",",
"&",
"mask_orig",
")",
";",
"glDepthMask",
"(",
"0",
")",
";",
"GPU_depth_test",
"(",
"true",
")",
";",
"bglPolygonOffset",
"(",
"1.0f",
",",
"1.0f",
")",
";",
"}",
"}",
"GPU_program_point_size",
"(",
"true",
")",
";",
"for",
"(",
"bGPDstroke",
"*",
"gps",
"=",
"gpf",
"->",
"strokes",
".",
"first",
";",
"gps",
";",
"gps",
"=",
"gps",
"->",
"next",
")",
"{",
"if",
"(",
"annotation_can_draw_stroke",
"(",
"gps",
",",
"dflag",
")",
"==",
"false",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"(",
"gps",
"->",
"flag",
"&",
"GP_STROKE_SELECT",
")",
"==",
"0",
")",
"{",
"continue",
";",
"}",
"float",
"bsize",
"=",
"UI_GetThemeValuef",
"(",
"TH_GP_VERTEX_SIZE",
")",
";",
"float",
"vsize",
";",
"if",
"(",
"(",
"int",
")",
"bsize",
">",
"8",
")",
"{",
"vsize",
"=",
"10.0f",
";",
"bsize",
"=",
"8.0f",
";",
"}",
"else",
"{",
"vsize",
"=",
"bsize",
"+",
"2",
";",
"}",
"float",
"selectColor",
"[",
"4",
"]",
";",
"UI_GetThemeColor3fv",
"(",
"TH_GP_VERTEX_SELECT",
",",
"selectColor",
")",
";",
"selectColor",
"[",
"3",
"]",
"=",
"alpha",
";",
"GPUVertFormat",
"*",
"format",
"=",
"immVertexFormat",
"(",
")",
";",
"uint",
"pos",
";",
"uint",
"size",
"=",
"GPU_vertformat_attr_add",
"(",
"format",
",",
"\"",
"\"",
",",
"GPU_COMP_F32",
",",
"1",
",",
"GPU_FETCH_FLOAT",
")",
";",
"uint",
"color",
"=",
"GPU_vertformat_attr_add",
"(",
"format",
",",
"\"",
"\"",
",",
"GPU_COMP_F32",
",",
"3",
",",
"GPU_FETCH_FLOAT",
")",
";",
"if",
"(",
"gps",
"->",
"flag",
"&",
"GP_STROKE_3DSPACE",
")",
"{",
"pos",
"=",
"GPU_vertformat_attr_add",
"(",
"format",
",",
"\"",
"\"",
",",
"GPU_COMP_F32",
",",
"3",
",",
"GPU_FETCH_FLOAT",
")",
";",
"immBindBuiltinProgram",
"(",
"GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR",
")",
";",
"}",
"else",
"{",
"pos",
"=",
"GPU_vertformat_attr_add",
"(",
"format",
",",
"\"",
"\"",
",",
"GPU_COMP_F32",
",",
"2",
",",
"GPU_FETCH_FLOAT",
")",
";",
"immBindBuiltinProgram",
"(",
"GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR",
")",
";",
"}",
"immBegin",
"(",
"GPU_PRIM_POINTS",
",",
"gps",
"->",
"totpoints",
")",
";",
"bool",
"show_direction_hint",
"=",
"(",
"gpd",
"->",
"flag",
"&",
"GP_DATA_SHOW_DIRECTION",
")",
"&&",
"(",
"gps",
"->",
"totpoints",
">",
"1",
")",
";",
"bGPDspoint",
"*",
"pt",
"=",
"gps",
"->",
"points",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"gps",
"->",
"totpoints",
";",
"i",
"++",
",",
"pt",
"++",
")",
"{",
"if",
"(",
"show_direction_hint",
"&&",
"i",
"==",
"0",
")",
"{",
"immAttr3f",
"(",
"color",
",",
"0.0f",
",",
"1.0f",
",",
"0.0f",
")",
";",
"immAttr1f",
"(",
"size",
",",
"vsize",
"+",
"4",
")",
";",
"}",
"else",
"if",
"(",
"show_direction_hint",
"&&",
"(",
"i",
"==",
"gps",
"->",
"totpoints",
"-",
"1",
")",
")",
"{",
"immAttr3f",
"(",
"color",
",",
"1.0f",
",",
"0.0f",
",",
"0.0f",
")",
";",
"immAttr1f",
"(",
"size",
",",
"vsize",
"+",
"1",
")",
";",
"}",
"else",
"if",
"(",
"pt",
"->",
"flag",
"&",
"GP_SPOINT_SELECT",
")",
"{",
"immAttr3fv",
"(",
"color",
",",
"selectColor",
")",
";",
"immAttr1f",
"(",
"size",
",",
"vsize",
")",
";",
"}",
"else",
"{",
"immAttr3fv",
"(",
"color",
",",
"gpl",
"->",
"color",
")",
";",
"immAttr1f",
"(",
"size",
",",
"bsize",
")",
";",
"}",
"if",
"(",
"gps",
"->",
"flag",
"&",
"GP_STROKE_3DSPACE",
")",
"{",
"immVertex3fv",
"(",
"pos",
",",
"&",
"pt",
"->",
"x",
")",
";",
"}",
"else",
"{",
"float",
"co",
"[",
"2",
"]",
";",
"annotation_calc_2d_stroke_fxy",
"(",
"&",
"pt",
"->",
"x",
",",
"gps",
"->",
"flag",
",",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
",",
"co",
")",
";",
"immVertex2fv",
"(",
"pos",
",",
"co",
")",
";",
"}",
"}",
"immEnd",
"(",
")",
";",
"immUnbindProgram",
"(",
")",
";",
"}",
"GPU_program_point_size",
"(",
"false",
")",
";",
"if",
"(",
"dflag",
"&",
"GP_DRAWDATA_ONLY3D",
")",
"{",
"if",
"(",
"no_xray",
")",
"{",
"glDepthMask",
"(",
"mask_orig",
")",
";",
"GPU_depth_test",
"(",
"false",
")",
";",
"bglPolygonOffset",
"(",
"0.0",
",",
"0.0",
")",
";",
"#if",
"0",
"\n",
"glDisable",
"(",
"GL_POLYGON_OFFSET_LINE",
")",
";",
"glPolygonOffset",
"(",
"0",
",",
"0",
")",
";",
"#endif",
"}",
"}",
"}"
] | Draw selected verts for strokes being edited | [
"Draw",
"selected",
"verts",
"for",
"strokes",
"being",
"edited"
] | [
"/* if alpha 0 do not draw */",
"/* set up depth masks... */",
"/* first arg is normally rv3d->dist, but this isn't\n * available here and seems to work quite well without */",
"/* draw stroke verts */",
"/* check if stroke can be drawn */",
"/* Optimization: only draw points for selected strokes\n * We assume that selected points can only occur in\n * strokes that are selected too.\n */",
"/* Get size of verts:\n * - The selected state needs to be larger than the unselected state so that\n * they stand out more.\n * - We use the theme setting for size of the unselected verts\n */",
"/* specified later */",
"/* Draw start and end point differently if enabled stroke direction hint */",
"/* Draw all the stroke points (selected or not) */",
"/* size and color first */",
"/* start point in green bigger */",
"/* end point in red smaller */",
"/* then position */",
"/* clear depth mask */"
] | [
{
"param": "gpd",
"type": "bGPdata"
},
{
"param": "gpl",
"type": "bGPDlayer"
},
{
"param": "gpf",
"type": "bGPDframe"
},
{
"param": "offsx",
"type": "int"
},
{
"param": "offsy",
"type": "int"
},
{
"param": "winx",
"type": "int"
},
{
"param": "winy",
"type": "int"
},
{
"param": "dflag",
"type": "short"
},
{
"param": "UNUSED",
"type": "short"
},
{
"param": "alpha",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gpd",
"type": "bGPdata",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpl",
"type": "bGPDlayer",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpf",
"type": "bGPDframe",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offsx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offsy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "winx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "winy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dflag",
"type": "short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "UNUSED",
"type": "short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "alpha",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | annotation_draw_onionskins | void | static void annotation_draw_onionskins(bGPdata *gpd,
bGPDlayer *gpl,
bGPDframe *gpf,
int offsx,
int offsy,
int winx,
int winy,
int UNUSED(cfra),
int dflag)
{
const float alpha = 1.0f;
float color[4];
/* 1) Draw Previous Frames First */
copy_v3_v3(color, gpl->gcolor_prev);
if (gpl->gstep > 0) {
bGPDframe *gf;
float fac;
/* draw previous frames first */
for (gf = gpf->prev; gf; gf = gf->prev) {
/* check if frame is drawable */
if ((gpf->framenum - gf->framenum) <= gpl->gstep) {
/* alpha decreases with distance from curframe index */
fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
color[3] = alpha * fac * 0.66f;
annotation_draw_strokes(
gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
else {
break;
}
}
}
else if (gpl->gstep == 0) {
/* draw the strokes for the ghost frames (at half of the alpha set by user) */
if (gpf->prev) {
color[3] = (alpha / 7);
annotation_draw_strokes(
gpd, gpl, gpf->prev, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
}
else {
/* don't draw - disabled */
}
/* 2) Now draw next frames */
copy_v3_v3(color, gpl->gcolor_next);
if (gpl->gstep_next > 0) {
bGPDframe *gf;
float fac;
/* now draw next frames */
for (gf = gpf->next; gf; gf = gf->next) {
/* check if frame is drawable */
if ((gf->framenum - gpf->framenum) <= gpl->gstep_next) {
/* alpha decreases with distance from curframe index */
fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1));
color[3] = alpha * fac * 0.66f;
annotation_draw_strokes(
gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
else {
break;
}
}
}
else if (gpl->gstep_next == 0) {
/* draw the strokes for the ghost frames (at half of the alpha set by user) */
if (gpf->next) {
color[3] = (alpha / 4);
annotation_draw_strokes(
gpd, gpl, gpf->next, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
}
else {
/* don't draw - disabled */
}
} | /* ----- General Drawing ------ */
/* draw onion-skinning for a layer */ | General Drawing
draw onion-skinning for a layer | [
"General",
"Drawing",
"draw",
"onion",
"-",
"skinning",
"for",
"a",
"layer"
] | static void annotation_draw_onionskins(bGPdata *gpd,
bGPDlayer *gpl,
bGPDframe *gpf,
int offsx,
int offsy,
int winx,
int winy,
int UNUSED(cfra),
int dflag)
{
const float alpha = 1.0f;
float color[4];
copy_v3_v3(color, gpl->gcolor_prev);
if (gpl->gstep > 0) {
bGPDframe *gf;
float fac;
for (gf = gpf->prev; gf; gf = gf->prev) {
if ((gpf->framenum - gf->framenum) <= gpl->gstep) {
fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
color[3] = alpha * fac * 0.66f;
annotation_draw_strokes(
gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
else {
break;
}
}
}
else if (gpl->gstep == 0) {
if (gpf->prev) {
color[3] = (alpha / 7);
annotation_draw_strokes(
gpd, gpl, gpf->prev, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
}
else {
}
copy_v3_v3(color, gpl->gcolor_next);
if (gpl->gstep_next > 0) {
bGPDframe *gf;
float fac;
for (gf = gpf->next; gf; gf = gf->next) {
if ((gf->framenum - gpf->framenum) <= gpl->gstep_next) {
fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1));
color[3] = alpha * fac * 0.66f;
annotation_draw_strokes(
gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
else {
break;
}
}
}
else if (gpl->gstep_next == 0) {
if (gpf->next) {
color[3] = (alpha / 4);
annotation_draw_strokes(
gpd, gpl, gpf->next, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
}
else {
}
} | [
"static",
"void",
"annotation_draw_onionskins",
"(",
"bGPdata",
"*",
"gpd",
",",
"bGPDlayer",
"*",
"gpl",
",",
"bGPDframe",
"*",
"gpf",
",",
"int",
"offsx",
",",
"int",
"offsy",
",",
"int",
"winx",
",",
"int",
"winy",
",",
"int",
"UNUSED",
"(",
"cfra",
")",
",",
"int",
"dflag",
")",
"{",
"const",
"float",
"alpha",
"=",
"1.0f",
";",
"float",
"color",
"[",
"4",
"]",
";",
"copy_v3_v3",
"(",
"color",
",",
"gpl",
"->",
"gcolor_prev",
")",
";",
"if",
"(",
"gpl",
"->",
"gstep",
">",
"0",
")",
"{",
"bGPDframe",
"*",
"gf",
";",
"float",
"fac",
";",
"for",
"(",
"gf",
"=",
"gpf",
"->",
"prev",
";",
"gf",
";",
"gf",
"=",
"gf",
"->",
"prev",
")",
"{",
"if",
"(",
"(",
"gpf",
"->",
"framenum",
"-",
"gf",
"->",
"framenum",
")",
"<=",
"gpl",
"->",
"gstep",
")",
"{",
"fac",
"=",
"1.0f",
"-",
"(",
"(",
"float",
")",
"(",
"gpf",
"->",
"framenum",
"-",
"gf",
"->",
"framenum",
")",
"/",
"(",
"float",
")",
"(",
"gpl",
"->",
"gstep",
"+",
"1",
")",
")",
";",
"color",
"[",
"3",
"]",
"=",
"alpha",
"*",
"fac",
"*",
"0.66f",
";",
"annotation_draw_strokes",
"(",
"gpd",
",",
"gpl",
",",
"gf",
",",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
",",
"dflag",
",",
"gpl",
"->",
"thickness",
",",
"color",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"gpl",
"->",
"gstep",
"==",
"0",
")",
"{",
"if",
"(",
"gpf",
"->",
"prev",
")",
"{",
"color",
"[",
"3",
"]",
"=",
"(",
"alpha",
"/",
"7",
")",
";",
"annotation_draw_strokes",
"(",
"gpd",
",",
"gpl",
",",
"gpf",
"->",
"prev",
",",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
",",
"dflag",
",",
"gpl",
"->",
"thickness",
",",
"color",
")",
";",
"}",
"}",
"else",
"{",
"}",
"copy_v3_v3",
"(",
"color",
",",
"gpl",
"->",
"gcolor_next",
")",
";",
"if",
"(",
"gpl",
"->",
"gstep_next",
">",
"0",
")",
"{",
"bGPDframe",
"*",
"gf",
";",
"float",
"fac",
";",
"for",
"(",
"gf",
"=",
"gpf",
"->",
"next",
";",
"gf",
";",
"gf",
"=",
"gf",
"->",
"next",
")",
"{",
"if",
"(",
"(",
"gf",
"->",
"framenum",
"-",
"gpf",
"->",
"framenum",
")",
"<=",
"gpl",
"->",
"gstep_next",
")",
"{",
"fac",
"=",
"1.0f",
"-",
"(",
"(",
"float",
")",
"(",
"gf",
"->",
"framenum",
"-",
"gpf",
"->",
"framenum",
")",
"/",
"(",
"float",
")",
"(",
"gpl",
"->",
"gstep_next",
"+",
"1",
")",
")",
";",
"color",
"[",
"3",
"]",
"=",
"alpha",
"*",
"fac",
"*",
"0.66f",
";",
"annotation_draw_strokes",
"(",
"gpd",
",",
"gpl",
",",
"gf",
",",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
",",
"dflag",
",",
"gpl",
"->",
"thickness",
",",
"color",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"gpl",
"->",
"gstep_next",
"==",
"0",
")",
"{",
"if",
"(",
"gpf",
"->",
"next",
")",
"{",
"color",
"[",
"3",
"]",
"=",
"(",
"alpha",
"/",
"4",
")",
";",
"annotation_draw_strokes",
"(",
"gpd",
",",
"gpl",
",",
"gpf",
"->",
"next",
",",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
",",
"dflag",
",",
"gpl",
"->",
"thickness",
",",
"color",
")",
";",
"}",
"}",
"else",
"{",
"}",
"}"
] | General Drawing
draw onion-skinning for a layer | [
"General",
"Drawing",
"draw",
"onion",
"-",
"skinning",
"for",
"a",
"layer"
] | [
"/* 1) Draw Previous Frames First */",
"/* draw previous frames first */",
"/* check if frame is drawable */",
"/* alpha decreases with distance from curframe index */",
"/* draw the strokes for the ghost frames (at half of the alpha set by user) */",
"/* don't draw - disabled */",
"/* 2) Now draw next frames */",
"/* now draw next frames */",
"/* check if frame is drawable */",
"/* alpha decreases with distance from curframe index */",
"/* draw the strokes for the ghost frames (at half of the alpha set by user) */",
"/* don't draw - disabled */"
] | [
{
"param": "gpd",
"type": "bGPdata"
},
{
"param": "gpl",
"type": "bGPDlayer"
},
{
"param": "gpf",
"type": "bGPDframe"
},
{
"param": "offsx",
"type": "int"
},
{
"param": "offsy",
"type": "int"
},
{
"param": "winx",
"type": "int"
},
{
"param": "winy",
"type": "int"
},
{
"param": "UNUSED",
"type": "int"
},
{
"param": "dflag",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gpd",
"type": "bGPdata",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpl",
"type": "bGPDlayer",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpf",
"type": "bGPDframe",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offsx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offsy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "winx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "winy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "UNUSED",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dflag",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | annotation_draw_data_layers | void | static void annotation_draw_data_layers(
bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag, float alpha)
{
float ink[4];
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* verify never thickness is less than 1 */
CLAMP_MIN(gpl->thickness, 1.0f);
short lthick = gpl->thickness;
/* apply layer opacity */
copy_v3_v3(ink, gpl->color);
ink[3] = gpl->opacity;
/* don't draw layer if hidden */
if (gpl->flag & GP_LAYER_HIDE) {
continue;
}
/* get frame to draw */
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra, GP_GETFRAME_USE_PREV);
if (gpf == NULL) {
continue;
}
/* set basic stroke thickness */
GPU_line_width(lthick);
/* Add layer drawing settings to the set of "draw flags"
* NOTE: If the setting doesn't apply, it *must* be cleared,
* as dflag's carry over from the previous layer
*/
/* xray... */
SET_FLAG_FROM_TEST(dflag, gpl->flag & GP_LAYER_NO_XRAY, GP_DRAWDATA_NO_XRAY);
/* Draw 'onionskins' (frame left + right) */
if (gpl->onion_flag & GP_LAYER_ONIONSKIN) {
annotation_draw_onionskins(gpd, gpl, gpf, offsx, offsy, winx, winy, cfra, dflag);
}
/* draw the strokes already in active frame */
annotation_draw_strokes(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, lthick, ink);
/* Draw verts of selected strokes:
* - when doing OpenGL renders, we don't want to be showing these, as that ends up flickering
* - locked layers can't be edited, so there's no point showing these verts
* as they will have no bearings on what gets edited
* - only show when in editmode, since operators shouldn't work otherwise
* (NOTE: doing it this way means that the toggling editmode
* shows visible change immediately).
*/
/* XXX: perhaps we don't want to show these when users are drawing... */
if ((G.f & G_FLAG_RENDER_VIEWPORT) == 0 && (gpl->flag & GP_LAYER_LOCKED) == 0 &&
(gpd->flag & GP_DATA_STROKE_EDITMODE)) {
annotation_draw_strokes_edit(
gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, gpl->flag, alpha);
}
/* Check if may need to draw the active stroke cache, only if this layer is the active layer
* that is being edited. (Stroke buffer is currently stored in gp-data)
*/
if (ED_gpencil_session_active() && (gpl->flag & GP_LAYER_ACTIVE) &&
(gpf->flag & GP_FRAME_PAINT)) {
/* Buffer stroke needs to be drawn with a different linestyle
* to help differentiate them from normal strokes.
*
* It should also be noted that sbuffer contains temporary point types
* i.e. tGPspoints NOT bGPDspoints
*/
annotation_draw_stroke_buffer(gpd->runtime.sbuffer,
gpd->runtime.sbuffer_used,
lthick,
dflag,
gpd->runtime.sbuffer_sflag,
ink);
}
}
} | /* loop over gpencil data layers, drawing them */ | loop over gpencil data layers, drawing them | [
"loop",
"over",
"gpencil",
"data",
"layers",
"drawing",
"them"
] | static void annotation_draw_data_layers(
bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag, float alpha)
{
float ink[4];
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
CLAMP_MIN(gpl->thickness, 1.0f);
short lthick = gpl->thickness;
copy_v3_v3(ink, gpl->color);
ink[3] = gpl->opacity;
if (gpl->flag & GP_LAYER_HIDE) {
continue;
}
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra, GP_GETFRAME_USE_PREV);
if (gpf == NULL) {
continue;
}
GPU_line_width(lthick);
SET_FLAG_FROM_TEST(dflag, gpl->flag & GP_LAYER_NO_XRAY, GP_DRAWDATA_NO_XRAY);
if (gpl->onion_flag & GP_LAYER_ONIONSKIN) {
annotation_draw_onionskins(gpd, gpl, gpf, offsx, offsy, winx, winy, cfra, dflag);
}
annotation_draw_strokes(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, lthick, ink);
if ((G.f & G_FLAG_RENDER_VIEWPORT) == 0 && (gpl->flag & GP_LAYER_LOCKED) == 0 &&
(gpd->flag & GP_DATA_STROKE_EDITMODE)) {
annotation_draw_strokes_edit(
gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, gpl->flag, alpha);
}
if (ED_gpencil_session_active() && (gpl->flag & GP_LAYER_ACTIVE) &&
(gpf->flag & GP_FRAME_PAINT)) {
annotation_draw_stroke_buffer(gpd->runtime.sbuffer,
gpd->runtime.sbuffer_used,
lthick,
dflag,
gpd->runtime.sbuffer_sflag,
ink);
}
}
} | [
"static",
"void",
"annotation_draw_data_layers",
"(",
"bGPdata",
"*",
"gpd",
",",
"int",
"offsx",
",",
"int",
"offsy",
",",
"int",
"winx",
",",
"int",
"winy",
",",
"int",
"cfra",
",",
"int",
"dflag",
",",
"float",
"alpha",
")",
"{",
"float",
"ink",
"[",
"4",
"]",
";",
"for",
"(",
"bGPDlayer",
"*",
"gpl",
"=",
"gpd",
"->",
"layers",
".",
"first",
";",
"gpl",
";",
"gpl",
"=",
"gpl",
"->",
"next",
")",
"{",
"CLAMP_MIN",
"(",
"gpl",
"->",
"thickness",
",",
"1.0f",
")",
";",
"short",
"lthick",
"=",
"gpl",
"->",
"thickness",
";",
"copy_v3_v3",
"(",
"ink",
",",
"gpl",
"->",
"color",
")",
";",
"ink",
"[",
"3",
"]",
"=",
"gpl",
"->",
"opacity",
";",
"if",
"(",
"gpl",
"->",
"flag",
"&",
"GP_LAYER_HIDE",
")",
"{",
"continue",
";",
"}",
"bGPDframe",
"*",
"gpf",
"=",
"BKE_gpencil_layer_getframe",
"(",
"gpl",
",",
"cfra",
",",
"GP_GETFRAME_USE_PREV",
")",
";",
"if",
"(",
"gpf",
"==",
"NULL",
")",
"{",
"continue",
";",
"}",
"GPU_line_width",
"(",
"lthick",
")",
";",
"SET_FLAG_FROM_TEST",
"(",
"dflag",
",",
"gpl",
"->",
"flag",
"&",
"GP_LAYER_NO_XRAY",
",",
"GP_DRAWDATA_NO_XRAY",
")",
";",
"if",
"(",
"gpl",
"->",
"onion_flag",
"&",
"GP_LAYER_ONIONSKIN",
")",
"{",
"annotation_draw_onionskins",
"(",
"gpd",
",",
"gpl",
",",
"gpf",
",",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
",",
"cfra",
",",
"dflag",
")",
";",
"}",
"annotation_draw_strokes",
"(",
"gpd",
",",
"gpl",
",",
"gpf",
",",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
",",
"dflag",
",",
"lthick",
",",
"ink",
")",
";",
"if",
"(",
"(",
"G",
".",
"f",
"&",
"G_FLAG_RENDER_VIEWPORT",
")",
"==",
"0",
"&&",
"(",
"gpl",
"->",
"flag",
"&",
"GP_LAYER_LOCKED",
")",
"==",
"0",
"&&",
"(",
"gpd",
"->",
"flag",
"&",
"GP_DATA_STROKE_EDITMODE",
")",
")",
"{",
"annotation_draw_strokes_edit",
"(",
"gpd",
",",
"gpl",
",",
"gpf",
",",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
",",
"dflag",
",",
"gpl",
"->",
"flag",
",",
"alpha",
")",
";",
"}",
"if",
"(",
"ED_gpencil_session_active",
"(",
")",
"&&",
"(",
"gpl",
"->",
"flag",
"&",
"GP_LAYER_ACTIVE",
")",
"&&",
"(",
"gpf",
"->",
"flag",
"&",
"GP_FRAME_PAINT",
")",
")",
"{",
"annotation_draw_stroke_buffer",
"(",
"gpd",
"->",
"runtime",
".",
"sbuffer",
",",
"gpd",
"->",
"runtime",
".",
"sbuffer_used",
",",
"lthick",
",",
"dflag",
",",
"gpd",
"->",
"runtime",
".",
"sbuffer_sflag",
",",
"ink",
")",
";",
"}",
"}",
"}"
] | loop over gpencil data layers, drawing them | [
"loop",
"over",
"gpencil",
"data",
"layers",
"drawing",
"them"
] | [
"/* verify never thickness is less than 1 */",
"/* apply layer opacity */",
"/* don't draw layer if hidden */",
"/* get frame to draw */",
"/* set basic stroke thickness */",
"/* Add layer drawing settings to the set of \"draw flags\"\n * NOTE: If the setting doesn't apply, it *must* be cleared,\n * as dflag's carry over from the previous layer\n */",
"/* xray... */",
"/* Draw 'onionskins' (frame left + right) */",
"/* draw the strokes already in active frame */",
"/* Draw verts of selected strokes:\n * - when doing OpenGL renders, we don't want to be showing these, as that ends up flickering\n * - locked layers can't be edited, so there's no point showing these verts\n * as they will have no bearings on what gets edited\n * - only show when in editmode, since operators shouldn't work otherwise\n * (NOTE: doing it this way means that the toggling editmode\n * shows visible change immediately).\n */",
"/* XXX: perhaps we don't want to show these when users are drawing... */",
"/* Check if may need to draw the active stroke cache, only if this layer is the active layer\n * that is being edited. (Stroke buffer is currently stored in gp-data)\n */",
"/* Buffer stroke needs to be drawn with a different linestyle\n * to help differentiate them from normal strokes.\n *\n * It should also be noted that sbuffer contains temporary point types\n * i.e. tGPspoints NOT bGPDspoints\n */"
] | [
{
"param": "gpd",
"type": "bGPdata"
},
{
"param": "offsx",
"type": "int"
},
{
"param": "offsy",
"type": "int"
},
{
"param": "winx",
"type": "int"
},
{
"param": "winy",
"type": "int"
},
{
"param": "cfra",
"type": "int"
},
{
"param": "dflag",
"type": "int"
},
{
"param": "alpha",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gpd",
"type": "bGPdata",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offsx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offsy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "winx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "winy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cfra",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dflag",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "alpha",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | annotation_draw_status_text | void | static void annotation_draw_status_text(const bGPdata *gpd, ARegion *ar)
{
/* Cannot draw any status text when drawing OpenGL Renders */
if (G.f & G_FLAG_RENDER_VIEWPORT) {
return;
}
/* Get bounds of region - Necessary to avoid problems with region overlap */
const rcti *rect = ED_region_visible_rect(ar);
/* for now, this should only be used to indicate when we are in stroke editmode */
if (gpd->flag & GP_DATA_STROKE_EDITMODE) {
const char *printable = IFACE_("GPencil Stroke Editing");
float printable_size[2];
int font_id = BLF_default();
BLF_width_and_height(
font_id, printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
int xco = (rect->xmax - U.widget_unit) - (int)printable_size[0];
int yco = (rect->ymax - U.widget_unit);
/* text label */
UI_FontThemeColor(font_id, TH_TEXT_HI);
#ifdef WITH_INTERNATIONAL
BLF_draw_default(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
#else
BLF_draw_default_ascii(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
#endif
/* grease pencil icon... */
// XXX: is this too intrusive?
GPU_blend_set_func_separate(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
GPU_blend(true);
xco -= U.widget_unit;
yco -= (int)printable_size[1] / 2;
UI_icon_draw(xco, yco, ICON_GREASEPENCIL);
GPU_blend(false);
}
} | /* draw a short status message in the top-right corner */ | draw a short status message in the top-right corner | [
"draw",
"a",
"short",
"status",
"message",
"in",
"the",
"top",
"-",
"right",
"corner"
] | static void annotation_draw_status_text(const bGPdata *gpd, ARegion *ar)
{
if (G.f & G_FLAG_RENDER_VIEWPORT) {
return;
}
const rcti *rect = ED_region_visible_rect(ar);
if (gpd->flag & GP_DATA_STROKE_EDITMODE) {
const char *printable = IFACE_("GPencil Stroke Editing");
float printable_size[2];
int font_id = BLF_default();
BLF_width_and_height(
font_id, printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
int xco = (rect->xmax - U.widget_unit) - (int)printable_size[0];
int yco = (rect->ymax - U.widget_unit);
UI_FontThemeColor(font_id, TH_TEXT_HI);
#ifdef WITH_INTERNATIONAL
BLF_draw_default(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
#else
BLF_draw_default_ascii(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
#endif
GPU_blend_set_func_separate(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
GPU_blend(true);
xco -= U.widget_unit;
yco -= (int)printable_size[1] / 2;
UI_icon_draw(xco, yco, ICON_GREASEPENCIL);
GPU_blend(false);
}
} | [
"static",
"void",
"annotation_draw_status_text",
"(",
"const",
"bGPdata",
"*",
"gpd",
",",
"ARegion",
"*",
"ar",
")",
"{",
"if",
"(",
"G",
".",
"f",
"&",
"G_FLAG_RENDER_VIEWPORT",
")",
"{",
"return",
";",
"}",
"const",
"rcti",
"*",
"rect",
"=",
"ED_region_visible_rect",
"(",
"ar",
")",
";",
"if",
"(",
"gpd",
"->",
"flag",
"&",
"GP_DATA_STROKE_EDITMODE",
")",
"{",
"const",
"char",
"*",
"printable",
"=",
"IFACE_",
"(",
"\"",
"\"",
")",
";",
"float",
"printable_size",
"[",
"2",
"]",
";",
"int",
"font_id",
"=",
"BLF_default",
"(",
")",
";",
"BLF_width_and_height",
"(",
"font_id",
",",
"printable",
",",
"BLF_DRAW_STR_DUMMY_MAX",
",",
"&",
"printable_size",
"[",
"0",
"]",
",",
"&",
"printable_size",
"[",
"1",
"]",
")",
";",
"int",
"xco",
"=",
"(",
"rect",
"->",
"xmax",
"-",
"U",
".",
"widget_unit",
")",
"-",
"(",
"int",
")",
"printable_size",
"[",
"0",
"]",
";",
"int",
"yco",
"=",
"(",
"rect",
"->",
"ymax",
"-",
"U",
".",
"widget_unit",
")",
";",
"UI_FontThemeColor",
"(",
"font_id",
",",
"TH_TEXT_HI",
")",
";",
"#ifdef",
"WITH_INTERNATIONAL",
"BLF_draw_default",
"(",
"xco",
",",
"yco",
",",
"0.0f",
",",
"printable",
",",
"BLF_DRAW_STR_DUMMY_MAX",
")",
";",
"#else",
"BLF_draw_default_ascii",
"(",
"xco",
",",
"yco",
",",
"0.0f",
",",
"printable",
",",
"BLF_DRAW_STR_DUMMY_MAX",
")",
";",
"#endif",
"GPU_blend_set_func_separate",
"(",
"GPU_SRC_ALPHA",
",",
"GPU_ONE_MINUS_SRC_ALPHA",
",",
"GPU_ONE",
",",
"GPU_ONE_MINUS_SRC_ALPHA",
")",
";",
"GPU_blend",
"(",
"true",
")",
";",
"xco",
"-=",
"U",
".",
"widget_unit",
";",
"yco",
"-=",
"(",
"int",
")",
"printable_size",
"[",
"1",
"]",
"/",
"2",
";",
"UI_icon_draw",
"(",
"xco",
",",
"yco",
",",
"ICON_GREASEPENCIL",
")",
";",
"GPU_blend",
"(",
"false",
")",
";",
"}",
"}"
] | draw a short status message in the top-right corner | [
"draw",
"a",
"short",
"status",
"message",
"in",
"the",
"top",
"-",
"right",
"corner"
] | [
"/* Cannot draw any status text when drawing OpenGL Renders */",
"/* Get bounds of region - Necessary to avoid problems with region overlap */",
"/* for now, this should only be used to indicate when we are in stroke editmode */",
"/* text label */",
"/* grease pencil icon... */",
"// XXX: is this too intrusive?"
] | [
{
"param": "gpd",
"type": "bGPdata"
},
{
"param": "ar",
"type": "ARegion"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gpd",
"type": "bGPdata",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ar",
"type": "ARegion",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | annotation_draw_data_all | void | static void annotation_draw_data_all(Scene *scene,
bGPdata *gpd,
int offsx,
int offsy,
int winx,
int winy,
int cfra,
int dflag,
const char spacetype)
{
bGPdata *gpd_source = NULL;
float alpha = 1.0f;
if (scene) {
if (spacetype == SPACE_VIEW3D) {
gpd_source = (scene->gpd ? scene->gpd : NULL);
}
else if (spacetype == SPACE_CLIP && scene->clip) {
/* currently drawing only gpencil data from either clip or track,
* but not both - XXX fix logic behind */
gpd_source = (scene->clip->gpd ? scene->clip->gpd : NULL);
}
if (gpd_source) {
annotation_draw_data(gpd_source, offsx, offsy, winx, winy, cfra, dflag, alpha);
}
}
/* scene/clip data has already been drawn, only object/track data is drawn here
* if gpd_source == gpd, we don't have any object/track data and we can skip */
if (gpd_source == NULL || (gpd_source && gpd_source != gpd)) {
annotation_draw_data(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha);
}
} | /* if we have strokes for scenes (3d view)/clips (movie clip editor)
* and objects/tracks, multiple data blocks have to be drawn */ | if we have strokes for scenes (3d view)/clips (movie clip editor)
and objects/tracks, multiple data blocks have to be drawn | [
"if",
"we",
"have",
"strokes",
"for",
"scenes",
"(",
"3d",
"view",
")",
"/",
"clips",
"(",
"movie",
"clip",
"editor",
")",
"and",
"objects",
"/",
"tracks",
"multiple",
"data",
"blocks",
"have",
"to",
"be",
"drawn"
] | static void annotation_draw_data_all(Scene *scene,
bGPdata *gpd,
int offsx,
int offsy,
int winx,
int winy,
int cfra,
int dflag,
const char spacetype)
{
bGPdata *gpd_source = NULL;
float alpha = 1.0f;
if (scene) {
if (spacetype == SPACE_VIEW3D) {
gpd_source = (scene->gpd ? scene->gpd : NULL);
}
else if (spacetype == SPACE_CLIP && scene->clip) {
gpd_source = (scene->clip->gpd ? scene->clip->gpd : NULL);
}
if (gpd_source) {
annotation_draw_data(gpd_source, offsx, offsy, winx, winy, cfra, dflag, alpha);
}
}
if (gpd_source == NULL || (gpd_source && gpd_source != gpd)) {
annotation_draw_data(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha);
}
} | [
"static",
"void",
"annotation_draw_data_all",
"(",
"Scene",
"*",
"scene",
",",
"bGPdata",
"*",
"gpd",
",",
"int",
"offsx",
",",
"int",
"offsy",
",",
"int",
"winx",
",",
"int",
"winy",
",",
"int",
"cfra",
",",
"int",
"dflag",
",",
"const",
"char",
"spacetype",
")",
"{",
"bGPdata",
"*",
"gpd_source",
"=",
"NULL",
";",
"float",
"alpha",
"=",
"1.0f",
";",
"if",
"(",
"scene",
")",
"{",
"if",
"(",
"spacetype",
"==",
"SPACE_VIEW3D",
")",
"{",
"gpd_source",
"=",
"(",
"scene",
"->",
"gpd",
"?",
"scene",
"->",
"gpd",
":",
"NULL",
")",
";",
"}",
"else",
"if",
"(",
"spacetype",
"==",
"SPACE_CLIP",
"&&",
"scene",
"->",
"clip",
")",
"{",
"gpd_source",
"=",
"(",
"scene",
"->",
"clip",
"->",
"gpd",
"?",
"scene",
"->",
"clip",
"->",
"gpd",
":",
"NULL",
")",
";",
"}",
"if",
"(",
"gpd_source",
")",
"{",
"annotation_draw_data",
"(",
"gpd_source",
",",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
",",
"cfra",
",",
"dflag",
",",
"alpha",
")",
";",
"}",
"}",
"if",
"(",
"gpd_source",
"==",
"NULL",
"||",
"(",
"gpd_source",
"&&",
"gpd_source",
"!=",
"gpd",
")",
")",
"{",
"annotation_draw_data",
"(",
"gpd",
",",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
",",
"cfra",
",",
"dflag",
",",
"alpha",
")",
";",
"}",
"}"
] | if we have strokes for scenes (3d view)/clips (movie clip editor)
and objects/tracks, multiple data blocks have to be drawn | [
"if",
"we",
"have",
"strokes",
"for",
"scenes",
"(",
"3d",
"view",
")",
"/",
"clips",
"(",
"movie",
"clip",
"editor",
")",
"and",
"objects",
"/",
"tracks",
"multiple",
"data",
"blocks",
"have",
"to",
"be",
"drawn"
] | [
"/* currently drawing only gpencil data from either clip or track,\n * but not both - XXX fix logic behind */",
"/* scene/clip data has already been drawn, only object/track data is drawn here\n * if gpd_source == gpd, we don't have any object/track data and we can skip */"
] | [
{
"param": "scene",
"type": "Scene"
},
{
"param": "gpd",
"type": "bGPdata"
},
{
"param": "offsx",
"type": "int"
},
{
"param": "offsy",
"type": "int"
},
{
"param": "winx",
"type": "int"
},
{
"param": "winy",
"type": "int"
},
{
"param": "cfra",
"type": "int"
},
{
"param": "dflag",
"type": "int"
},
{
"param": "spacetype",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scene",
"type": "Scene",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gpd",
"type": "bGPdata",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offsx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offsy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "winx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "winy",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cfra",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dflag",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "spacetype",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | ED_annotation_draw_2dimage | void | void ED_annotation_draw_2dimage(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
int offsx, offsy, sizex, sizey;
int dflag = GP_DRAWDATA_NOSTATUS;
bGPdata *gpd = ED_gpencil_data_get_active(C); // XXX
if (gpd == NULL) {
return;
}
/* calculate rect */
switch (sa->spacetype) {
case SPACE_IMAGE: /* image */
case SPACE_CLIP: /* clip */
{
/* just draw using standard scaling (settings here are currently ignored anyways) */
/* FIXME: the opengl poly-strokes don't draw at right thickness when done this way,
* so disabled. */
offsx = 0;
offsy = 0;
sizex = ar->winx;
sizey = ar->winy;
wmOrtho2(ar->v2d.cur.xmin, ar->v2d.cur.xmax, ar->v2d.cur.ymin, ar->v2d.cur.ymax);
dflag |= GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_IEDITHACK;
break;
}
case SPACE_SEQ: /* sequence */
{
/* just draw using standard scaling (settings here are currently ignored anyways) */
offsx = 0;
offsy = 0;
sizex = ar->winx;
sizey = ar->winy;
/* NOTE: I2D was used in 2.4x, but the old settings for that have been deprecated
* and everything moved to standard View2d
*/
dflag |= GP_DRAWDATA_ONLYV2D;
break;
}
default: /* for spacetype not yet handled */
offsx = 0;
offsy = 0;
sizex = ar->winx;
sizey = ar->winy;
dflag |= GP_DRAWDATA_ONLYI2D;
break;
}
if (ED_screen_animation_playing(wm)) {
/* Don't show onion-skins during animation playback/scrub (i.e. it obscures the poses)
* OpenGL Renders (i.e. final output), or depth buffer (i.e. not real strokes). */
dflag |= GP_DRAWDATA_NO_ONIONS;
}
/* draw it! */
annotation_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype);
} | /* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */ | draw grease-pencil sketches to specified 2d-view that uses ibuf corrections | [
"draw",
"grease",
"-",
"pencil",
"sketches",
"to",
"specified",
"2d",
"-",
"view",
"that",
"uses",
"ibuf",
"corrections"
] | void ED_annotation_draw_2dimage(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
int offsx, offsy, sizex, sizey;
int dflag = GP_DRAWDATA_NOSTATUS;
bGPdata *gpd = ED_gpencil_data_get_active(C);
if (gpd == NULL) {
return;
}
switch (sa->spacetype) {
case SPACE_IMAGE:
case SPACE_CLIP:
{
offsx = 0;
offsy = 0;
sizex = ar->winx;
sizey = ar->winy;
wmOrtho2(ar->v2d.cur.xmin, ar->v2d.cur.xmax, ar->v2d.cur.ymin, ar->v2d.cur.ymax);
dflag |= GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_IEDITHACK;
break;
}
case SPACE_SEQ:
{
offsx = 0;
offsy = 0;
sizex = ar->winx;
sizey = ar->winy;
dflag |= GP_DRAWDATA_ONLYV2D;
break;
}
default:
offsx = 0;
offsy = 0;
sizex = ar->winx;
sizey = ar->winy;
dflag |= GP_DRAWDATA_ONLYI2D;
break;
}
if (ED_screen_animation_playing(wm)) {
dflag |= GP_DRAWDATA_NO_ONIONS;
}
annotation_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype);
} | [
"void",
"ED_annotation_draw_2dimage",
"(",
"const",
"bContext",
"*",
"C",
")",
"{",
"wmWindowManager",
"*",
"wm",
"=",
"CTX_wm_manager",
"(",
"C",
")",
";",
"ScrArea",
"*",
"sa",
"=",
"CTX_wm_area",
"(",
"C",
")",
";",
"ARegion",
"*",
"ar",
"=",
"CTX_wm_region",
"(",
"C",
")",
";",
"Scene",
"*",
"scene",
"=",
"CTX_data_scene",
"(",
"C",
")",
";",
"int",
"offsx",
",",
"offsy",
",",
"sizex",
",",
"sizey",
";",
"int",
"dflag",
"=",
"GP_DRAWDATA_NOSTATUS",
";",
"bGPdata",
"*",
"gpd",
"=",
"ED_gpencil_data_get_active",
"(",
"C",
")",
";",
"if",
"(",
"gpd",
"==",
"NULL",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"sa",
"->",
"spacetype",
")",
"{",
"case",
"SPACE_IMAGE",
":",
"case",
"SPACE_CLIP",
":",
"{",
"offsx",
"=",
"0",
";",
"offsy",
"=",
"0",
";",
"sizex",
"=",
"ar",
"->",
"winx",
";",
"sizey",
"=",
"ar",
"->",
"winy",
";",
"wmOrtho2",
"(",
"ar",
"->",
"v2d",
".",
"cur",
".",
"xmin",
",",
"ar",
"->",
"v2d",
".",
"cur",
".",
"xmax",
",",
"ar",
"->",
"v2d",
".",
"cur",
".",
"ymin",
",",
"ar",
"->",
"v2d",
".",
"cur",
".",
"ymax",
")",
";",
"dflag",
"|=",
"GP_DRAWDATA_ONLYV2D",
"|",
"GP_DRAWDATA_IEDITHACK",
";",
"break",
";",
"}",
"case",
"SPACE_SEQ",
":",
"{",
"offsx",
"=",
"0",
";",
"offsy",
"=",
"0",
";",
"sizex",
"=",
"ar",
"->",
"winx",
";",
"sizey",
"=",
"ar",
"->",
"winy",
";",
"dflag",
"|=",
"GP_DRAWDATA_ONLYV2D",
";",
"break",
";",
"}",
"default",
":",
"offsx",
"=",
"0",
";",
"offsy",
"=",
"0",
";",
"sizex",
"=",
"ar",
"->",
"winx",
";",
"sizey",
"=",
"ar",
"->",
"winy",
";",
"dflag",
"|=",
"GP_DRAWDATA_ONLYI2D",
";",
"break",
";",
"}",
"if",
"(",
"ED_screen_animation_playing",
"(",
"wm",
")",
")",
"{",
"dflag",
"|=",
"GP_DRAWDATA_NO_ONIONS",
";",
"}",
"annotation_draw_data_all",
"(",
"scene",
",",
"gpd",
",",
"offsx",
",",
"offsy",
",",
"sizex",
",",
"sizey",
",",
"CFRA",
",",
"dflag",
",",
"sa",
"->",
"spacetype",
")",
";",
"}"
] | draw grease-pencil sketches to specified 2d-view that uses ibuf corrections | [
"draw",
"grease",
"-",
"pencil",
"sketches",
"to",
"specified",
"2d",
"-",
"view",
"that",
"uses",
"ibuf",
"corrections"
] | [
"// XXX",
"/* calculate rect */",
"/* image */",
"/* clip */",
"/* just draw using standard scaling (settings here are currently ignored anyways) */",
"/* FIXME: the opengl poly-strokes don't draw at right thickness when done this way,\n * so disabled. */",
"/* sequence */",
"/* just draw using standard scaling (settings here are currently ignored anyways) */",
"/* NOTE: I2D was used in 2.4x, but the old settings for that have been deprecated\n * and everything moved to standard View2d\n */",
"/* for spacetype not yet handled */",
"/* Don't show onion-skins during animation playback/scrub (i.e. it obscures the poses)\n * OpenGL Renders (i.e. final output), or depth buffer (i.e. not real strokes). */",
"/* draw it! */"
] | [
{
"param": "C",
"type": "bContext"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "C",
"type": "bContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | ED_annotation_draw_view2d | void | void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
{
wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
int dflag = 0;
/* check that we have grease-pencil stuff to draw */
if (sa == NULL) {
return;
}
bGPdata *gpd = ED_gpencil_data_get_active(C); // XXX
if (gpd == NULL) {
return;
}
/* special hack for Image Editor */
/* FIXME: the opengl poly-strokes don't draw at right thickness when done this way,
* so disabled. */
if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) {
dflag |= GP_DRAWDATA_IEDITHACK;
}
/* draw it! */
if (onlyv2d) {
dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS);
}
if (ED_screen_animation_playing(wm)) {
dflag |= GP_DRAWDATA_NO_ONIONS;
}
annotation_draw_data_all(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype);
/* draw status text (if in screen/pixel-space) */
if (!onlyv2d) {
annotation_draw_status_text(gpd, ar);
}
} | /**
* Draw grease-pencil sketches to specified 2d-view
* assuming that matrices are already set correctly.
*
* \note This gets called twice - first time with onlyv2d=true to draw 'canvas' strokes,
* second time with onlyv2d=false for screen-aligned strokes.
*/ | Draw grease-pencil sketches to specified 2d-view
assuming that matrices are already set correctly.
\note This gets called twice - first time with onlyv2d=true to draw 'canvas' strokes,
second time with onlyv2d=false for screen-aligned strokes. | [
"Draw",
"grease",
"-",
"pencil",
"sketches",
"to",
"specified",
"2d",
"-",
"view",
"assuming",
"that",
"matrices",
"are",
"already",
"set",
"correctly",
".",
"\\",
"note",
"This",
"gets",
"called",
"twice",
"-",
"first",
"time",
"with",
"onlyv2d",
"=",
"true",
"to",
"draw",
"'",
"canvas",
"'",
"strokes",
"second",
"time",
"with",
"onlyv2d",
"=",
"false",
"for",
"screen",
"-",
"aligned",
"strokes",
"."
] | void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
{
wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
int dflag = 0;
if (sa == NULL) {
return;
}
bGPdata *gpd = ED_gpencil_data_get_active(C);
if (gpd == NULL) {
return;
}
if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) {
dflag |= GP_DRAWDATA_IEDITHACK;
}
if (onlyv2d) {
dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS);
}
if (ED_screen_animation_playing(wm)) {
dflag |= GP_DRAWDATA_NO_ONIONS;
}
annotation_draw_data_all(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype);
if (!onlyv2d) {
annotation_draw_status_text(gpd, ar);
}
} | [
"void",
"ED_annotation_draw_view2d",
"(",
"const",
"bContext",
"*",
"C",
",",
"bool",
"onlyv2d",
")",
"{",
"wmWindowManager",
"*",
"wm",
"=",
"CTX_wm_manager",
"(",
"C",
")",
";",
"ScrArea",
"*",
"sa",
"=",
"CTX_wm_area",
"(",
"C",
")",
";",
"ARegion",
"*",
"ar",
"=",
"CTX_wm_region",
"(",
"C",
")",
";",
"Scene",
"*",
"scene",
"=",
"CTX_data_scene",
"(",
"C",
")",
";",
"int",
"dflag",
"=",
"0",
";",
"if",
"(",
"sa",
"==",
"NULL",
")",
"{",
"return",
";",
"}",
"bGPdata",
"*",
"gpd",
"=",
"ED_gpencil_data_get_active",
"(",
"C",
")",
";",
"if",
"(",
"gpd",
"==",
"NULL",
")",
"{",
"return",
";",
"}",
"if",
"(",
"ELEM",
"(",
"sa",
"->",
"spacetype",
",",
"SPACE_IMAGE",
",",
"SPACE_CLIP",
")",
")",
"{",
"dflag",
"|=",
"GP_DRAWDATA_IEDITHACK",
";",
"}",
"if",
"(",
"onlyv2d",
")",
"{",
"dflag",
"|=",
"(",
"GP_DRAWDATA_ONLYV2D",
"|",
"GP_DRAWDATA_NOSTATUS",
")",
";",
"}",
"if",
"(",
"ED_screen_animation_playing",
"(",
"wm",
")",
")",
"{",
"dflag",
"|=",
"GP_DRAWDATA_NO_ONIONS",
";",
"}",
"annotation_draw_data_all",
"(",
"scene",
",",
"gpd",
",",
"0",
",",
"0",
",",
"ar",
"->",
"winx",
",",
"ar",
"->",
"winy",
",",
"CFRA",
",",
"dflag",
",",
"sa",
"->",
"spacetype",
")",
";",
"if",
"(",
"!",
"onlyv2d",
")",
"{",
"annotation_draw_status_text",
"(",
"gpd",
",",
"ar",
")",
";",
"}",
"}"
] | Draw grease-pencil sketches to specified 2d-view
assuming that matrices are already set correctly. | [
"Draw",
"grease",
"-",
"pencil",
"sketches",
"to",
"specified",
"2d",
"-",
"view",
"assuming",
"that",
"matrices",
"are",
"already",
"set",
"correctly",
"."
] | [
"/* check that we have grease-pencil stuff to draw */",
"// XXX",
"/* special hack for Image Editor */",
"/* FIXME: the opengl poly-strokes don't draw at right thickness when done this way,\n * so disabled. */",
"/* draw it! */",
"/* draw status text (if in screen/pixel-space) */"
] | [
{
"param": "C",
"type": "bContext"
},
{
"param": "onlyv2d",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "C",
"type": "bContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "onlyv2d",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67bf64a29034deed0fc8b89a3c83bfb5721d2924 | DemonRem/blender | source/blender/editors/gpencil/annotate_draw.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | ED_annotation_draw_view3d | void | void ED_annotation_draw_view3d(
Scene *scene, struct Depsgraph *depsgraph, View3D *v3d, ARegion *ar, bool only3d)
{
int dflag = 0;
RegionView3D *rv3d = ar->regiondata;
int offsx, offsy, winx, winy;
/* check that we have grease-pencil stuff to draw */
/* XXX: Hardcoded reference here may get out of sync if we change how we fetch annotation data */
bGPdata *gpd = scene->gpd;
if (gpd == NULL) {
return;
}
/* when rendering to the offscreen buffer we don't want to
* deal with the camera border, otherwise map the coords to the camera border. */
if ((rv3d->persp == RV3D_CAMOB) && !(G.f & G_FLAG_RENDER_VIEWPORT)) {
rctf rectf;
ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &rectf, true); /* no shift */
offsx = round_fl_to_int(rectf.xmin);
offsy = round_fl_to_int(rectf.ymin);
winx = round_fl_to_int(rectf.xmax - rectf.xmin);
winy = round_fl_to_int(rectf.ymax - rectf.ymin);
}
else {
offsx = 0;
offsy = 0;
winx = ar->winx;
winy = ar->winy;
}
/* set flags */
if (only3d) {
/* 3D strokes/3D space:
* - only 3D space points
* - don't status text either (as it's the wrong space)
*/
dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS);
}
if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
/* don't draw status text when "only render" flag is set */
dflag |= GP_DRAWDATA_NOSTATUS;
}
/* draw it! */
annotation_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype);
} | /* draw annotations sketches to specified 3d-view assuming that matrices are already set correctly
* Note: this gets called twice - first time with only3d=true to draw 3d-strokes,
* second time with only3d=false for screen-aligned strokes */ | draw annotations sketches to specified 3d-view assuming that matrices are already set correctly
Note: this gets called twice - first time with only3d=true to draw 3d-strokes,
second time with only3d=false for screen-aligned strokes | [
"draw",
"annotations",
"sketches",
"to",
"specified",
"3d",
"-",
"view",
"assuming",
"that",
"matrices",
"are",
"already",
"set",
"correctly",
"Note",
":",
"this",
"gets",
"called",
"twice",
"-",
"first",
"time",
"with",
"only3d",
"=",
"true",
"to",
"draw",
"3d",
"-",
"strokes",
"second",
"time",
"with",
"only3d",
"=",
"false",
"for",
"screen",
"-",
"aligned",
"strokes"
] | void ED_annotation_draw_view3d(
Scene *scene, struct Depsgraph *depsgraph, View3D *v3d, ARegion *ar, bool only3d)
{
int dflag = 0;
RegionView3D *rv3d = ar->regiondata;
int offsx, offsy, winx, winy;
bGPdata *gpd = scene->gpd;
if (gpd == NULL) {
return;
}
if ((rv3d->persp == RV3D_CAMOB) && !(G.f & G_FLAG_RENDER_VIEWPORT)) {
rctf rectf;
ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &rectf, true);
offsx = round_fl_to_int(rectf.xmin);
offsy = round_fl_to_int(rectf.ymin);
winx = round_fl_to_int(rectf.xmax - rectf.xmin);
winy = round_fl_to_int(rectf.ymax - rectf.ymin);
}
else {
offsx = 0;
offsy = 0;
winx = ar->winx;
winy = ar->winy;
}
if (only3d) {
dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS);
}
if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
dflag |= GP_DRAWDATA_NOSTATUS;
}
annotation_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype);
} | [
"void",
"ED_annotation_draw_view3d",
"(",
"Scene",
"*",
"scene",
",",
"struct",
"Depsgraph",
"*",
"depsgraph",
",",
"View3D",
"*",
"v3d",
",",
"ARegion",
"*",
"ar",
",",
"bool",
"only3d",
")",
"{",
"int",
"dflag",
"=",
"0",
";",
"RegionView3D",
"*",
"rv3d",
"=",
"ar",
"->",
"regiondata",
";",
"int",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
";",
"bGPdata",
"*",
"gpd",
"=",
"scene",
"->",
"gpd",
";",
"if",
"(",
"gpd",
"==",
"NULL",
")",
"{",
"return",
";",
"}",
"if",
"(",
"(",
"rv3d",
"->",
"persp",
"==",
"RV3D_CAMOB",
")",
"&&",
"!",
"(",
"G",
".",
"f",
"&",
"G_FLAG_RENDER_VIEWPORT",
")",
")",
"{",
"rctf",
"rectf",
";",
"ED_view3d_calc_camera_border",
"(",
"scene",
",",
"depsgraph",
",",
"ar",
",",
"v3d",
",",
"rv3d",
",",
"&",
"rectf",
",",
"true",
")",
";",
"offsx",
"=",
"round_fl_to_int",
"(",
"rectf",
".",
"xmin",
")",
";",
"offsy",
"=",
"round_fl_to_int",
"(",
"rectf",
".",
"ymin",
")",
";",
"winx",
"=",
"round_fl_to_int",
"(",
"rectf",
".",
"xmax",
"-",
"rectf",
".",
"xmin",
")",
";",
"winy",
"=",
"round_fl_to_int",
"(",
"rectf",
".",
"ymax",
"-",
"rectf",
".",
"ymin",
")",
";",
"}",
"else",
"{",
"offsx",
"=",
"0",
";",
"offsy",
"=",
"0",
";",
"winx",
"=",
"ar",
"->",
"winx",
";",
"winy",
"=",
"ar",
"->",
"winy",
";",
"}",
"if",
"(",
"only3d",
")",
"{",
"dflag",
"|=",
"(",
"GP_DRAWDATA_ONLY3D",
"|",
"GP_DRAWDATA_NOSTATUS",
")",
";",
"}",
"if",
"(",
"v3d",
"->",
"flag2",
"&",
"V3D_HIDE_OVERLAYS",
")",
"{",
"dflag",
"|=",
"GP_DRAWDATA_NOSTATUS",
";",
"}",
"annotation_draw_data_all",
"(",
"scene",
",",
"gpd",
",",
"offsx",
",",
"offsy",
",",
"winx",
",",
"winy",
",",
"CFRA",
",",
"dflag",
",",
"v3d",
"->",
"spacetype",
")",
";",
"}"
] | draw annotations sketches to specified 3d-view assuming that matrices are already set correctly
Note: this gets called twice - first time with only3d=true to draw 3d-strokes,
second time with only3d=false for screen-aligned strokes | [
"draw",
"annotations",
"sketches",
"to",
"specified",
"3d",
"-",
"view",
"assuming",
"that",
"matrices",
"are",
"already",
"set",
"correctly",
"Note",
":",
"this",
"gets",
"called",
"twice",
"-",
"first",
"time",
"with",
"only3d",
"=",
"true",
"to",
"draw",
"3d",
"-",
"strokes",
"second",
"time",
"with",
"only3d",
"=",
"false",
"for",
"screen",
"-",
"aligned",
"strokes"
] | [
"/* check that we have grease-pencil stuff to draw */",
"/* XXX: Hardcoded reference here may get out of sync if we change how we fetch annotation data */",
"/* when rendering to the offscreen buffer we don't want to\n * deal with the camera border, otherwise map the coords to the camera border. */",
"/* no shift */",
"/* set flags */",
"/* 3D strokes/3D space:\n * - only 3D space points\n * - don't status text either (as it's the wrong space)\n */",
"/* don't draw status text when \"only render\" flag is set */",
"/* draw it! */"
] | [
{
"param": "scene",
"type": "Scene"
},
{
"param": "depsgraph",
"type": "struct Depsgraph"
},
{
"param": "v3d",
"type": "View3D"
},
{
"param": "ar",
"type": "ARegion"
},
{
"param": "only3d",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scene",
"type": "Scene",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "depsgraph",
"type": "struct Depsgraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v3d",
"type": "View3D",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ar",
"type": "ARegion",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "only3d",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67a64921bbcaee8a97bb59cbe68ec29d1af6273d | DemonRem/blender | source/blender/modifiers/intern/MOD_particlesystem.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | deformVerts | void | static void deformVerts(ModifierData *md,
const ModifierEvalContext *ctx,
Mesh *mesh,
float (*vertexCos)[3],
int numVerts)
{
Mesh *mesh_src = mesh;
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
ParticleSystem *psys = NULL;
/* float cfra = BKE_scene_frame_get(md->scene); */ /* UNUSED */
if (ctx->object->particlesystem.first) {
psys = psmd->psys;
}
else {
return;
}
if (!psys_check_enabled(ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0)) {
return;
}
if (mesh_src == NULL) {
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, vertexCos, numVerts, false, true);
if (mesh_src == NULL) {
return;
}
}
/* clear old dm */
bool had_mesh_final = (psmd->mesh_final != NULL);
if (psmd->mesh_final) {
BKE_id_free(NULL, psmd->mesh_final);
psmd->mesh_final = NULL;
if (psmd->mesh_original) {
BKE_id_free(NULL, psmd->mesh_original);
psmd->mesh_original = NULL;
}
}
else if (psmd->flag & eParticleSystemFlag_file_loaded) {
/* in file read mesh just wasn't saved in file so no need to reset everything */
psmd->flag &= ~eParticleSystemFlag_file_loaded;
if (psys->particles == NULL) {
psys->recalc |= ID_RECALC_PSYS_RESET;
}
/* TODO(sergey): This is not how particles were working prior to copy on
* write, but now evaluation is similar to case when one duplicates the
* object. In that case particles were doing reset here.
*
* Don't do reset when entering particle edit mode, as that will destroy the edit mode data.
* Shouldn't be an issue, since particles are supposed to be evaluated once prior to entering
* edit mode anyway.
* Could in theory be an issue when everything is done in a script, but then solution is
* not known to me. */
if (ctx->object->mode != OB_MODE_PARTICLE_EDIT) {
psys->recalc |= ID_RECALC_PSYS_RESET;
}
}
/* make new mesh */
psmd->mesh_final = BKE_mesh_copy_for_eval(mesh_src, false);
BKE_mesh_vert_coords_apply(psmd->mesh_final, vertexCos);
BKE_mesh_calc_normals(psmd->mesh_final);
BKE_mesh_tessface_ensure(psmd->mesh_final);
if (!psmd->mesh_final->runtime.deformed_only) {
/* Get the original mesh from the object, this is what the particles
* are attached to so in case of non-deform modifiers we need to remap
* them to the final mesh (typically subdivision surfaces). */
Mesh *mesh_original = NULL;
if (ctx->object->type == OB_MESH) {
BMEditMesh *em = BKE_editmesh_from_object(ctx->object);
if (em) {
/* In edit mode get directly from the edit mesh. */
psmd->mesh_original = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL, mesh);
}
else {
/* Otherwise get regular mesh. */
mesh_original = ctx->object->data;
}
}
else {
mesh_original = mesh_src;
}
if (mesh_original) {
/* Make a persistent copy of the mesh. We don't actually need
* all this data, just some topology for remapping. Could be
* optimized once. */
psmd->mesh_original = BKE_mesh_copy_for_eval(mesh_original, false);
}
BKE_mesh_tessface_ensure(psmd->mesh_original);
}
if (mesh_src != psmd->mesh_final && mesh_src != mesh) {
BKE_id_free(NULL, mesh_src);
}
/* Report change in mesh structure.
* This is an unreliable check for the topology check, but allows some
* handy configuration like emitting particles from inside particle
* instance. */
if (had_mesh_final && (psmd->mesh_final->totvert != psmd->totdmvert ||
psmd->mesh_final->totedge != psmd->totdmedge ||
psmd->mesh_final->totface != psmd->totdmface)) {
psys->recalc |= ID_RECALC_PSYS_RESET;
}
psmd->totdmvert = psmd->mesh_final->totvert;
psmd->totdmedge = psmd->mesh_final->totedge;
psmd->totdmface = psmd->mesh_final->totface;
if (!(ctx->object->transflag & OB_NO_PSYS_UPDATE)) {
struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
psmd->flag &= ~eParticleSystemFlag_psys_updated;
particle_system_update(
ctx->depsgraph, scene, ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0);
psmd->flag |= eParticleSystemFlag_psys_updated;
}
if (DEG_is_active(ctx->depsgraph)) {
Object *object_orig = DEG_get_original_object(ctx->object);
ModifierData *md_orig = modifiers_findByName(object_orig, psmd->modifier.name);
BLI_assert(md_orig != NULL);
ParticleSystemModifierData *psmd_orig = (ParticleSystemModifierData *)md_orig;
psmd_orig->flag = psmd->flag;
}
} | /* saves the current emitter state for a particle system and calculates particles */ | saves the current emitter state for a particle system and calculates particles | [
"saves",
"the",
"current",
"emitter",
"state",
"for",
"a",
"particle",
"system",
"and",
"calculates",
"particles"
] | static void deformVerts(ModifierData *md,
const ModifierEvalContext *ctx,
Mesh *mesh,
float (*vertexCos)[3],
int numVerts)
{
Mesh *mesh_src = mesh;
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
ParticleSystem *psys = NULL;
if (ctx->object->particlesystem.first) {
psys = psmd->psys;
}
else {
return;
}
if (!psys_check_enabled(ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0)) {
return;
}
if (mesh_src == NULL) {
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, vertexCos, numVerts, false, true);
if (mesh_src == NULL) {
return;
}
}
bool had_mesh_final = (psmd->mesh_final != NULL);
if (psmd->mesh_final) {
BKE_id_free(NULL, psmd->mesh_final);
psmd->mesh_final = NULL;
if (psmd->mesh_original) {
BKE_id_free(NULL, psmd->mesh_original);
psmd->mesh_original = NULL;
}
}
else if (psmd->flag & eParticleSystemFlag_file_loaded) {
psmd->flag &= ~eParticleSystemFlag_file_loaded;
if (psys->particles == NULL) {
psys->recalc |= ID_RECALC_PSYS_RESET;
}
if (ctx->object->mode != OB_MODE_PARTICLE_EDIT) {
psys->recalc |= ID_RECALC_PSYS_RESET;
}
}
psmd->mesh_final = BKE_mesh_copy_for_eval(mesh_src, false);
BKE_mesh_vert_coords_apply(psmd->mesh_final, vertexCos);
BKE_mesh_calc_normals(psmd->mesh_final);
BKE_mesh_tessface_ensure(psmd->mesh_final);
if (!psmd->mesh_final->runtime.deformed_only) {
Mesh *mesh_original = NULL;
if (ctx->object->type == OB_MESH) {
BMEditMesh *em = BKE_editmesh_from_object(ctx->object);
if (em) {
psmd->mesh_original = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL, mesh);
}
else {
mesh_original = ctx->object->data;
}
}
else {
mesh_original = mesh_src;
}
if (mesh_original) {
psmd->mesh_original = BKE_mesh_copy_for_eval(mesh_original, false);
}
BKE_mesh_tessface_ensure(psmd->mesh_original);
}
if (mesh_src != psmd->mesh_final && mesh_src != mesh) {
BKE_id_free(NULL, mesh_src);
}
if (had_mesh_final && (psmd->mesh_final->totvert != psmd->totdmvert ||
psmd->mesh_final->totedge != psmd->totdmedge ||
psmd->mesh_final->totface != psmd->totdmface)) {
psys->recalc |= ID_RECALC_PSYS_RESET;
}
psmd->totdmvert = psmd->mesh_final->totvert;
psmd->totdmedge = psmd->mesh_final->totedge;
psmd->totdmface = psmd->mesh_final->totface;
if (!(ctx->object->transflag & OB_NO_PSYS_UPDATE)) {
struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
psmd->flag &= ~eParticleSystemFlag_psys_updated;
particle_system_update(
ctx->depsgraph, scene, ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0);
psmd->flag |= eParticleSystemFlag_psys_updated;
}
if (DEG_is_active(ctx->depsgraph)) {
Object *object_orig = DEG_get_original_object(ctx->object);
ModifierData *md_orig = modifiers_findByName(object_orig, psmd->modifier.name);
BLI_assert(md_orig != NULL);
ParticleSystemModifierData *psmd_orig = (ParticleSystemModifierData *)md_orig;
psmd_orig->flag = psmd->flag;
}
} | [
"static",
"void",
"deformVerts",
"(",
"ModifierData",
"*",
"md",
",",
"const",
"ModifierEvalContext",
"*",
"ctx",
",",
"Mesh",
"*",
"mesh",
",",
"float",
"(",
"*",
"vertexCos",
")",
"[",
"3",
"]",
",",
"int",
"numVerts",
")",
"{",
"Mesh",
"*",
"mesh_src",
"=",
"mesh",
";",
"ParticleSystemModifierData",
"*",
"psmd",
"=",
"(",
"ParticleSystemModifierData",
"*",
")",
"md",
";",
"ParticleSystem",
"*",
"psys",
"=",
"NULL",
";",
"if",
"(",
"ctx",
"->",
"object",
"->",
"particlesystem",
".",
"first",
")",
"{",
"psys",
"=",
"psmd",
"->",
"psys",
";",
"}",
"else",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"psys_check_enabled",
"(",
"ctx",
"->",
"object",
",",
"psys",
",",
"(",
"ctx",
"->",
"flag",
"&",
"MOD_APPLY_RENDER",
")",
"!=",
"0",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"mesh_src",
"==",
"NULL",
")",
"{",
"mesh_src",
"=",
"MOD_deform_mesh_eval_get",
"(",
"ctx",
"->",
"object",
",",
"NULL",
",",
"NULL",
",",
"vertexCos",
",",
"numVerts",
",",
"false",
",",
"true",
")",
";",
"if",
"(",
"mesh_src",
"==",
"NULL",
")",
"{",
"return",
";",
"}",
"}",
"bool",
"had_mesh_final",
"=",
"(",
"psmd",
"->",
"mesh_final",
"!=",
"NULL",
")",
";",
"if",
"(",
"psmd",
"->",
"mesh_final",
")",
"{",
"BKE_id_free",
"(",
"NULL",
",",
"psmd",
"->",
"mesh_final",
")",
";",
"psmd",
"->",
"mesh_final",
"=",
"NULL",
";",
"if",
"(",
"psmd",
"->",
"mesh_original",
")",
"{",
"BKE_id_free",
"(",
"NULL",
",",
"psmd",
"->",
"mesh_original",
")",
";",
"psmd",
"->",
"mesh_original",
"=",
"NULL",
";",
"}",
"}",
"else",
"if",
"(",
"psmd",
"->",
"flag",
"&",
"eParticleSystemFlag_file_loaded",
")",
"{",
"psmd",
"->",
"flag",
"&=",
"~",
"eParticleSystemFlag_file_loaded",
";",
"if",
"(",
"psys",
"->",
"particles",
"==",
"NULL",
")",
"{",
"psys",
"->",
"recalc",
"|=",
"ID_RECALC_PSYS_RESET",
";",
"}",
"if",
"(",
"ctx",
"->",
"object",
"->",
"mode",
"!=",
"OB_MODE_PARTICLE_EDIT",
")",
"{",
"psys",
"->",
"recalc",
"|=",
"ID_RECALC_PSYS_RESET",
";",
"}",
"}",
"psmd",
"->",
"mesh_final",
"=",
"BKE_mesh_copy_for_eval",
"(",
"mesh_src",
",",
"false",
")",
";",
"BKE_mesh_vert_coords_apply",
"(",
"psmd",
"->",
"mesh_final",
",",
"vertexCos",
")",
";",
"BKE_mesh_calc_normals",
"(",
"psmd",
"->",
"mesh_final",
")",
";",
"BKE_mesh_tessface_ensure",
"(",
"psmd",
"->",
"mesh_final",
")",
";",
"if",
"(",
"!",
"psmd",
"->",
"mesh_final",
"->",
"runtime",
".",
"deformed_only",
")",
"{",
"Mesh",
"*",
"mesh_original",
"=",
"NULL",
";",
"if",
"(",
"ctx",
"->",
"object",
"->",
"type",
"==",
"OB_MESH",
")",
"{",
"BMEditMesh",
"*",
"em",
"=",
"BKE_editmesh_from_object",
"(",
"ctx",
"->",
"object",
")",
";",
"if",
"(",
"em",
")",
"{",
"psmd",
"->",
"mesh_original",
"=",
"BKE_mesh_from_bmesh_for_eval_nomain",
"(",
"em",
"->",
"bm",
",",
"NULL",
",",
"mesh",
")",
";",
"}",
"else",
"{",
"mesh_original",
"=",
"ctx",
"->",
"object",
"->",
"data",
";",
"}",
"}",
"else",
"{",
"mesh_original",
"=",
"mesh_src",
";",
"}",
"if",
"(",
"mesh_original",
")",
"{",
"psmd",
"->",
"mesh_original",
"=",
"BKE_mesh_copy_for_eval",
"(",
"mesh_original",
",",
"false",
")",
";",
"}",
"BKE_mesh_tessface_ensure",
"(",
"psmd",
"->",
"mesh_original",
")",
";",
"}",
"if",
"(",
"mesh_src",
"!=",
"psmd",
"->",
"mesh_final",
"&&",
"mesh_src",
"!=",
"mesh",
")",
"{",
"BKE_id_free",
"(",
"NULL",
",",
"mesh_src",
")",
";",
"}",
"if",
"(",
"had_mesh_final",
"&&",
"(",
"psmd",
"->",
"mesh_final",
"->",
"totvert",
"!=",
"psmd",
"->",
"totdmvert",
"||",
"psmd",
"->",
"mesh_final",
"->",
"totedge",
"!=",
"psmd",
"->",
"totdmedge",
"||",
"psmd",
"->",
"mesh_final",
"->",
"totface",
"!=",
"psmd",
"->",
"totdmface",
")",
")",
"{",
"psys",
"->",
"recalc",
"|=",
"ID_RECALC_PSYS_RESET",
";",
"}",
"psmd",
"->",
"totdmvert",
"=",
"psmd",
"->",
"mesh_final",
"->",
"totvert",
";",
"psmd",
"->",
"totdmedge",
"=",
"psmd",
"->",
"mesh_final",
"->",
"totedge",
";",
"psmd",
"->",
"totdmface",
"=",
"psmd",
"->",
"mesh_final",
"->",
"totface",
";",
"if",
"(",
"!",
"(",
"ctx",
"->",
"object",
"->",
"transflag",
"&",
"OB_NO_PSYS_UPDATE",
")",
")",
"{",
"struct",
"Scene",
"*",
"scene",
"=",
"DEG_get_evaluated_scene",
"(",
"ctx",
"->",
"depsgraph",
")",
";",
"psmd",
"->",
"flag",
"&=",
"~",
"eParticleSystemFlag_psys_updated",
";",
"particle_system_update",
"(",
"ctx",
"->",
"depsgraph",
",",
"scene",
",",
"ctx",
"->",
"object",
",",
"psys",
",",
"(",
"ctx",
"->",
"flag",
"&",
"MOD_APPLY_RENDER",
")",
"!=",
"0",
")",
";",
"psmd",
"->",
"flag",
"|=",
"eParticleSystemFlag_psys_updated",
";",
"}",
"if",
"(",
"DEG_is_active",
"(",
"ctx",
"->",
"depsgraph",
")",
")",
"{",
"Object",
"*",
"object_orig",
"=",
"DEG_get_original_object",
"(",
"ctx",
"->",
"object",
")",
";",
"ModifierData",
"*",
"md_orig",
"=",
"modifiers_findByName",
"(",
"object_orig",
",",
"psmd",
"->",
"modifier",
".",
"name",
")",
";",
"BLI_assert",
"(",
"md_orig",
"!=",
"NULL",
")",
";",
"ParticleSystemModifierData",
"*",
"psmd_orig",
"=",
"(",
"ParticleSystemModifierData",
"*",
")",
"md_orig",
";",
"psmd_orig",
"->",
"flag",
"=",
"psmd",
"->",
"flag",
";",
"}",
"}"
] | saves the current emitter state for a particle system and calculates particles | [
"saves",
"the",
"current",
"emitter",
"state",
"for",
"a",
"particle",
"system",
"and",
"calculates",
"particles"
] | [
"/* float cfra = BKE_scene_frame_get(md->scene); */",
"/* UNUSED */",
"/* clear old dm */",
"/* in file read mesh just wasn't saved in file so no need to reset everything */",
"/* TODO(sergey): This is not how particles were working prior to copy on\n * write, but now evaluation is similar to case when one duplicates the\n * object. In that case particles were doing reset here.\n *\n * Don't do reset when entering particle edit mode, as that will destroy the edit mode data.\n * Shouldn't be an issue, since particles are supposed to be evaluated once prior to entering\n * edit mode anyway.\n * Could in theory be an issue when everything is done in a script, but then solution is\n * not known to me. */",
"/* make new mesh */",
"/* Get the original mesh from the object, this is what the particles\n * are attached to so in case of non-deform modifiers we need to remap\n * them to the final mesh (typically subdivision surfaces). */",
"/* In edit mode get directly from the edit mesh. */",
"/* Otherwise get regular mesh. */",
"/* Make a persistent copy of the mesh. We don't actually need\n * all this data, just some topology for remapping. Could be\n * optimized once. */",
"/* Report change in mesh structure.\n * This is an unreliable check for the topology check, but allows some\n * handy configuration like emitting particles from inside particle\n * instance. */"
] | [
{
"param": "md",
"type": "ModifierData"
},
{
"param": "ctx",
"type": "ModifierEvalContext"
},
{
"param": "mesh",
"type": "Mesh"
},
{
"param": "vertexCos",
"type": "float"
},
{
"param": "numVerts",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "md",
"type": "ModifierData",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": "ModifierEvalContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mesh",
"type": "Mesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vertexCos",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "numVerts",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
192571044b947dac39a1397f06b6192ad4d8b71b | DemonRem/blender | source/blender/editors/interface/interface_style.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | UI_fontstyle_draw_simple_backdrop | void | void UI_fontstyle_draw_simple_backdrop(const uiFontStyle *fs,
float x,
float y,
const char *str,
const float col_fg[4],
const float col_bg[4])
{
if (fs->kerning == 1) {
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
}
UI_fontstyle_set(fs);
{
const float width = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
const float height = BLF_height_max(fs->uifont_id);
const float decent = BLF_descender(fs->uifont_id);
const float margin = height / 4.0f;
/* backdrop */
float color[4] = {col_bg[0], col_bg[1], col_bg[2], 0.5f};
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_aa(true,
x - margin,
(y + decent) - margin,
x + width + margin,
(y + decent) + height + margin,
margin,
color);
}
BLF_position(fs->uifont_id, x, y, 0.0f);
BLF_color4fv(fs->uifont_id, col_fg);
BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
if (fs->kerning == 1) {
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
}
} | /**
* Same as #UI_fontstyle_draw but draw a colored backdrop.
*/ | Same as #UI_fontstyle_draw but draw a colored backdrop. | [
"Same",
"as",
"#UI_fontstyle_draw",
"but",
"draw",
"a",
"colored",
"backdrop",
"."
] | void UI_fontstyle_draw_simple_backdrop(const uiFontStyle *fs,
float x,
float y,
const char *str,
const float col_fg[4],
const float col_bg[4])
{
if (fs->kerning == 1) {
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
}
UI_fontstyle_set(fs);
{
const float width = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
const float height = BLF_height_max(fs->uifont_id);
const float decent = BLF_descender(fs->uifont_id);
const float margin = height / 4.0f;
float color[4] = {col_bg[0], col_bg[1], col_bg[2], 0.5f};
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_aa(true,
x - margin,
(y + decent) - margin,
x + width + margin,
(y + decent) + height + margin,
margin,
color);
}
BLF_position(fs->uifont_id, x, y, 0.0f);
BLF_color4fv(fs->uifont_id, col_fg);
BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
if (fs->kerning == 1) {
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
}
} | [
"void",
"UI_fontstyle_draw_simple_backdrop",
"(",
"const",
"uiFontStyle",
"*",
"fs",
",",
"float",
"x",
",",
"float",
"y",
",",
"const",
"char",
"*",
"str",
",",
"const",
"float",
"col_fg",
"[",
"4",
"]",
",",
"const",
"float",
"col_bg",
"[",
"4",
"]",
")",
"{",
"if",
"(",
"fs",
"->",
"kerning",
"==",
"1",
")",
"{",
"BLF_enable",
"(",
"fs",
"->",
"uifont_id",
",",
"BLF_KERNING_DEFAULT",
")",
";",
"}",
"UI_fontstyle_set",
"(",
"fs",
")",
";",
"{",
"const",
"float",
"width",
"=",
"BLF_width",
"(",
"fs",
"->",
"uifont_id",
",",
"str",
",",
"BLF_DRAW_STR_DUMMY_MAX",
")",
";",
"const",
"float",
"height",
"=",
"BLF_height_max",
"(",
"fs",
"->",
"uifont_id",
")",
";",
"const",
"float",
"decent",
"=",
"BLF_descender",
"(",
"fs",
"->",
"uifont_id",
")",
";",
"const",
"float",
"margin",
"=",
"height",
"/",
"4.0f",
";",
"float",
"color",
"[",
"4",
"]",
"=",
"{",
"col_bg",
"[",
"0",
"]",
",",
"col_bg",
"[",
"1",
"]",
",",
"col_bg",
"[",
"2",
"]",
",",
"0.5f",
"}",
";",
"UI_draw_roundbox_corner_set",
"(",
"UI_CNR_ALL",
")",
";",
"UI_draw_roundbox_aa",
"(",
"true",
",",
"x",
"-",
"margin",
",",
"(",
"y",
"+",
"decent",
")",
"-",
"margin",
",",
"x",
"+",
"width",
"+",
"margin",
",",
"(",
"y",
"+",
"decent",
")",
"+",
"height",
"+",
"margin",
",",
"margin",
",",
"color",
")",
";",
"}",
"BLF_position",
"(",
"fs",
"->",
"uifont_id",
",",
"x",
",",
"y",
",",
"0.0f",
")",
";",
"BLF_color4fv",
"(",
"fs",
"->",
"uifont_id",
",",
"col_fg",
")",
";",
"BLF_draw",
"(",
"fs",
"->",
"uifont_id",
",",
"str",
",",
"BLF_DRAW_STR_DUMMY_MAX",
")",
";",
"if",
"(",
"fs",
"->",
"kerning",
"==",
"1",
")",
"{",
"BLF_disable",
"(",
"fs",
"->",
"uifont_id",
",",
"BLF_KERNING_DEFAULT",
")",
";",
"}",
"}"
] | Same as #UI_fontstyle_draw but draw a colored backdrop. | [
"Same",
"as",
"#UI_fontstyle_draw",
"but",
"draw",
"a",
"colored",
"backdrop",
"."
] | [
"/* backdrop */"
] | [
{
"param": "fs",
"type": "uiFontStyle"
},
{
"param": "x",
"type": "float"
},
{
"param": "y",
"type": "float"
},
{
"param": "str",
"type": "char"
},
{
"param": "col_fg",
"type": "float"
},
{
"param": "col_bg",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fs",
"type": "uiFontStyle",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "str",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col_fg",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col_bg",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
192571044b947dac39a1397f06b6192ad4d8b71b | DemonRem/blender | source/blender/editors/interface/interface_style.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | UI_style_get | uiStyle | uiStyle *UI_style_get(void)
{
#if 0
uiStyle *style = NULL;
/* offset is two struct uiStyle pointers */
style = BLI_findstring(&U.uistyles, "Unifont Style", sizeof(style) * 2);
return (style != NULL) ? style : U.uistyles.first;
#else
return U.uistyles.first;
#endif
} | /* ************** helpers ************************ */
/* XXX: read a style configure */ | helpers
XXX: read a style configure | [
"helpers",
"XXX",
":",
"read",
"a",
"style",
"configure"
] | uiStyle *UI_style_get(void)
{
#if 0
uiStyle *style = NULL;
style = BLI_findstring(&U.uistyles, "Unifont Style", sizeof(style) * 2);
return (style != NULL) ? style : U.uistyles.first;
#else
return U.uistyles.first;
#endif
} | [
"uiStyle",
"*",
"UI_style_get",
"(",
"void",
")",
"{",
"#if",
"0",
"\n",
"uiStyle",
"*",
"style",
"=",
"NULL",
";",
"style",
"=",
"BLI_findstring",
"(",
"&",
"U",
".",
"uistyles",
",",
"\"",
"\"",
",",
"sizeof",
"(",
"style",
")",
"*",
"2",
")",
";",
"return",
"(",
"style",
"!=",
"NULL",
")",
"?",
"style",
":",
"U",
".",
"uistyles",
".",
"first",
";",
"#else",
"return",
"U",
".",
"uistyles",
".",
"first",
";",
"#endif",
"}"
] | helpers
XXX: read a style configure | [
"helpers",
"XXX",
":",
"read",
"a",
"style",
"configure"
] | [
"/* offset is two struct uiStyle pointers */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
192571044b947dac39a1397f06b6192ad4d8b71b | DemonRem/blender | source/blender/editors/interface/interface_style.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | UI_style_get_dpi | uiStyle | uiStyle *UI_style_get_dpi(void)
{
uiStyle *style = UI_style_get();
static uiStyle _style;
_style = *style;
_style.paneltitle.shadx = (short)(UI_DPI_FAC * _style.paneltitle.shadx);
_style.paneltitle.shady = (short)(UI_DPI_FAC * _style.paneltitle.shady);
_style.grouplabel.shadx = (short)(UI_DPI_FAC * _style.grouplabel.shadx);
_style.grouplabel.shady = (short)(UI_DPI_FAC * _style.grouplabel.shady);
_style.widgetlabel.shadx = (short)(UI_DPI_FAC * _style.widgetlabel.shadx);
_style.widgetlabel.shady = (short)(UI_DPI_FAC * _style.widgetlabel.shady);
_style.columnspace = (short)(UI_DPI_FAC * _style.columnspace);
_style.templatespace = (short)(UI_DPI_FAC * _style.templatespace);
_style.boxspace = (short)(UI_DPI_FAC * _style.boxspace);
_style.buttonspacex = (short)(UI_DPI_FAC * _style.buttonspacex);
_style.buttonspacey = (short)(UI_DPI_FAC * _style.buttonspacey);
_style.panelspace = (short)(UI_DPI_FAC * _style.panelspace);
_style.panelouter = (short)(UI_DPI_FAC * _style.panelouter);
return &_style;
} | /* for drawing, scaled with DPI setting */ | for drawing, scaled with DPI setting | [
"for",
"drawing",
"scaled",
"with",
"DPI",
"setting"
] | uiStyle *UI_style_get_dpi(void)
{
uiStyle *style = UI_style_get();
static uiStyle _style;
_style = *style;
_style.paneltitle.shadx = (short)(UI_DPI_FAC * _style.paneltitle.shadx);
_style.paneltitle.shady = (short)(UI_DPI_FAC * _style.paneltitle.shady);
_style.grouplabel.shadx = (short)(UI_DPI_FAC * _style.grouplabel.shadx);
_style.grouplabel.shady = (short)(UI_DPI_FAC * _style.grouplabel.shady);
_style.widgetlabel.shadx = (short)(UI_DPI_FAC * _style.widgetlabel.shadx);
_style.widgetlabel.shady = (short)(UI_DPI_FAC * _style.widgetlabel.shady);
_style.columnspace = (short)(UI_DPI_FAC * _style.columnspace);
_style.templatespace = (short)(UI_DPI_FAC * _style.templatespace);
_style.boxspace = (short)(UI_DPI_FAC * _style.boxspace);
_style.buttonspacex = (short)(UI_DPI_FAC * _style.buttonspacex);
_style.buttonspacey = (short)(UI_DPI_FAC * _style.buttonspacey);
_style.panelspace = (short)(UI_DPI_FAC * _style.panelspace);
_style.panelouter = (short)(UI_DPI_FAC * _style.panelouter);
return &_style;
} | [
"uiStyle",
"*",
"UI_style_get_dpi",
"(",
"void",
")",
"{",
"uiStyle",
"*",
"style",
"=",
"UI_style_get",
"(",
")",
";",
"static",
"uiStyle",
"_style",
";",
"_style",
"=",
"*",
"style",
";",
"_style",
".",
"paneltitle",
".",
"shadx",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"paneltitle",
".",
"shadx",
")",
";",
"_style",
".",
"paneltitle",
".",
"shady",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"paneltitle",
".",
"shady",
")",
";",
"_style",
".",
"grouplabel",
".",
"shadx",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"grouplabel",
".",
"shadx",
")",
";",
"_style",
".",
"grouplabel",
".",
"shady",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"grouplabel",
".",
"shady",
")",
";",
"_style",
".",
"widgetlabel",
".",
"shadx",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"widgetlabel",
".",
"shadx",
")",
";",
"_style",
".",
"widgetlabel",
".",
"shady",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"widgetlabel",
".",
"shady",
")",
";",
"_style",
".",
"columnspace",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"columnspace",
")",
";",
"_style",
".",
"templatespace",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"templatespace",
")",
";",
"_style",
".",
"boxspace",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"boxspace",
")",
";",
"_style",
".",
"buttonspacex",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"buttonspacex",
")",
";",
"_style",
".",
"buttonspacey",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"buttonspacey",
")",
";",
"_style",
".",
"panelspace",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"panelspace",
")",
";",
"_style",
".",
"panelouter",
"=",
"(",
"short",
")",
"(",
"UI_DPI_FAC",
"*",
"_style",
".",
"panelouter",
")",
";",
"return",
"&",
"_style",
";",
"}"
] | for drawing, scaled with DPI setting | [
"for",
"drawing",
"scaled",
"with",
"DPI",
"setting"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
192571044b947dac39a1397f06b6192ad4d8b71b | DemonRem/blender | source/blender/editors/interface/interface_style.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | uiStyleInit | void | void uiStyleInit(void)
{
uiFont *font;
uiStyle *style = U.uistyles.first;
int monofont_size = datatoc_bmonofont_ttf_size;
uchar *monofont_ttf = (uchar *)datatoc_bmonofont_ttf;
/* recover from uninitialized dpi */
if (U.dpi == 0) {
U.dpi = 72;
}
CLAMP(U.dpi, 48, 144);
for (font = U.uifonts.first; font; font = font->next) {
BLF_unload_id(font->blf_id);
}
if (blf_mono_font != -1) {
BLF_unload_id(blf_mono_font);
blf_mono_font = -1;
}
if (blf_mono_font_render != -1) {
BLF_unload_id(blf_mono_font_render);
blf_mono_font_render = -1;
}
font = U.uifonts.first;
/* default builtin */
if (font == NULL) {
font = MEM_callocN(sizeof(uiFont), "ui font");
BLI_addtail(&U.uifonts, font);
}
if (U.font_path_ui[0]) {
BLI_strncpy(font->filename, U.font_path_ui, sizeof(font->filename));
font->uifont_id = UIFONT_CUSTOM1;
}
else {
BLI_strncpy(font->filename, "default", sizeof(font->filename));
font->uifont_id = UIFONT_DEFAULT;
}
for (font = U.uifonts.first; font; font = font->next) {
if (font->uifont_id == UIFONT_DEFAULT) {
#ifdef WITH_INTERNATIONAL
int font_size = datatoc_bfont_ttf_size;
uchar *font_ttf = (uchar *)datatoc_bfont_ttf;
static int last_font_size = 0;
/* use unicode font for translation */
if (U.transopts & USER_DOTRANSLATE) {
font_ttf = BLF_get_unifont(&font_size);
if (!font_ttf) {
/* fall back if not found */
font_size = datatoc_bfont_ttf_size;
font_ttf = (uchar *)datatoc_bfont_ttf;
}
}
/* relload only if needed */
if (last_font_size != font_size) {
BLF_unload("default");
last_font_size = font_size;
}
font->blf_id = BLF_load_mem("default", font_ttf, font_size);
#else
font->blf_id = BLF_load_mem("default", (uchar *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
#endif
}
else {
font->blf_id = BLF_load(font->filename);
if (font->blf_id == -1) {
font->blf_id = BLF_load_mem("default", (uchar *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
}
}
BLF_default_set(font->blf_id);
if (font->blf_id == -1) {
if (G.debug & G_DEBUG) {
printf("%s: error, no fonts available\n", __func__);
}
}
else {
/* ? just for speed to initialize?
* Yes, this build the glyph cache and create
* the texture.
*/
BLF_size(font->blf_id, 11 * U.pixelsize, U.dpi);
BLF_size(font->blf_id, 12 * U.pixelsize, U.dpi);
BLF_size(font->blf_id, 14 * U.pixelsize, U.dpi);
}
}
if (style == NULL) {
ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT);
}
#ifdef WITH_INTERNATIONAL
/* use unicode font for text editor and interactive console */
if (U.transopts & USER_DOTRANSLATE) {
monofont_ttf = BLF_get_unifont_mono(&monofont_size);
if (!monofont_ttf) {
/* fall back if not found */
monofont_size = datatoc_bmonofont_ttf_size;
monofont_ttf = (uchar *)datatoc_bmonofont_ttf;
}
}
#endif
/* XXX, this should be moved into a style,
* but for now best only load the monospaced font once. */
BLI_assert(blf_mono_font == -1);
if (U.font_path_ui_mono[0]) {
blf_mono_font = BLF_load_unique(U.font_path_ui_mono);
}
if (blf_mono_font == -1) {
blf_mono_font = BLF_load_mem_unique("monospace", monofont_ttf, monofont_size);
}
BLF_size(blf_mono_font, 12 * U.pixelsize, 72);
/* Set default flags based on UI preferences (not render fonts) */
{
int flag_disable = (BLF_MONOCHROME | BLF_HINTING_NONE | BLF_HINTING_SLIGHT | BLF_HINTING_FULL);
int flag_enable = 0;
if (U.text_render & USER_TEXT_HINTING_NONE) {
flag_enable |= BLF_HINTING_NONE;
}
else if (U.text_render & USER_TEXT_HINTING_SLIGHT) {
flag_enable |= BLF_HINTING_SLIGHT;
}
else if (U.text_render & USER_TEXT_HINTING_FULL) {
flag_enable |= BLF_HINTING_FULL;
}
if (U.text_render & USER_TEXT_DISABLE_AA) {
flag_enable |= BLF_MONOCHROME;
}
for (font = U.uifonts.first; font; font = font->next) {
if (font->blf_id != -1) {
BLF_disable(font->blf_id, flag_disable);
BLF_enable(font->blf_id, flag_enable);
}
}
if (blf_mono_font != -1) {
BLF_disable(blf_mono_font, flag_disable);
BLF_enable(blf_mono_font, flag_enable);
}
}
/**
* Second for rendering else we get threading problems,
*
* \note This isn't good that the render font depends on the preferences,
* keep for now though, since without this there is no way to display many unicode chars.
*/
if (blf_mono_font_render == -1) {
blf_mono_font_render = BLF_load_mem_unique("monospace", monofont_ttf, monofont_size);
}
BLF_size(blf_mono_font_render, 12 * U.pixelsize, 72);
} | /* called on each startup.blend read */
/* reading without uifont will create one */ | called on each startup.blend read
reading without uifont will create one | [
"called",
"on",
"each",
"startup",
".",
"blend",
"read",
"reading",
"without",
"uifont",
"will",
"create",
"one"
] | void uiStyleInit(void)
{
uiFont *font;
uiStyle *style = U.uistyles.first;
int monofont_size = datatoc_bmonofont_ttf_size;
uchar *monofont_ttf = (uchar *)datatoc_bmonofont_ttf;
if (U.dpi == 0) {
U.dpi = 72;
}
CLAMP(U.dpi, 48, 144);
for (font = U.uifonts.first; font; font = font->next) {
BLF_unload_id(font->blf_id);
}
if (blf_mono_font != -1) {
BLF_unload_id(blf_mono_font);
blf_mono_font = -1;
}
if (blf_mono_font_render != -1) {
BLF_unload_id(blf_mono_font_render);
blf_mono_font_render = -1;
}
font = U.uifonts.first;
if (font == NULL) {
font = MEM_callocN(sizeof(uiFont), "ui font");
BLI_addtail(&U.uifonts, font);
}
if (U.font_path_ui[0]) {
BLI_strncpy(font->filename, U.font_path_ui, sizeof(font->filename));
font->uifont_id = UIFONT_CUSTOM1;
}
else {
BLI_strncpy(font->filename, "default", sizeof(font->filename));
font->uifont_id = UIFONT_DEFAULT;
}
for (font = U.uifonts.first; font; font = font->next) {
if (font->uifont_id == UIFONT_DEFAULT) {
#ifdef WITH_INTERNATIONAL
int font_size = datatoc_bfont_ttf_size;
uchar *font_ttf = (uchar *)datatoc_bfont_ttf;
static int last_font_size = 0;
if (U.transopts & USER_DOTRANSLATE) {
font_ttf = BLF_get_unifont(&font_size);
if (!font_ttf) {
font_size = datatoc_bfont_ttf_size;
font_ttf = (uchar *)datatoc_bfont_ttf;
}
}
if (last_font_size != font_size) {
BLF_unload("default");
last_font_size = font_size;
}
font->blf_id = BLF_load_mem("default", font_ttf, font_size);
#else
font->blf_id = BLF_load_mem("default", (uchar *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
#endif
}
else {
font->blf_id = BLF_load(font->filename);
if (font->blf_id == -1) {
font->blf_id = BLF_load_mem("default", (uchar *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
}
}
BLF_default_set(font->blf_id);
if (font->blf_id == -1) {
if (G.debug & G_DEBUG) {
printf("%s: error, no fonts available\n", __func__);
}
}
else {
BLF_size(font->blf_id, 11 * U.pixelsize, U.dpi);
BLF_size(font->blf_id, 12 * U.pixelsize, U.dpi);
BLF_size(font->blf_id, 14 * U.pixelsize, U.dpi);
}
}
if (style == NULL) {
ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT);
}
#ifdef WITH_INTERNATIONAL
if (U.transopts & USER_DOTRANSLATE) {
monofont_ttf = BLF_get_unifont_mono(&monofont_size);
if (!monofont_ttf) {
monofont_size = datatoc_bmonofont_ttf_size;
monofont_ttf = (uchar *)datatoc_bmonofont_ttf;
}
}
#endif
BLI_assert(blf_mono_font == -1);
if (U.font_path_ui_mono[0]) {
blf_mono_font = BLF_load_unique(U.font_path_ui_mono);
}
if (blf_mono_font == -1) {
blf_mono_font = BLF_load_mem_unique("monospace", monofont_ttf, monofont_size);
}
BLF_size(blf_mono_font, 12 * U.pixelsize, 72);
{
int flag_disable = (BLF_MONOCHROME | BLF_HINTING_NONE | BLF_HINTING_SLIGHT | BLF_HINTING_FULL);
int flag_enable = 0;
if (U.text_render & USER_TEXT_HINTING_NONE) {
flag_enable |= BLF_HINTING_NONE;
}
else if (U.text_render & USER_TEXT_HINTING_SLIGHT) {
flag_enable |= BLF_HINTING_SLIGHT;
}
else if (U.text_render & USER_TEXT_HINTING_FULL) {
flag_enable |= BLF_HINTING_FULL;
}
if (U.text_render & USER_TEXT_DISABLE_AA) {
flag_enable |= BLF_MONOCHROME;
}
for (font = U.uifonts.first; font; font = font->next) {
if (font->blf_id != -1) {
BLF_disable(font->blf_id, flag_disable);
BLF_enable(font->blf_id, flag_enable);
}
}
if (blf_mono_font != -1) {
BLF_disable(blf_mono_font, flag_disable);
BLF_enable(blf_mono_font, flag_enable);
}
}
if (blf_mono_font_render == -1) {
blf_mono_font_render = BLF_load_mem_unique("monospace", monofont_ttf, monofont_size);
}
BLF_size(blf_mono_font_render, 12 * U.pixelsize, 72);
} | [
"void",
"uiStyleInit",
"(",
"void",
")",
"{",
"uiFont",
"*",
"font",
";",
"uiStyle",
"*",
"style",
"=",
"U",
".",
"uistyles",
".",
"first",
";",
"int",
"monofont_size",
"=",
"datatoc_bmonofont_ttf_size",
";",
"uchar",
"*",
"monofont_ttf",
"=",
"(",
"uchar",
"*",
")",
"datatoc_bmonofont_ttf",
";",
"if",
"(",
"U",
".",
"dpi",
"==",
"0",
")",
"{",
"U",
".",
"dpi",
"=",
"72",
";",
"}",
"CLAMP",
"(",
"U",
".",
"dpi",
",",
"48",
",",
"144",
")",
";",
"for",
"(",
"font",
"=",
"U",
".",
"uifonts",
".",
"first",
";",
"font",
";",
"font",
"=",
"font",
"->",
"next",
")",
"{",
"BLF_unload_id",
"(",
"font",
"->",
"blf_id",
")",
";",
"}",
"if",
"(",
"blf_mono_font",
"!=",
"-1",
")",
"{",
"BLF_unload_id",
"(",
"blf_mono_font",
")",
";",
"blf_mono_font",
"=",
"-1",
";",
"}",
"if",
"(",
"blf_mono_font_render",
"!=",
"-1",
")",
"{",
"BLF_unload_id",
"(",
"blf_mono_font_render",
")",
";",
"blf_mono_font_render",
"=",
"-1",
";",
"}",
"font",
"=",
"U",
".",
"uifonts",
".",
"first",
";",
"if",
"(",
"font",
"==",
"NULL",
")",
"{",
"font",
"=",
"MEM_callocN",
"(",
"sizeof",
"(",
"uiFont",
")",
",",
"\"",
"\"",
")",
";",
"BLI_addtail",
"(",
"&",
"U",
".",
"uifonts",
",",
"font",
")",
";",
"}",
"if",
"(",
"U",
".",
"font_path_ui",
"[",
"0",
"]",
")",
"{",
"BLI_strncpy",
"(",
"font",
"->",
"filename",
",",
"U",
".",
"font_path_ui",
",",
"sizeof",
"(",
"font",
"->",
"filename",
")",
")",
";",
"font",
"->",
"uifont_id",
"=",
"UIFONT_CUSTOM1",
";",
"}",
"else",
"{",
"BLI_strncpy",
"(",
"font",
"->",
"filename",
",",
"\"",
"\"",
",",
"sizeof",
"(",
"font",
"->",
"filename",
")",
")",
";",
"font",
"->",
"uifont_id",
"=",
"UIFONT_DEFAULT",
";",
"}",
"for",
"(",
"font",
"=",
"U",
".",
"uifonts",
".",
"first",
";",
"font",
";",
"font",
"=",
"font",
"->",
"next",
")",
"{",
"if",
"(",
"font",
"->",
"uifont_id",
"==",
"UIFONT_DEFAULT",
")",
"{",
"#ifdef",
"WITH_INTERNATIONAL",
"int",
"font_size",
"=",
"datatoc_bfont_ttf_size",
";",
"uchar",
"*",
"font_ttf",
"=",
"(",
"uchar",
"*",
")",
"datatoc_bfont_ttf",
";",
"static",
"int",
"last_font_size",
"=",
"0",
";",
"if",
"(",
"U",
".",
"transopts",
"&",
"USER_DOTRANSLATE",
")",
"{",
"font_ttf",
"=",
"BLF_get_unifont",
"(",
"&",
"font_size",
")",
";",
"if",
"(",
"!",
"font_ttf",
")",
"{",
"font_size",
"=",
"datatoc_bfont_ttf_size",
";",
"font_ttf",
"=",
"(",
"uchar",
"*",
")",
"datatoc_bfont_ttf",
";",
"}",
"}",
"if",
"(",
"last_font_size",
"!=",
"font_size",
")",
"{",
"BLF_unload",
"(",
"\"",
"\"",
")",
";",
"last_font_size",
"=",
"font_size",
";",
"}",
"font",
"->",
"blf_id",
"=",
"BLF_load_mem",
"(",
"\"",
"\"",
",",
"font_ttf",
",",
"font_size",
")",
";",
"#else",
"font",
"->",
"blf_id",
"=",
"BLF_load_mem",
"(",
"\"",
"\"",
",",
"(",
"uchar",
"*",
")",
"datatoc_bfont_ttf",
",",
"datatoc_bfont_ttf_size",
")",
";",
"#endif",
"}",
"else",
"{",
"font",
"->",
"blf_id",
"=",
"BLF_load",
"(",
"font",
"->",
"filename",
")",
";",
"if",
"(",
"font",
"->",
"blf_id",
"==",
"-1",
")",
"{",
"font",
"->",
"blf_id",
"=",
"BLF_load_mem",
"(",
"\"",
"\"",
",",
"(",
"uchar",
"*",
")",
"datatoc_bfont_ttf",
",",
"datatoc_bfont_ttf_size",
")",
";",
"}",
"}",
"BLF_default_set",
"(",
"font",
"->",
"blf_id",
")",
";",
"if",
"(",
"font",
"->",
"blf_id",
"==",
"-1",
")",
"{",
"if",
"(",
"G",
".",
"debug",
"&",
"G_DEBUG",
")",
"{",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"__func__",
")",
";",
"}",
"}",
"else",
"{",
"BLF_size",
"(",
"font",
"->",
"blf_id",
",",
"11",
"*",
"U",
".",
"pixelsize",
",",
"U",
".",
"dpi",
")",
";",
"BLF_size",
"(",
"font",
"->",
"blf_id",
",",
"12",
"*",
"U",
".",
"pixelsize",
",",
"U",
".",
"dpi",
")",
";",
"BLF_size",
"(",
"font",
"->",
"blf_id",
",",
"14",
"*",
"U",
".",
"pixelsize",
",",
"U",
".",
"dpi",
")",
";",
"}",
"}",
"if",
"(",
"style",
"==",
"NULL",
")",
"{",
"ui_style_new",
"(",
"&",
"U",
".",
"uistyles",
",",
"\"",
"\"",
",",
"UIFONT_DEFAULT",
")",
";",
"}",
"#ifdef",
"WITH_INTERNATIONAL",
"if",
"(",
"U",
".",
"transopts",
"&",
"USER_DOTRANSLATE",
")",
"{",
"monofont_ttf",
"=",
"BLF_get_unifont_mono",
"(",
"&",
"monofont_size",
")",
";",
"if",
"(",
"!",
"monofont_ttf",
")",
"{",
"monofont_size",
"=",
"datatoc_bmonofont_ttf_size",
";",
"monofont_ttf",
"=",
"(",
"uchar",
"*",
")",
"datatoc_bmonofont_ttf",
";",
"}",
"}",
"#endif",
"BLI_assert",
"(",
"blf_mono_font",
"==",
"-1",
")",
";",
"if",
"(",
"U",
".",
"font_path_ui_mono",
"[",
"0",
"]",
")",
"{",
"blf_mono_font",
"=",
"BLF_load_unique",
"(",
"U",
".",
"font_path_ui_mono",
")",
";",
"}",
"if",
"(",
"blf_mono_font",
"==",
"-1",
")",
"{",
"blf_mono_font",
"=",
"BLF_load_mem_unique",
"(",
"\"",
"\"",
",",
"monofont_ttf",
",",
"monofont_size",
")",
";",
"}",
"BLF_size",
"(",
"blf_mono_font",
",",
"12",
"*",
"U",
".",
"pixelsize",
",",
"72",
")",
";",
"{",
"int",
"flag_disable",
"=",
"(",
"BLF_MONOCHROME",
"|",
"BLF_HINTING_NONE",
"|",
"BLF_HINTING_SLIGHT",
"|",
"BLF_HINTING_FULL",
")",
";",
"int",
"flag_enable",
"=",
"0",
";",
"if",
"(",
"U",
".",
"text_render",
"&",
"USER_TEXT_HINTING_NONE",
")",
"{",
"flag_enable",
"|=",
"BLF_HINTING_NONE",
";",
"}",
"else",
"if",
"(",
"U",
".",
"text_render",
"&",
"USER_TEXT_HINTING_SLIGHT",
")",
"{",
"flag_enable",
"|=",
"BLF_HINTING_SLIGHT",
";",
"}",
"else",
"if",
"(",
"U",
".",
"text_render",
"&",
"USER_TEXT_HINTING_FULL",
")",
"{",
"flag_enable",
"|=",
"BLF_HINTING_FULL",
";",
"}",
"if",
"(",
"U",
".",
"text_render",
"&",
"USER_TEXT_DISABLE_AA",
")",
"{",
"flag_enable",
"|=",
"BLF_MONOCHROME",
";",
"}",
"for",
"(",
"font",
"=",
"U",
".",
"uifonts",
".",
"first",
";",
"font",
";",
"font",
"=",
"font",
"->",
"next",
")",
"{",
"if",
"(",
"font",
"->",
"blf_id",
"!=",
"-1",
")",
"{",
"BLF_disable",
"(",
"font",
"->",
"blf_id",
",",
"flag_disable",
")",
";",
"BLF_enable",
"(",
"font",
"->",
"blf_id",
",",
"flag_enable",
")",
";",
"}",
"}",
"if",
"(",
"blf_mono_font",
"!=",
"-1",
")",
"{",
"BLF_disable",
"(",
"blf_mono_font",
",",
"flag_disable",
")",
";",
"BLF_enable",
"(",
"blf_mono_font",
",",
"flag_enable",
")",
";",
"}",
"}",
"if",
"(",
"blf_mono_font_render",
"==",
"-1",
")",
"{",
"blf_mono_font_render",
"=",
"BLF_load_mem_unique",
"(",
"\"",
"\"",
",",
"monofont_ttf",
",",
"monofont_size",
")",
";",
"}",
"BLF_size",
"(",
"blf_mono_font_render",
",",
"12",
"*",
"U",
".",
"pixelsize",
",",
"72",
")",
";",
"}"
] | called on each startup.blend read
reading without uifont will create one | [
"called",
"on",
"each",
"startup",
".",
"blend",
"read",
"reading",
"without",
"uifont",
"will",
"create",
"one"
] | [
"/* recover from uninitialized dpi */",
"/* default builtin */",
"/* use unicode font for translation */",
"/* fall back if not found */",
"/* relload only if needed */",
"/* ? just for speed to initialize?\n * Yes, this build the glyph cache and create\n * the texture.\n */",
"/* use unicode font for text editor and interactive console */",
"/* fall back if not found */",
"/* XXX, this should be moved into a style,\n * but for now best only load the monospaced font once. */",
"/* Set default flags based on UI preferences (not render fonts) */",
"/**\n * Second for rendering else we get threading problems,\n *\n * \\note This isn't good that the render font depends on the preferences,\n * keep for now though, since without this there is no way to display many unicode chars.\n */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | flag_out_edge | void | static void flag_out_edge(BMesh *bm, BMEdge *bme)
{
if (bm->use_toolflags) {
BMO_edge_flag_enable(bm, bme, EDGE_OUT);
}
} | /* If we're called from the modifier, tool flags aren't available,
* but don't need output geometry. */ | If we're called from the modifier, tool flags aren't available,
but don't need output geometry. | [
"If",
"we",
"'",
"re",
"called",
"from",
"the",
"modifier",
"tool",
"flags",
"aren",
"'",
"t",
"available",
"but",
"don",
"'",
"t",
"need",
"output",
"geometry",
"."
] | static void flag_out_edge(BMesh *bm, BMEdge *bme)
{
if (bm->use_toolflags) {
BMO_edge_flag_enable(bm, bme, EDGE_OUT);
}
} | [
"static",
"void",
"flag_out_edge",
"(",
"BMesh",
"*",
"bm",
",",
"BMEdge",
"*",
"bme",
")",
"{",
"if",
"(",
"bm",
"->",
"use_toolflags",
")",
"{",
"BMO_edge_flag_enable",
"(",
"bm",
",",
"bme",
",",
"EDGE_OUT",
")",
";",
"}",
"}"
] | If we're called from the modifier, tool flags aren't available,
but don't need output geometry. | [
"If",
"we",
"'",
"re",
"called",
"from",
"the",
"modifier",
"tool",
"flags",
"aren",
"'",
"t",
"available",
"but",
"don",
"'",
"t",
"need",
"output",
"geometry",
"."
] | [] | [
{
"param": "bm",
"type": "BMesh"
},
{
"param": "bme",
"type": "BMEdge"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bm",
"type": "BMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bme",
"type": "BMEdge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | add_new_bound_vert | BoundVert | static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, const float co[3])
{
BoundVert *ans = (BoundVert *)BLI_memarena_alloc(mem_arena, sizeof(BoundVert));
copy_v3_v3(ans->nv.co, co);
if (!vm->boundstart) {
ans->index = 0;
vm->boundstart = ans;
ans->next = ans->prev = ans;
}
else {
BoundVert *tail = vm->boundstart->prev;
ans->index = tail->index + 1;
ans->prev = tail;
ans->next = vm->boundstart;
tail->next = ans;
vm->boundstart->prev = ans;
}
ans->profile.super_r = PRO_LINE_R;
ans->adjchain = NULL;
ans->sinratio = 1.0f;
ans->visited = false;
ans->any_seam = false;
ans->is_arc_start = false;
ans->is_patch_start = false;
vm->count++;
return ans;
} | /* Make a new BoundVert of the given kind, insert it at the end of the circular linked
* list with entry point bv->boundstart, and return it. */ | Make a new BoundVert of the given kind, insert it at the end of the circular linked
list with entry point bv->boundstart, and return it. | [
"Make",
"a",
"new",
"BoundVert",
"of",
"the",
"given",
"kind",
"insert",
"it",
"at",
"the",
"end",
"of",
"the",
"circular",
"linked",
"list",
"with",
"entry",
"point",
"bv",
"-",
">",
"boundstart",
"and",
"return",
"it",
"."
] | static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, const float co[3])
{
BoundVert *ans = (BoundVert *)BLI_memarena_alloc(mem_arena, sizeof(BoundVert));
copy_v3_v3(ans->nv.co, co);
if (!vm->boundstart) {
ans->index = 0;
vm->boundstart = ans;
ans->next = ans->prev = ans;
}
else {
BoundVert *tail = vm->boundstart->prev;
ans->index = tail->index + 1;
ans->prev = tail;
ans->next = vm->boundstart;
tail->next = ans;
vm->boundstart->prev = ans;
}
ans->profile.super_r = PRO_LINE_R;
ans->adjchain = NULL;
ans->sinratio = 1.0f;
ans->visited = false;
ans->any_seam = false;
ans->is_arc_start = false;
ans->is_patch_start = false;
vm->count++;
return ans;
} | [
"static",
"BoundVert",
"*",
"add_new_bound_vert",
"(",
"MemArena",
"*",
"mem_arena",
",",
"VMesh",
"*",
"vm",
",",
"const",
"float",
"co",
"[",
"3",
"]",
")",
"{",
"BoundVert",
"*",
"ans",
"=",
"(",
"BoundVert",
"*",
")",
"BLI_memarena_alloc",
"(",
"mem_arena",
",",
"sizeof",
"(",
"BoundVert",
")",
")",
";",
"copy_v3_v3",
"(",
"ans",
"->",
"nv",
".",
"co",
",",
"co",
")",
";",
"if",
"(",
"!",
"vm",
"->",
"boundstart",
")",
"{",
"ans",
"->",
"index",
"=",
"0",
";",
"vm",
"->",
"boundstart",
"=",
"ans",
";",
"ans",
"->",
"next",
"=",
"ans",
"->",
"prev",
"=",
"ans",
";",
"}",
"else",
"{",
"BoundVert",
"*",
"tail",
"=",
"vm",
"->",
"boundstart",
"->",
"prev",
";",
"ans",
"->",
"index",
"=",
"tail",
"->",
"index",
"+",
"1",
";",
"ans",
"->",
"prev",
"=",
"tail",
";",
"ans",
"->",
"next",
"=",
"vm",
"->",
"boundstart",
";",
"tail",
"->",
"next",
"=",
"ans",
";",
"vm",
"->",
"boundstart",
"->",
"prev",
"=",
"ans",
";",
"}",
"ans",
"->",
"profile",
".",
"super_r",
"=",
"PRO_LINE_R",
";",
"ans",
"->",
"adjchain",
"=",
"NULL",
";",
"ans",
"->",
"sinratio",
"=",
"1.0f",
";",
"ans",
"->",
"visited",
"=",
"false",
";",
"ans",
"->",
"any_seam",
"=",
"false",
";",
"ans",
"->",
"is_arc_start",
"=",
"false",
";",
"ans",
"->",
"is_patch_start",
"=",
"false",
";",
"vm",
"->",
"count",
"++",
";",
"return",
"ans",
";",
"}"
] | Make a new BoundVert of the given kind, insert it at the end of the circular linked
list with entry point bv->boundstart, and return it. | [
"Make",
"a",
"new",
"BoundVert",
"of",
"the",
"given",
"kind",
"insert",
"it",
"at",
"the",
"end",
"of",
"the",
"circular",
"linked",
"list",
"with",
"entry",
"point",
"bv",
"-",
">",
"boundstart",
"and",
"return",
"it",
"."
] | [] | [
{
"param": "mem_arena",
"type": "MemArena"
},
{
"param": "vm",
"type": "VMesh"
},
{
"param": "co",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mem_arena",
"type": "MemArena",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vm",
"type": "VMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "co",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | find_edge_half | EdgeHalf | static EdgeHalf *find_edge_half(BevVert *bv, BMEdge *bme)
{
int i;
for (i = 0; i < bv->edgecount; i++) {
if (bv->edges[i].e == bme) {
return &bv->edges[i];
}
}
return NULL;
} | /* find the EdgeHalf in bv's array that has edge bme */ | find the EdgeHalf in bv's array that has edge bme | [
"find",
"the",
"EdgeHalf",
"in",
"bv",
"'",
"s",
"array",
"that",
"has",
"edge",
"bme"
] | static EdgeHalf *find_edge_half(BevVert *bv, BMEdge *bme)
{
int i;
for (i = 0; i < bv->edgecount; i++) {
if (bv->edges[i].e == bme) {
return &bv->edges[i];
}
}
return NULL;
} | [
"static",
"EdgeHalf",
"*",
"find_edge_half",
"(",
"BevVert",
"*",
"bv",
",",
"BMEdge",
"*",
"bme",
")",
"{",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"bv",
"->",
"edgecount",
";",
"i",
"++",
")",
"{",
"if",
"(",
"bv",
"->",
"edges",
"[",
"i",
"]",
".",
"e",
"==",
"bme",
")",
"{",
"return",
"&",
"bv",
"->",
"edges",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"NULL",
";",
"}"
] | find the EdgeHalf in bv's array that has edge bme | [
"find",
"the",
"EdgeHalf",
"in",
"bv",
"'",
"s",
"array",
"that",
"has",
"edge",
"bme"
] | [] | [
{
"param": "bv",
"type": "BevVert"
},
{
"param": "bme",
"type": "BMEdge"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bv",
"type": "BevVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bme",
"type": "BMEdge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | find_other_end_edge_half | EdgeHalf | static EdgeHalf *find_other_end_edge_half(BevelParams *bp, EdgeHalf *e, BevVert **r_bvother)
{
BevVert *bvo;
EdgeHalf *eother;
bvo = find_bevvert(bp, e->is_rev ? e->e->v1 : e->e->v2);
if (bvo) {
if (r_bvother) {
*r_bvother = bvo;
}
eother = find_edge_half(bvo, e->e);
BLI_assert(eother != NULL);
return eother;
}
else if (r_bvother) {
*r_bvother = NULL;
}
return NULL;
} | /* Find the EdgeHalf representing the other end of e->e.
* Return other end's BevVert in *bvother, if r_bvother is provided.
* That may not have been constructed yet, in which case return NULL. */ | Find the EdgeHalf representing the other end of e->e.
Return other end's BevVert in *bvother, if r_bvother is provided.
That may not have been constructed yet, in which case return NULL. | [
"Find",
"the",
"EdgeHalf",
"representing",
"the",
"other",
"end",
"of",
"e",
"-",
">",
"e",
".",
"Return",
"other",
"end",
"'",
"s",
"BevVert",
"in",
"*",
"bvother",
"if",
"r_bvother",
"is",
"provided",
".",
"That",
"may",
"not",
"have",
"been",
"constructed",
"yet",
"in",
"which",
"case",
"return",
"NULL",
"."
] | static EdgeHalf *find_other_end_edge_half(BevelParams *bp, EdgeHalf *e, BevVert **r_bvother)
{
BevVert *bvo;
EdgeHalf *eother;
bvo = find_bevvert(bp, e->is_rev ? e->e->v1 : e->e->v2);
if (bvo) {
if (r_bvother) {
*r_bvother = bvo;
}
eother = find_edge_half(bvo, e->e);
BLI_assert(eother != NULL);
return eother;
}
else if (r_bvother) {
*r_bvother = NULL;
}
return NULL;
} | [
"static",
"EdgeHalf",
"*",
"find_other_end_edge_half",
"(",
"BevelParams",
"*",
"bp",
",",
"EdgeHalf",
"*",
"e",
",",
"BevVert",
"*",
"*",
"r_bvother",
")",
"{",
"BevVert",
"*",
"bvo",
";",
"EdgeHalf",
"*",
"eother",
";",
"bvo",
"=",
"find_bevvert",
"(",
"bp",
",",
"e",
"->",
"is_rev",
"?",
"e",
"->",
"e",
"->",
"v1",
":",
"e",
"->",
"e",
"->",
"v2",
")",
";",
"if",
"(",
"bvo",
")",
"{",
"if",
"(",
"r_bvother",
")",
"{",
"*",
"r_bvother",
"=",
"bvo",
";",
"}",
"eother",
"=",
"find_edge_half",
"(",
"bvo",
",",
"e",
"->",
"e",
")",
";",
"BLI_assert",
"(",
"eother",
"!=",
"NULL",
")",
";",
"return",
"eother",
";",
"}",
"else",
"if",
"(",
"r_bvother",
")",
"{",
"*",
"r_bvother",
"=",
"NULL",
";",
"}",
"return",
"NULL",
";",
"}"
] | Find the EdgeHalf representing the other end of e->e. | [
"Find",
"the",
"EdgeHalf",
"representing",
"the",
"other",
"end",
"of",
"e",
"-",
">",
"e",
"."
] | [] | [
{
"param": "bp",
"type": "BevelParams"
},
{
"param": "e",
"type": "EdgeHalf"
},
{
"param": "r_bvother",
"type": "BevVert"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bp",
"type": "BevelParams",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "e",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r_bvother",
"type": "BevVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | next_bev | EdgeHalf | static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e)
{
EdgeHalf *e;
if (from_e == NULL) {
from_e = &bv->edges[bv->edgecount - 1];
}
e = from_e;
do {
if (e->is_bev) {
return e;
}
} while ((e = e->next) != from_e);
return NULL;
} | /* Return the next EdgeHalf after from_e that is beveled.
* If from_e is NULL, find the first beveled edge. */ | Return the next EdgeHalf after from_e that is beveled.
If from_e is NULL, find the first beveled edge. | [
"Return",
"the",
"next",
"EdgeHalf",
"after",
"from_e",
"that",
"is",
"beveled",
".",
"If",
"from_e",
"is",
"NULL",
"find",
"the",
"first",
"beveled",
"edge",
"."
] | static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e)
{
EdgeHalf *e;
if (from_e == NULL) {
from_e = &bv->edges[bv->edgecount - 1];
}
e = from_e;
do {
if (e->is_bev) {
return e;
}
} while ((e = e->next) != from_e);
return NULL;
} | [
"static",
"EdgeHalf",
"*",
"next_bev",
"(",
"BevVert",
"*",
"bv",
",",
"EdgeHalf",
"*",
"from_e",
")",
"{",
"EdgeHalf",
"*",
"e",
";",
"if",
"(",
"from_e",
"==",
"NULL",
")",
"{",
"from_e",
"=",
"&",
"bv",
"->",
"edges",
"[",
"bv",
"->",
"edgecount",
"-",
"1",
"]",
";",
"}",
"e",
"=",
"from_e",
";",
"do",
"{",
"if",
"(",
"e",
"->",
"is_bev",
")",
"{",
"return",
"e",
";",
"}",
"}",
"while",
"(",
"(",
"e",
"=",
"e",
"->",
"next",
")",
"!=",
"from_e",
")",
";",
"return",
"NULL",
";",
"}"
] | Return the next EdgeHalf after from_e that is beveled. | [
"Return",
"the",
"next",
"EdgeHalf",
"after",
"from_e",
"that",
"is",
"beveled",
"."
] | [] | [
{
"param": "bv",
"type": "BevVert"
},
{
"param": "from_e",
"type": "EdgeHalf"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bv",
"type": "BevVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "from_e",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | count_ccw_edges_between | int | static int count_ccw_edges_between(EdgeHalf *e1, EdgeHalf *e2)
{
int cnt = 0;
EdgeHalf *e = e1;
do {
if (e == e2) {
break;
}
e = e->next;
cnt++;
} while (e != e1);
return cnt;
} | /* return count of edges between e1 and e2 when going around bv CCW */ | return count of edges between e1 and e2 when going around bv CCW | [
"return",
"count",
"of",
"edges",
"between",
"e1",
"and",
"e2",
"when",
"going",
"around",
"bv",
"CCW"
] | static int count_ccw_edges_between(EdgeHalf *e1, EdgeHalf *e2)
{
int cnt = 0;
EdgeHalf *e = e1;
do {
if (e == e2) {
break;
}
e = e->next;
cnt++;
} while (e != e1);
return cnt;
} | [
"static",
"int",
"count_ccw_edges_between",
"(",
"EdgeHalf",
"*",
"e1",
",",
"EdgeHalf",
"*",
"e2",
")",
"{",
"int",
"cnt",
"=",
"0",
";",
"EdgeHalf",
"*",
"e",
"=",
"e1",
";",
"do",
"{",
"if",
"(",
"e",
"==",
"e2",
")",
"{",
"break",
";",
"}",
"e",
"=",
"e",
"->",
"next",
";",
"cnt",
"++",
";",
"}",
"while",
"(",
"e",
"!=",
"e1",
")",
";",
"return",
"cnt",
";",
"}"
] | return count of edges between e1 and e2 when going around bv CCW | [
"return",
"count",
"of",
"edges",
"between",
"e1",
"and",
"e2",
"when",
"going",
"around",
"bv",
"CCW"
] | [] | [
{
"param": "e1",
"type": "EdgeHalf"
},
{
"param": "e2",
"type": "EdgeHalf"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "e1",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "e2",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | edges_face_connected_at_vert | bool | static bool edges_face_connected_at_vert(BMEdge *bme1, BMEdge *bme2)
{
BMLoop *l;
BMIter iter;
BM_ITER_ELEM (l, &iter, bme1, BM_LOOPS_OF_EDGE) {
if (l->prev->e == bme2 || l->next->e == bme2) {
return true;
}
}
return false;
} | /* Assume bme1 and bme2 both share some vert. Do they share a face?
* If they share a face then there is some loop around bme1 that is in a face
* where the next or previous edge in the face must be bme2. */ | Assume bme1 and bme2 both share some vert. Do they share a face.
If they share a face then there is some loop around bme1 that is in a face
where the next or previous edge in the face must be bme2. | [
"Assume",
"bme1",
"and",
"bme2",
"both",
"share",
"some",
"vert",
".",
"Do",
"they",
"share",
"a",
"face",
".",
"If",
"they",
"share",
"a",
"face",
"then",
"there",
"is",
"some",
"loop",
"around",
"bme1",
"that",
"is",
"in",
"a",
"face",
"where",
"the",
"next",
"or",
"previous",
"edge",
"in",
"the",
"face",
"must",
"be",
"bme2",
"."
] | static bool edges_face_connected_at_vert(BMEdge *bme1, BMEdge *bme2)
{
BMLoop *l;
BMIter iter;
BM_ITER_ELEM (l, &iter, bme1, BM_LOOPS_OF_EDGE) {
if (l->prev->e == bme2 || l->next->e == bme2) {
return true;
}
}
return false;
} | [
"static",
"bool",
"edges_face_connected_at_vert",
"(",
"BMEdge",
"*",
"bme1",
",",
"BMEdge",
"*",
"bme2",
")",
"{",
"BMLoop",
"*",
"l",
";",
"BMIter",
"iter",
";",
"BM_ITER_ELEM",
"(",
"l",
",",
"&",
"iter",
",",
"bme1",
",",
"BM_LOOPS_OF_EDGE",
")",
"",
"{",
"if",
"(",
"l",
"->",
"prev",
"->",
"e",
"==",
"bme2",
"||",
"l",
"->",
"next",
"->",
"e",
"==",
"bme2",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Assume bme1 and bme2 both share some vert. | [
"Assume",
"bme1",
"and",
"bme2",
"both",
"share",
"some",
"vert",
"."
] | [] | [
{
"param": "bme1",
"type": "BMEdge"
},
{
"param": "bme2",
"type": "BMEdge"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bme1",
"type": "BMEdge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bme2",
"type": "BMEdge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | boundvert_rep_face | BMFace | static BMFace *boundvert_rep_face(BoundVert *v, BMFace **r_fother)
{
BMFace *frep, *frep2;
frep2 = NULL;
if (v->ebev) {
frep = v->ebev->fprev;
if (v->efirst->fprev != frep) {
frep2 = v->efirst->fprev;
}
}
else if (v->efirst) {
frep = v->efirst->fprev;
if (frep) {
if (v->elast->fnext != frep) {
frep2 = v->elast->fnext;
}
else if (v->efirst->fnext != frep) {
frep2 = v->efirst->fnext;
}
else if (v->elast->fprev != frep) {
frep2 = v->efirst->fprev;
}
}
else if (v->efirst->fnext) {
frep = v->efirst->fnext;
if (v->elast->fnext != frep) {
frep2 = v->elast->fnext;
}
}
else if (v->elast->fprev) {
frep = v->elast->fprev;
}
}
else if (v->prev->elast) {
frep = v->prev->elast->fnext;
if (v->next->efirst) {
if (frep) {
frep2 = v->next->efirst->fprev;
}
else {
frep = v->next->efirst->fprev;
}
}
}
else {
frep = NULL;
}
if (r_fother) {
*r_fother = frep2;
}
return frep;
} | /* Return a good representative face (for materials, etc.) for faces
* created around/near BoundVert v.
* Sometimes care about a second choice, if there is one.
* If r_fother parameter is non-NULL and there is another, different,
* possible frep, return the other one in that parameter. */ | Return a good representative face (for materials, etc.) for faces
created around/near BoundVert v.
Sometimes care about a second choice, if there is one.
If r_fother parameter is non-NULL and there is another, different,
possible frep, return the other one in that parameter. | [
"Return",
"a",
"good",
"representative",
"face",
"(",
"for",
"materials",
"etc",
".",
")",
"for",
"faces",
"created",
"around",
"/",
"near",
"BoundVert",
"v",
".",
"Sometimes",
"care",
"about",
"a",
"second",
"choice",
"if",
"there",
"is",
"one",
".",
"If",
"r_fother",
"parameter",
"is",
"non",
"-",
"NULL",
"and",
"there",
"is",
"another",
"different",
"possible",
"frep",
"return",
"the",
"other",
"one",
"in",
"that",
"parameter",
"."
] | static BMFace *boundvert_rep_face(BoundVert *v, BMFace **r_fother)
{
BMFace *frep, *frep2;
frep2 = NULL;
if (v->ebev) {
frep = v->ebev->fprev;
if (v->efirst->fprev != frep) {
frep2 = v->efirst->fprev;
}
}
else if (v->efirst) {
frep = v->efirst->fprev;
if (frep) {
if (v->elast->fnext != frep) {
frep2 = v->elast->fnext;
}
else if (v->efirst->fnext != frep) {
frep2 = v->efirst->fnext;
}
else if (v->elast->fprev != frep) {
frep2 = v->efirst->fprev;
}
}
else if (v->efirst->fnext) {
frep = v->efirst->fnext;
if (v->elast->fnext != frep) {
frep2 = v->elast->fnext;
}
}
else if (v->elast->fprev) {
frep = v->elast->fprev;
}
}
else if (v->prev->elast) {
frep = v->prev->elast->fnext;
if (v->next->efirst) {
if (frep) {
frep2 = v->next->efirst->fprev;
}
else {
frep = v->next->efirst->fprev;
}
}
}
else {
frep = NULL;
}
if (r_fother) {
*r_fother = frep2;
}
return frep;
} | [
"static",
"BMFace",
"*",
"boundvert_rep_face",
"(",
"BoundVert",
"*",
"v",
",",
"BMFace",
"*",
"*",
"r_fother",
")",
"{",
"BMFace",
"*",
"frep",
",",
"*",
"frep2",
";",
"frep2",
"=",
"NULL",
";",
"if",
"(",
"v",
"->",
"ebev",
")",
"{",
"frep",
"=",
"v",
"->",
"ebev",
"->",
"fprev",
";",
"if",
"(",
"v",
"->",
"efirst",
"->",
"fprev",
"!=",
"frep",
")",
"{",
"frep2",
"=",
"v",
"->",
"efirst",
"->",
"fprev",
";",
"}",
"}",
"else",
"if",
"(",
"v",
"->",
"efirst",
")",
"{",
"frep",
"=",
"v",
"->",
"efirst",
"->",
"fprev",
";",
"if",
"(",
"frep",
")",
"{",
"if",
"(",
"v",
"->",
"elast",
"->",
"fnext",
"!=",
"frep",
")",
"{",
"frep2",
"=",
"v",
"->",
"elast",
"->",
"fnext",
";",
"}",
"else",
"if",
"(",
"v",
"->",
"efirst",
"->",
"fnext",
"!=",
"frep",
")",
"{",
"frep2",
"=",
"v",
"->",
"efirst",
"->",
"fnext",
";",
"}",
"else",
"if",
"(",
"v",
"->",
"elast",
"->",
"fprev",
"!=",
"frep",
")",
"{",
"frep2",
"=",
"v",
"->",
"efirst",
"->",
"fprev",
";",
"}",
"}",
"else",
"if",
"(",
"v",
"->",
"efirst",
"->",
"fnext",
")",
"{",
"frep",
"=",
"v",
"->",
"efirst",
"->",
"fnext",
";",
"if",
"(",
"v",
"->",
"elast",
"->",
"fnext",
"!=",
"frep",
")",
"{",
"frep2",
"=",
"v",
"->",
"elast",
"->",
"fnext",
";",
"}",
"}",
"else",
"if",
"(",
"v",
"->",
"elast",
"->",
"fprev",
")",
"{",
"frep",
"=",
"v",
"->",
"elast",
"->",
"fprev",
";",
"}",
"}",
"else",
"if",
"(",
"v",
"->",
"prev",
"->",
"elast",
")",
"{",
"frep",
"=",
"v",
"->",
"prev",
"->",
"elast",
"->",
"fnext",
";",
"if",
"(",
"v",
"->",
"next",
"->",
"efirst",
")",
"{",
"if",
"(",
"frep",
")",
"{",
"frep2",
"=",
"v",
"->",
"next",
"->",
"efirst",
"->",
"fprev",
";",
"}",
"else",
"{",
"frep",
"=",
"v",
"->",
"next",
"->",
"efirst",
"->",
"fprev",
";",
"}",
"}",
"}",
"else",
"{",
"frep",
"=",
"NULL",
";",
"}",
"if",
"(",
"r_fother",
")",
"{",
"*",
"r_fother",
"=",
"frep2",
";",
"}",
"return",
"frep",
";",
"}"
] | Return a good representative face (for materials, etc.) | [
"Return",
"a",
"good",
"representative",
"face",
"(",
"for",
"materials",
"etc",
".",
")"
] | [] | [
{
"param": "v",
"type": "BoundVert"
},
{
"param": "r_fother",
"type": "BMFace"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "v",
"type": "BoundVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r_fother",
"type": "BMFace",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | bev_create_ngon | BMFace | static BMFace *bev_create_ngon(BMesh *bm,
BMVert **vert_arr,
const int totv,
BMFace **face_arr,
BMFace *facerep,
BMEdge **edge_arr,
int mat_nr,
bool do_interp)
{
BMIter iter;
BMLoop *l;
BMFace *f, *interp_f;
BMEdge *bme;
float save_co[3];
int i;
f = BM_face_create_verts(bm, vert_arr, totv, facerep, BM_CREATE_NOP, true);
if ((facerep || (face_arr && face_arr[0])) && f) {
BM_elem_attrs_copy(bm, bm, facerep ? facerep : face_arr[0], f);
if (do_interp) {
i = 0;
BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
if (face_arr) {
/* assume loops of created face are in same order as verts */
BLI_assert(l->v == vert_arr[i]);
interp_f = face_arr[i];
}
else {
interp_f = facerep;
}
if (interp_f) {
bme = NULL;
if (edge_arr) {
bme = edge_arr[i];
}
if (bme) {
copy_v3_v3(save_co, l->v->co);
closest_to_line_segment_v3(l->v->co, save_co, bme->v1->co, bme->v2->co);
}
BM_loop_interp_from_face(bm, l, interp_f, true, true);
if (bme) {
copy_v3_v3(l->v->co, save_co);
}
}
i++;
}
}
}
/* not essential for bevels own internal logic,
* this is done so the operator can select newly created geometry */
if (f) {
BM_elem_flag_enable(f, BM_ELEM_TAG);
BM_ITER_ELEM (bme, &iter, f, BM_EDGES_OF_FACE) {
flag_out_edge(bm, bme);
}
}
if (mat_nr >= 0) {
f->mat_nr = mat_nr;
}
return f;
} | /**
* Make ngon from verts alone.
* Make sure to properly copy face attributes and do custom data interpolation from
* corresponding elements of face_arr, if that is non-NULL, else from facerep.
* If edge_arr is non-NULL, then for interpolation purposes only, the corresponding
* elements of vert_arr are snapped to any non-NULL edges in that array.
* If mat_nr >= 0 then the material of the face is set to that.
*
* \note ALL face creation goes through this function, this is important to keep!
*/ | Make ngon from verts alone.
Make sure to properly copy face attributes and do custom data interpolation from
corresponding elements of face_arr, if that is non-NULL, else from facerep.
If edge_arr is non-NULL, then for interpolation purposes only, the corresponding
elements of vert_arr are snapped to any non-NULL edges in that array.
If mat_nr >= 0 then the material of the face is set to that.
\note ALL face creation goes through this function, this is important to keep! | [
"Make",
"ngon",
"from",
"verts",
"alone",
".",
"Make",
"sure",
"to",
"properly",
"copy",
"face",
"attributes",
"and",
"do",
"custom",
"data",
"interpolation",
"from",
"corresponding",
"elements",
"of",
"face_arr",
"if",
"that",
"is",
"non",
"-",
"NULL",
"else",
"from",
"facerep",
".",
"If",
"edge_arr",
"is",
"non",
"-",
"NULL",
"then",
"for",
"interpolation",
"purposes",
"only",
"the",
"corresponding",
"elements",
"of",
"vert_arr",
"are",
"snapped",
"to",
"any",
"non",
"-",
"NULL",
"edges",
"in",
"that",
"array",
".",
"If",
"mat_nr",
">",
"=",
"0",
"then",
"the",
"material",
"of",
"the",
"face",
"is",
"set",
"to",
"that",
".",
"\\",
"note",
"ALL",
"face",
"creation",
"goes",
"through",
"this",
"function",
"this",
"is",
"important",
"to",
"keep!"
] | static BMFace *bev_create_ngon(BMesh *bm,
BMVert **vert_arr,
const int totv,
BMFace **face_arr,
BMFace *facerep,
BMEdge **edge_arr,
int mat_nr,
bool do_interp)
{
BMIter iter;
BMLoop *l;
BMFace *f, *interp_f;
BMEdge *bme;
float save_co[3];
int i;
f = BM_face_create_verts(bm, vert_arr, totv, facerep, BM_CREATE_NOP, true);
if ((facerep || (face_arr && face_arr[0])) && f) {
BM_elem_attrs_copy(bm, bm, facerep ? facerep : face_arr[0], f);
if (do_interp) {
i = 0;
BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
if (face_arr) {
BLI_assert(l->v == vert_arr[i]);
interp_f = face_arr[i];
}
else {
interp_f = facerep;
}
if (interp_f) {
bme = NULL;
if (edge_arr) {
bme = edge_arr[i];
}
if (bme) {
copy_v3_v3(save_co, l->v->co);
closest_to_line_segment_v3(l->v->co, save_co, bme->v1->co, bme->v2->co);
}
BM_loop_interp_from_face(bm, l, interp_f, true, true);
if (bme) {
copy_v3_v3(l->v->co, save_co);
}
}
i++;
}
}
}
if (f) {
BM_elem_flag_enable(f, BM_ELEM_TAG);
BM_ITER_ELEM (bme, &iter, f, BM_EDGES_OF_FACE) {
flag_out_edge(bm, bme);
}
}
if (mat_nr >= 0) {
f->mat_nr = mat_nr;
}
return f;
} | [
"static",
"BMFace",
"*",
"bev_create_ngon",
"(",
"BMesh",
"*",
"bm",
",",
"BMVert",
"*",
"*",
"vert_arr",
",",
"const",
"int",
"totv",
",",
"BMFace",
"*",
"*",
"face_arr",
",",
"BMFace",
"*",
"facerep",
",",
"BMEdge",
"*",
"*",
"edge_arr",
",",
"int",
"mat_nr",
",",
"bool",
"do_interp",
")",
"{",
"BMIter",
"iter",
";",
"BMLoop",
"*",
"l",
";",
"BMFace",
"*",
"f",
",",
"*",
"interp_f",
";",
"BMEdge",
"*",
"bme",
";",
"float",
"save_co",
"[",
"3",
"]",
";",
"int",
"i",
";",
"f",
"=",
"BM_face_create_verts",
"(",
"bm",
",",
"vert_arr",
",",
"totv",
",",
"facerep",
",",
"BM_CREATE_NOP",
",",
"true",
")",
";",
"if",
"(",
"(",
"facerep",
"||",
"(",
"face_arr",
"&&",
"face_arr",
"[",
"0",
"]",
")",
")",
"&&",
"f",
")",
"{",
"BM_elem_attrs_copy",
"(",
"bm",
",",
"bm",
",",
"facerep",
"?",
"facerep",
":",
"face_arr",
"[",
"0",
"]",
",",
"f",
")",
";",
"if",
"(",
"do_interp",
")",
"{",
"i",
"=",
"0",
";",
"BM_ITER_ELEM",
"(",
"l",
",",
"&",
"iter",
",",
"f",
",",
"BM_LOOPS_OF_FACE",
")",
"",
"{",
"if",
"(",
"face_arr",
")",
"{",
"BLI_assert",
"(",
"l",
"->",
"v",
"==",
"vert_arr",
"[",
"i",
"]",
")",
";",
"interp_f",
"=",
"face_arr",
"[",
"i",
"]",
";",
"}",
"else",
"{",
"interp_f",
"=",
"facerep",
";",
"}",
"if",
"(",
"interp_f",
")",
"{",
"bme",
"=",
"NULL",
";",
"if",
"(",
"edge_arr",
")",
"{",
"bme",
"=",
"edge_arr",
"[",
"i",
"]",
";",
"}",
"if",
"(",
"bme",
")",
"{",
"copy_v3_v3",
"(",
"save_co",
",",
"l",
"->",
"v",
"->",
"co",
")",
";",
"closest_to_line_segment_v3",
"(",
"l",
"->",
"v",
"->",
"co",
",",
"save_co",
",",
"bme",
"->",
"v1",
"->",
"co",
",",
"bme",
"->",
"v2",
"->",
"co",
")",
";",
"}",
"BM_loop_interp_from_face",
"(",
"bm",
",",
"l",
",",
"interp_f",
",",
"true",
",",
"true",
")",
";",
"if",
"(",
"bme",
")",
"{",
"copy_v3_v3",
"(",
"l",
"->",
"v",
"->",
"co",
",",
"save_co",
")",
";",
"}",
"}",
"i",
"++",
";",
"}",
"}",
"}",
"if",
"(",
"f",
")",
"{",
"BM_elem_flag_enable",
"(",
"f",
",",
"BM_ELEM_TAG",
")",
";",
"BM_ITER_ELEM",
"(",
"bme",
",",
"&",
"iter",
",",
"f",
",",
"BM_EDGES_OF_FACE",
")",
"",
"{",
"flag_out_edge",
"(",
"bm",
",",
"bme",
")",
";",
"}",
"}",
"if",
"(",
"mat_nr",
">=",
"0",
")",
"{",
"f",
"->",
"mat_nr",
"=",
"mat_nr",
";",
"}",
"return",
"f",
";",
"}"
] | Make ngon from verts alone. | [
"Make",
"ngon",
"from",
"verts",
"alone",
"."
] | [
"/* assume loops of created face are in same order as verts */",
"/* not essential for bevels own internal logic,\n * this is done so the operator can select newly created geometry */"
] | [
{
"param": "bm",
"type": "BMesh"
},
{
"param": "vert_arr",
"type": "BMVert"
},
{
"param": "totv",
"type": "int"
},
{
"param": "face_arr",
"type": "BMFace"
},
{
"param": "facerep",
"type": "BMFace"
},
{
"param": "edge_arr",
"type": "BMEdge"
},
{
"param": "mat_nr",
"type": "int"
},
{
"param": "do_interp",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bm",
"type": "BMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vert_arr",
"type": "BMVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "totv",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "face_arr",
"type": "BMFace",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "facerep",
"type": "BMFace",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "edge_arr",
"type": "BMEdge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mat_nr",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "do_interp",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | bev_merge_uvs | void | static void bev_merge_uvs(BMesh *bm, BMVert *v)
{
BMIter iter;
MLoopUV *luv;
BMLoop *l;
float uv[2];
int n;
int num_of_uv_layers = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
int i;
for (i = 0; i < num_of_uv_layers; i++) {
int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, i);
if (cd_loop_uv_offset == -1) {
return;
}
n = 0;
zero_v2(uv);
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
add_v2_v2(uv, luv->uv);
n++;
}
if (n > 1) {
mul_v2_fl(uv, 1.0f / (float)n);
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
copy_v2_v2(luv->uv, uv);
}
}
}
} | /* Merge (using average) all the UV values for loops of v's faces.
* Caller should ensure that no seams are violated by doing this. */ | Merge (using average) all the UV values for loops of v's faces.
Caller should ensure that no seams are violated by doing this. | [
"Merge",
"(",
"using",
"average",
")",
"all",
"the",
"UV",
"values",
"for",
"loops",
"of",
"v",
"'",
"s",
"faces",
".",
"Caller",
"should",
"ensure",
"that",
"no",
"seams",
"are",
"violated",
"by",
"doing",
"this",
"."
] | static void bev_merge_uvs(BMesh *bm, BMVert *v)
{
BMIter iter;
MLoopUV *luv;
BMLoop *l;
float uv[2];
int n;
int num_of_uv_layers = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
int i;
for (i = 0; i < num_of_uv_layers; i++) {
int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, i);
if (cd_loop_uv_offset == -1) {
return;
}
n = 0;
zero_v2(uv);
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
add_v2_v2(uv, luv->uv);
n++;
}
if (n > 1) {
mul_v2_fl(uv, 1.0f / (float)n);
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
copy_v2_v2(luv->uv, uv);
}
}
}
} | [
"static",
"void",
"bev_merge_uvs",
"(",
"BMesh",
"*",
"bm",
",",
"BMVert",
"*",
"v",
")",
"{",
"BMIter",
"iter",
";",
"MLoopUV",
"*",
"luv",
";",
"BMLoop",
"*",
"l",
";",
"float",
"uv",
"[",
"2",
"]",
";",
"int",
"n",
";",
"int",
"num_of_uv_layers",
"=",
"CustomData_number_of_layers",
"(",
"&",
"bm",
"->",
"ldata",
",",
"CD_MLOOPUV",
")",
";",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"num_of_uv_layers",
";",
"i",
"++",
")",
"{",
"int",
"cd_loop_uv_offset",
"=",
"CustomData_get_n_offset",
"(",
"&",
"bm",
"->",
"ldata",
",",
"CD_MLOOPUV",
",",
"i",
")",
";",
"if",
"(",
"cd_loop_uv_offset",
"==",
"-1",
")",
"{",
"return",
";",
"}",
"n",
"=",
"0",
";",
"zero_v2",
"(",
"uv",
")",
";",
"BM_ITER_ELEM",
"(",
"l",
",",
"&",
"iter",
",",
"v",
",",
"BM_LOOPS_OF_VERT",
")",
"",
"{",
"luv",
"=",
"BM_ELEM_CD_GET_VOID_P",
"(",
"l",
",",
"cd_loop_uv_offset",
")",
";",
"add_v2_v2",
"(",
"uv",
",",
"luv",
"->",
"uv",
")",
";",
"n",
"++",
";",
"}",
"if",
"(",
"n",
">",
"1",
")",
"{",
"mul_v2_fl",
"(",
"uv",
",",
"1.0f",
"/",
"(",
"float",
")",
"n",
")",
";",
"BM_ITER_ELEM",
"(",
"l",
",",
"&",
"iter",
",",
"v",
",",
"BM_LOOPS_OF_VERT",
")",
"",
"{",
"luv",
"=",
"BM_ELEM_CD_GET_VOID_P",
"(",
"l",
",",
"cd_loop_uv_offset",
")",
";",
"copy_v2_v2",
"(",
"luv",
"->",
"uv",
",",
"uv",
")",
";",
"}",
"}",
"}",
"}"
] | Merge (using average) all the UV values for loops of v's faces. | [
"Merge",
"(",
"using",
"average",
")",
"all",
"the",
"UV",
"values",
"for",
"loops",
"of",
"v",
"'",
"s",
"faces",
"."
] | [] | [
{
"param": "bm",
"type": "BMesh"
},
{
"param": "v",
"type": "BMVert"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bm",
"type": "BMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v",
"type": "BMVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | bev_merge_edge_uvs | void | static void bev_merge_edge_uvs(BMesh *bm, BMEdge *bme, BMVert *v)
{
BMIter iter;
MLoopUV *luv;
BMLoop *l, *l1, *l2;
float uv[2];
int num_of_uv_layers = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
int i;
l1 = NULL;
l2 = NULL;
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
if (l->e == bme) {
l1 = l;
}
else if (l->prev->e == bme) {
l2 = l;
}
}
if (l1 == NULL || l2 == NULL) {
return;
}
for (i = 0; i < num_of_uv_layers; i++) {
int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, i);
if (cd_loop_uv_offset == -1) {
return;
}
zero_v2(uv);
luv = BM_ELEM_CD_GET_VOID_P(l1, cd_loop_uv_offset);
add_v2_v2(uv, luv->uv);
luv = BM_ELEM_CD_GET_VOID_P(l2, cd_loop_uv_offset);
add_v2_v2(uv, luv->uv);
mul_v2_fl(uv, 0.5f);
luv = BM_ELEM_CD_GET_VOID_P(l1, cd_loop_uv_offset);
copy_v2_v2(luv->uv, uv);
luv = BM_ELEM_CD_GET_VOID_P(l2, cd_loop_uv_offset);
copy_v2_v2(luv->uv, uv);
}
} | /* Merge (using average) the UV values for two specific loops of v: those for faces containing v,
* and part of faces that share edge bme */ | Merge (using average) the UV values for two specific loops of v: those for faces containing v,
and part of faces that share edge bme | [
"Merge",
"(",
"using",
"average",
")",
"the",
"UV",
"values",
"for",
"two",
"specific",
"loops",
"of",
"v",
":",
"those",
"for",
"faces",
"containing",
"v",
"and",
"part",
"of",
"faces",
"that",
"share",
"edge",
"bme"
] | static void bev_merge_edge_uvs(BMesh *bm, BMEdge *bme, BMVert *v)
{
BMIter iter;
MLoopUV *luv;
BMLoop *l, *l1, *l2;
float uv[2];
int num_of_uv_layers = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
int i;
l1 = NULL;
l2 = NULL;
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
if (l->e == bme) {
l1 = l;
}
else if (l->prev->e == bme) {
l2 = l;
}
}
if (l1 == NULL || l2 == NULL) {
return;
}
for (i = 0; i < num_of_uv_layers; i++) {
int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, i);
if (cd_loop_uv_offset == -1) {
return;
}
zero_v2(uv);
luv = BM_ELEM_CD_GET_VOID_P(l1, cd_loop_uv_offset);
add_v2_v2(uv, luv->uv);
luv = BM_ELEM_CD_GET_VOID_P(l2, cd_loop_uv_offset);
add_v2_v2(uv, luv->uv);
mul_v2_fl(uv, 0.5f);
luv = BM_ELEM_CD_GET_VOID_P(l1, cd_loop_uv_offset);
copy_v2_v2(luv->uv, uv);
luv = BM_ELEM_CD_GET_VOID_P(l2, cd_loop_uv_offset);
copy_v2_v2(luv->uv, uv);
}
} | [
"static",
"void",
"bev_merge_edge_uvs",
"(",
"BMesh",
"*",
"bm",
",",
"BMEdge",
"*",
"bme",
",",
"BMVert",
"*",
"v",
")",
"{",
"BMIter",
"iter",
";",
"MLoopUV",
"*",
"luv",
";",
"BMLoop",
"*",
"l",
",",
"*",
"l1",
",",
"*",
"l2",
";",
"float",
"uv",
"[",
"2",
"]",
";",
"int",
"num_of_uv_layers",
"=",
"CustomData_number_of_layers",
"(",
"&",
"bm",
"->",
"ldata",
",",
"CD_MLOOPUV",
")",
";",
"int",
"i",
";",
"l1",
"=",
"NULL",
";",
"l2",
"=",
"NULL",
";",
"BM_ITER_ELEM",
"(",
"l",
",",
"&",
"iter",
",",
"v",
",",
"BM_LOOPS_OF_VERT",
")",
"",
"{",
"if",
"(",
"l",
"->",
"e",
"==",
"bme",
")",
"{",
"l1",
"=",
"l",
";",
"}",
"else",
"if",
"(",
"l",
"->",
"prev",
"->",
"e",
"==",
"bme",
")",
"{",
"l2",
"=",
"l",
";",
"}",
"}",
"if",
"(",
"l1",
"==",
"NULL",
"||",
"l2",
"==",
"NULL",
")",
"{",
"return",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"num_of_uv_layers",
";",
"i",
"++",
")",
"{",
"int",
"cd_loop_uv_offset",
"=",
"CustomData_get_n_offset",
"(",
"&",
"bm",
"->",
"ldata",
",",
"CD_MLOOPUV",
",",
"i",
")",
";",
"if",
"(",
"cd_loop_uv_offset",
"==",
"-1",
")",
"{",
"return",
";",
"}",
"zero_v2",
"(",
"uv",
")",
";",
"luv",
"=",
"BM_ELEM_CD_GET_VOID_P",
"(",
"l1",
",",
"cd_loop_uv_offset",
")",
";",
"add_v2_v2",
"(",
"uv",
",",
"luv",
"->",
"uv",
")",
";",
"luv",
"=",
"BM_ELEM_CD_GET_VOID_P",
"(",
"l2",
",",
"cd_loop_uv_offset",
")",
";",
"add_v2_v2",
"(",
"uv",
",",
"luv",
"->",
"uv",
")",
";",
"mul_v2_fl",
"(",
"uv",
",",
"0.5f",
")",
";",
"luv",
"=",
"BM_ELEM_CD_GET_VOID_P",
"(",
"l1",
",",
"cd_loop_uv_offset",
")",
";",
"copy_v2_v2",
"(",
"luv",
"->",
"uv",
",",
"uv",
")",
";",
"luv",
"=",
"BM_ELEM_CD_GET_VOID_P",
"(",
"l2",
",",
"cd_loop_uv_offset",
")",
";",
"copy_v2_v2",
"(",
"luv",
"->",
"uv",
",",
"uv",
")",
";",
"}",
"}"
] | Merge (using average) the UV values for two specific loops of v: those for faces containing v,
and part of faces that share edge bme | [
"Merge",
"(",
"using",
"average",
")",
"the",
"UV",
"values",
"for",
"two",
"specific",
"loops",
"of",
"v",
":",
"those",
"for",
"faces",
"containing",
"v",
"and",
"part",
"of",
"faces",
"that",
"share",
"edge",
"bme"
] | [] | [
{
"param": "bm",
"type": "BMesh"
},
{
"param": "bme",
"type": "BMEdge"
},
{
"param": "v",
"type": "BMVert"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bm",
"type": "BMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bme",
"type": "BMEdge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v",
"type": "BMVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | slide_dist | void | static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3])
{
float dir[3], len;
sub_v3_v3v3(dir, v->co, BM_edge_other_vert(e->e, v)->co);
len = normalize_v3(dir);
if (d > len) {
d = len - (float)(50.0 * BEVEL_EPSILON_D);
}
copy_v3_v3(slideco, v->co);
madd_v3_v3fl(slideco, dir, -d);
} | /* Calculate coordinates of a point a distance d from v on e->e and return it in slideco */ | Calculate coordinates of a point a distance d from v on e->e and return it in slideco | [
"Calculate",
"coordinates",
"of",
"a",
"point",
"a",
"distance",
"d",
"from",
"v",
"on",
"e",
"-",
">",
"e",
"and",
"return",
"it",
"in",
"slideco"
] | static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3])
{
float dir[3], len;
sub_v3_v3v3(dir, v->co, BM_edge_other_vert(e->e, v)->co);
len = normalize_v3(dir);
if (d > len) {
d = len - (float)(50.0 * BEVEL_EPSILON_D);
}
copy_v3_v3(slideco, v->co);
madd_v3_v3fl(slideco, dir, -d);
} | [
"static",
"void",
"slide_dist",
"(",
"EdgeHalf",
"*",
"e",
",",
"BMVert",
"*",
"v",
",",
"float",
"d",
",",
"float",
"slideco",
"[",
"3",
"]",
")",
"{",
"float",
"dir",
"[",
"3",
"]",
",",
"len",
";",
"sub_v3_v3v3",
"(",
"dir",
",",
"v",
"->",
"co",
",",
"BM_edge_other_vert",
"(",
"e",
"->",
"e",
",",
"v",
")",
"->",
"co",
")",
";",
"len",
"=",
"normalize_v3",
"(",
"dir",
")",
";",
"if",
"(",
"d",
">",
"len",
")",
"{",
"d",
"=",
"len",
"-",
"(",
"float",
")",
"(",
"50.0",
"*",
"BEVEL_EPSILON_D",
")",
";",
"}",
"copy_v3_v3",
"(",
"slideco",
",",
"v",
"->",
"co",
")",
";",
"madd_v3_v3fl",
"(",
"slideco",
",",
"dir",
",",
"-",
"d",
")",
";",
"}"
] | Calculate coordinates of a point a distance d from v on e->e and return it in slideco | [
"Calculate",
"coordinates",
"of",
"a",
"point",
"a",
"distance",
"d",
"from",
"v",
"on",
"e",
"-",
">",
"e",
"and",
"return",
"it",
"in",
"slideco"
] | [] | [
{
"param": "e",
"type": "EdgeHalf"
},
{
"param": "v",
"type": "BMVert"
},
{
"param": "d",
"type": "float"
},
{
"param": "slideco",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "e",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v",
"type": "BMVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "slideco",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | point_between_edges | bool | static bool point_between_edges(float co[3], BMVert *v, BMFace *f, EdgeHalf *e1, EdgeHalf *e2)
{
BMVert *v1, *v2;
float dir1[3], dir2[3], dirco[3], no[3];
float ang11, ang1co;
v1 = BM_edge_other_vert(e1->e, v);
v2 = BM_edge_other_vert(e2->e, v);
sub_v3_v3v3(dir1, v->co, v1->co);
sub_v3_v3v3(dir2, v->co, v2->co);
sub_v3_v3v3(dirco, v->co, co);
normalize_v3(dir1);
normalize_v3(dir2);
normalize_v3(dirco);
ang11 = angle_normalized_v3v3(dir1, dir2);
ang1co = angle_normalized_v3v3(dir1, dirco);
/* angles are in [0,pi]. need to compare cross product with normal to see if they are reflex */
cross_v3_v3v3(no, dir1, dir2);
if (dot_v3v3(no, f->no) < 0.0f) {
ang11 = (float)(M_PI * 2.0) - ang11;
}
cross_v3_v3v3(no, dir1, dirco);
if (dot_v3v3(no, f->no) < 0.0f) {
ang1co = (float)(M_PI * 2.0) - ang1co;
}
return (ang11 - ang1co > -BEVEL_EPSILON_ANG);
} | /* co should be approximately on the plane between e1 and e2, which share common vert v
* and common face f (which cannot be NULL).
* Is it between those edges, sweeping CCW? */ | co should be approximately on the plane between e1 and e2, which share common vert v
and common face f (which cannot be NULL). | [
"co",
"should",
"be",
"approximately",
"on",
"the",
"plane",
"between",
"e1",
"and",
"e2",
"which",
"share",
"common",
"vert",
"v",
"and",
"common",
"face",
"f",
"(",
"which",
"cannot",
"be",
"NULL",
")",
"."
] | static bool point_between_edges(float co[3], BMVert *v, BMFace *f, EdgeHalf *e1, EdgeHalf *e2)
{
BMVert *v1, *v2;
float dir1[3], dir2[3], dirco[3], no[3];
float ang11, ang1co;
v1 = BM_edge_other_vert(e1->e, v);
v2 = BM_edge_other_vert(e2->e, v);
sub_v3_v3v3(dir1, v->co, v1->co);
sub_v3_v3v3(dir2, v->co, v2->co);
sub_v3_v3v3(dirco, v->co, co);
normalize_v3(dir1);
normalize_v3(dir2);
normalize_v3(dirco);
ang11 = angle_normalized_v3v3(dir1, dir2);
ang1co = angle_normalized_v3v3(dir1, dirco);
cross_v3_v3v3(no, dir1, dir2);
if (dot_v3v3(no, f->no) < 0.0f) {
ang11 = (float)(M_PI * 2.0) - ang11;
}
cross_v3_v3v3(no, dir1, dirco);
if (dot_v3v3(no, f->no) < 0.0f) {
ang1co = (float)(M_PI * 2.0) - ang1co;
}
return (ang11 - ang1co > -BEVEL_EPSILON_ANG);
} | [
"static",
"bool",
"point_between_edges",
"(",
"float",
"co",
"[",
"3",
"]",
",",
"BMVert",
"*",
"v",
",",
"BMFace",
"*",
"f",
",",
"EdgeHalf",
"*",
"e1",
",",
"EdgeHalf",
"*",
"e2",
")",
"{",
"BMVert",
"*",
"v1",
",",
"*",
"v2",
";",
"float",
"dir1",
"[",
"3",
"]",
",",
"dir2",
"[",
"3",
"]",
",",
"dirco",
"[",
"3",
"]",
",",
"no",
"[",
"3",
"]",
";",
"float",
"ang11",
",",
"ang1co",
";",
"v1",
"=",
"BM_edge_other_vert",
"(",
"e1",
"->",
"e",
",",
"v",
")",
";",
"v2",
"=",
"BM_edge_other_vert",
"(",
"e2",
"->",
"e",
",",
"v",
")",
";",
"sub_v3_v3v3",
"(",
"dir1",
",",
"v",
"->",
"co",
",",
"v1",
"->",
"co",
")",
";",
"sub_v3_v3v3",
"(",
"dir2",
",",
"v",
"->",
"co",
",",
"v2",
"->",
"co",
")",
";",
"sub_v3_v3v3",
"(",
"dirco",
",",
"v",
"->",
"co",
",",
"co",
")",
";",
"normalize_v3",
"(",
"dir1",
")",
";",
"normalize_v3",
"(",
"dir2",
")",
";",
"normalize_v3",
"(",
"dirco",
")",
";",
"ang11",
"=",
"angle_normalized_v3v3",
"(",
"dir1",
",",
"dir2",
")",
";",
"ang1co",
"=",
"angle_normalized_v3v3",
"(",
"dir1",
",",
"dirco",
")",
";",
"cross_v3_v3v3",
"(",
"no",
",",
"dir1",
",",
"dir2",
")",
";",
"if",
"(",
"dot_v3v3",
"(",
"no",
",",
"f",
"->",
"no",
")",
"<",
"0.0f",
")",
"{",
"ang11",
"=",
"(",
"float",
")",
"(",
"M_PI",
"*",
"2.0",
")",
"-",
"ang11",
";",
"}",
"cross_v3_v3v3",
"(",
"no",
",",
"dir1",
",",
"dirco",
")",
";",
"if",
"(",
"dot_v3v3",
"(",
"no",
",",
"f",
"->",
"no",
")",
"<",
"0.0f",
")",
"{",
"ang1co",
"=",
"(",
"float",
")",
"(",
"M_PI",
"*",
"2.0",
")",
"-",
"ang1co",
";",
"}",
"return",
"(",
"ang11",
"-",
"ang1co",
">",
"-",
"BEVEL_EPSILON_ANG",
")",
";",
"}"
] | co should be approximately on the plane between e1 and e2, which share common vert v
and common face f (which cannot be NULL). | [
"co",
"should",
"be",
"approximately",
"on",
"the",
"plane",
"between",
"e1",
"and",
"e2",
"which",
"share",
"common",
"vert",
"v",
"and",
"common",
"face",
"f",
"(",
"which",
"cannot",
"be",
"NULL",
")",
"."
] | [
"/* angles are in [0,pi]. need to compare cross product with normal to see if they are reflex */"
] | [
{
"param": "co",
"type": "float"
},
{
"param": "v",
"type": "BMVert"
},
{
"param": "f",
"type": "BMFace"
},
{
"param": "e1",
"type": "EdgeHalf"
},
{
"param": "e2",
"type": "EdgeHalf"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "co",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v",
"type": "BMVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "f",
"type": "BMFace",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "e1",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "e2",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | offset_meet | void | static void offset_meet(
EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool edges_between, float meetco[3])
{
float dir1[3], dir2[3], dir1n[3], dir2p[3], norm_v[3], norm_v1[3], norm_v2[3];
float norm_perp1[3], norm_perp2[3], off1a[3], off1b[3], off2a[3], off2b[3];
float isect2[3], dropco[3], plane[4];
float ang, d;
BMVert *closer_v;
EdgeHalf *e, *e1next, *e2prev;
BMFace *ff;
int isect_kind;
/* get direction vectors for two offset lines */
sub_v3_v3v3(dir1, v->co, BM_edge_other_vert(e1->e, v)->co);
sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
if (edges_between) {
e1next = e1->next;
e2prev = e2->prev;
sub_v3_v3v3(dir1n, BM_edge_other_vert(e1next->e, v)->co, v->co);
sub_v3_v3v3(dir2p, v->co, BM_edge_other_vert(e2prev->e, v)->co);
}
else {
/* shup up 'maybe unused' warnings */
zero_v3(dir1n);
zero_v3(dir2p);
}
ang = angle_v3v3(dir1, dir2);
if (ang < BEVEL_EPSILON_ANG) {
/* special case: e1 and e2 are parallel; put offset point perp to both, from v.
* need to find a suitable plane.
* this code used to just use offset and dir1, but that makes for visible errors
* on a circle with > 200 sides, which trips this "nearly perp" code (see T61214).
* so use the average of the two, and the offset formula for angle bisector.
* if offsets are different, we're out of luck:
* use the max of the two (so get consistent looking results if the same situation
* arises elsewhere in the object but with opposite roles for e1 and e2 */
if (f) {
copy_v3_v3(norm_v, f->no);
}
else {
copy_v3_v3(norm_v, v->no);
}
add_v3_v3(dir1, dir2);
cross_v3_v3v3(norm_perp1, dir1, norm_v);
normalize_v3(norm_perp1);
copy_v3_v3(off1a, v->co);
d = max_ff(e1->offset_r, e2->offset_l);
d = d / cos(ang / 2.0f);
madd_v3_v3fl(off1a, norm_perp1, d);
copy_v3_v3(meetco, off1a);
}
else if (fabsf(ang - (float)M_PI) < BEVEL_EPSILON_ANG) {
/* special case e1 and e2 are antiparallel, so bevel is into
* a zero-area face. Just make the offset point on the
* common line, at offset distance from v. */
d = max_ff(e1->offset_r, e2->offset_l);
slide_dist(e2, v, d, meetco);
}
else {
/* Get normal to plane where meet point should be,
* using cross product instead of f->no in case f is non-planar.
* Except: sometimes locally there can be a small angle
* between dir1 and dir2 that leads to a normal that is actually almost
* perpendicular to the face normal; in this case it looks wrong to use
* the local (cross-product) normal, so use the face normal if the angle
* between dir1 and dir2 is smallish.
* If e1-v-e2 is a reflex angle (viewed from vertex normal side), need to flip.
* Use f->no to figure out which side to look at angle from, as even if
* f is non-planar, will be more accurate than vertex normal */
if (f && ang < BEVEL_SMALL_ANG) {
copy_v3_v3(norm_v1, f->no);
copy_v3_v3(norm_v2, f->no);
}
else if (!edges_between) {
cross_v3_v3v3(norm_v1, dir2, dir1);
normalize_v3(norm_v1);
if (dot_v3v3(norm_v1, f ? f->no : v->no) < 0.0f) {
negate_v3(norm_v1);
}
copy_v3_v3(norm_v2, norm_v1);
}
else {
/* separate faces; get face norms at corners for each separately */
cross_v3_v3v3(norm_v1, dir1n, dir1);
normalize_v3(norm_v1);
f = e1->fnext;
if (dot_v3v3(norm_v1, f ? f->no : v->no) < 0.0f) {
negate_v3(norm_v1);
}
cross_v3_v3v3(norm_v2, dir2, dir2p);
normalize_v3(norm_v2);
f = e2->fprev;
if (dot_v3v3(norm_v2, f ? f->no : v->no) < 0.0f) {
negate_v3(norm_v2);
}
}
/* get vectors perp to each edge, perp to norm_v, and pointing into face */
cross_v3_v3v3(norm_perp1, dir1, norm_v1);
cross_v3_v3v3(norm_perp2, dir2, norm_v2);
normalize_v3(norm_perp1);
normalize_v3(norm_perp2);
/* get points that are offset distances from each line, then another point on each line */
copy_v3_v3(off1a, v->co);
madd_v3_v3fl(off1a, norm_perp1, e1->offset_r);
add_v3_v3v3(off1b, off1a, dir1);
copy_v3_v3(off2a, v->co);
madd_v3_v3fl(off2a, norm_perp2, e2->offset_l);
add_v3_v3v3(off2b, off2a, dir2);
/* intersect the lines */
isect_kind = isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2);
if (isect_kind == 0) {
/* lines are collinear: we already tested for this, but this used a different epsilon */
copy_v3_v3(meetco, off1a); /* just to do something */
}
else {
/* The lines intersect, but is it at a reasonable place?
* One problem to check: if one of the offsets is 0, then don't
* want an intersection that is outside that edge itself.
* This can happen if angle between them is > 180 degrees,
* or if the offset amount is > the edge length*/
if (e1->offset_r == 0.0f && is_outside_edge(e1, meetco, &closer_v)) {
copy_v3_v3(meetco, closer_v->co);
}
if (e2->offset_l == 0.0f && is_outside_edge(e2, meetco, &closer_v)) {
copy_v3_v3(meetco, closer_v->co);
}
if (edges_between && e1->offset_r > 0.0f && e2->offset_l > 0.0f) {
/* Try to drop meetco to a face between e1 and e2 */
if (isect_kind == 2) {
/* lines didn't meet in 3d: get average of meetco and isect2 */
mid_v3_v3v3(meetco, meetco, isect2);
}
for (e = e1; e != e2; e = e->next) {
ff = e->fnext;
if (!ff) {
continue;
}
plane_from_point_normal_v3(plane, v->co, ff->no);
closest_to_plane_normalized_v3(dropco, plane, meetco);
if (point_between_edges(dropco, v, ff, e, e->next)) {
copy_v3_v3(meetco, dropco);
break;
}
}
}
}
}
} | /*
* Calculate the meeting point between the offset edges for e1 and e2, putting answer in meetco.
* e1 and e2 share vertex v and face f (may be NULL) and viewed from the normal side of
* the bevel vertex, e1 precedes e2 in CCW order.
* Except: if edges_between is true, there are edges between e1 and e2 in CCW order so they
* don't share a common face. We want the meeting point to be on an existing face so it
* should be dropped onto one of the intermediate faces, if possible.
* Offset edge is on right of both edges, where e1 enters v and e2 leave it.
* When offsets are equal, the new point is on the edge bisector, with length offset/sin(angle/2),
* but if the offsets are not equal (allowing for this, as bevel modifier has edge weights that may
* lead to different offsets) then meeting point can be found be intersecting offset lines.
* If making the meeting point significantly changes the left or right offset from the user spec,
* record the change in offset_l (or offset_r); later we can tell that a change has happened
* because the offset will differ from its original value in offset_l_spec (or offset_r_spec).
*/ | Calculate the meeting point between the offset edges for e1 and e2, putting answer in meetco.
e1 and e2 share vertex v and face f (may be NULL) and viewed from the normal side of
the bevel vertex, e1 precedes e2 in CCW order.
Except: if edges_between is true, there are edges between e1 and e2 in CCW order so they
don't share a common face. We want the meeting point to be on an existing face so it
should be dropped onto one of the intermediate faces, if possible.
Offset edge is on right of both edges, where e1 enters v and e2 leave it.
When offsets are equal, the new point is on the edge bisector, with length offset/sin(angle/2),
but if the offsets are not equal (allowing for this, as bevel modifier has edge weights that may
lead to different offsets) then meeting point can be found be intersecting offset lines.
If making the meeting point significantly changes the left or right offset from the user spec,
record the change in offset_l (or offset_r); later we can tell that a change has happened
because the offset will differ from its original value in offset_l_spec (or offset_r_spec). | [
"Calculate",
"the",
"meeting",
"point",
"between",
"the",
"offset",
"edges",
"for",
"e1",
"and",
"e2",
"putting",
"answer",
"in",
"meetco",
".",
"e1",
"and",
"e2",
"share",
"vertex",
"v",
"and",
"face",
"f",
"(",
"may",
"be",
"NULL",
")",
"and",
"viewed",
"from",
"the",
"normal",
"side",
"of",
"the",
"bevel",
"vertex",
"e1",
"precedes",
"e2",
"in",
"CCW",
"order",
".",
"Except",
":",
"if",
"edges_between",
"is",
"true",
"there",
"are",
"edges",
"between",
"e1",
"and",
"e2",
"in",
"CCW",
"order",
"so",
"they",
"don",
"'",
"t",
"share",
"a",
"common",
"face",
".",
"We",
"want",
"the",
"meeting",
"point",
"to",
"be",
"on",
"an",
"existing",
"face",
"so",
"it",
"should",
"be",
"dropped",
"onto",
"one",
"of",
"the",
"intermediate",
"faces",
"if",
"possible",
".",
"Offset",
"edge",
"is",
"on",
"right",
"of",
"both",
"edges",
"where",
"e1",
"enters",
"v",
"and",
"e2",
"leave",
"it",
".",
"When",
"offsets",
"are",
"equal",
"the",
"new",
"point",
"is",
"on",
"the",
"edge",
"bisector",
"with",
"length",
"offset",
"/",
"sin",
"(",
"angle",
"/",
"2",
")",
"but",
"if",
"the",
"offsets",
"are",
"not",
"equal",
"(",
"allowing",
"for",
"this",
"as",
"bevel",
"modifier",
"has",
"edge",
"weights",
"that",
"may",
"lead",
"to",
"different",
"offsets",
")",
"then",
"meeting",
"point",
"can",
"be",
"found",
"be",
"intersecting",
"offset",
"lines",
".",
"If",
"making",
"the",
"meeting",
"point",
"significantly",
"changes",
"the",
"left",
"or",
"right",
"offset",
"from",
"the",
"user",
"spec",
"record",
"the",
"change",
"in",
"offset_l",
"(",
"or",
"offset_r",
")",
";",
"later",
"we",
"can",
"tell",
"that",
"a",
"change",
"has",
"happened",
"because",
"the",
"offset",
"will",
"differ",
"from",
"its",
"original",
"value",
"in",
"offset_l_spec",
"(",
"or",
"offset_r_spec",
")",
"."
] | static void offset_meet(
EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool edges_between, float meetco[3])
{
float dir1[3], dir2[3], dir1n[3], dir2p[3], norm_v[3], norm_v1[3], norm_v2[3];
float norm_perp1[3], norm_perp2[3], off1a[3], off1b[3], off2a[3], off2b[3];
float isect2[3], dropco[3], plane[4];
float ang, d;
BMVert *closer_v;
EdgeHalf *e, *e1next, *e2prev;
BMFace *ff;
int isect_kind;
sub_v3_v3v3(dir1, v->co, BM_edge_other_vert(e1->e, v)->co);
sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
if (edges_between) {
e1next = e1->next;
e2prev = e2->prev;
sub_v3_v3v3(dir1n, BM_edge_other_vert(e1next->e, v)->co, v->co);
sub_v3_v3v3(dir2p, v->co, BM_edge_other_vert(e2prev->e, v)->co);
}
else {
zero_v3(dir1n);
zero_v3(dir2p);
}
ang = angle_v3v3(dir1, dir2);
if (ang < BEVEL_EPSILON_ANG) {
if (f) {
copy_v3_v3(norm_v, f->no);
}
else {
copy_v3_v3(norm_v, v->no);
}
add_v3_v3(dir1, dir2);
cross_v3_v3v3(norm_perp1, dir1, norm_v);
normalize_v3(norm_perp1);
copy_v3_v3(off1a, v->co);
d = max_ff(e1->offset_r, e2->offset_l);
d = d / cos(ang / 2.0f);
madd_v3_v3fl(off1a, norm_perp1, d);
copy_v3_v3(meetco, off1a);
}
else if (fabsf(ang - (float)M_PI) < BEVEL_EPSILON_ANG) {
d = max_ff(e1->offset_r, e2->offset_l);
slide_dist(e2, v, d, meetco);
}
else {
if (f && ang < BEVEL_SMALL_ANG) {
copy_v3_v3(norm_v1, f->no);
copy_v3_v3(norm_v2, f->no);
}
else if (!edges_between) {
cross_v3_v3v3(norm_v1, dir2, dir1);
normalize_v3(norm_v1);
if (dot_v3v3(norm_v1, f ? f->no : v->no) < 0.0f) {
negate_v3(norm_v1);
}
copy_v3_v3(norm_v2, norm_v1);
}
else {
cross_v3_v3v3(norm_v1, dir1n, dir1);
normalize_v3(norm_v1);
f = e1->fnext;
if (dot_v3v3(norm_v1, f ? f->no : v->no) < 0.0f) {
negate_v3(norm_v1);
}
cross_v3_v3v3(norm_v2, dir2, dir2p);
normalize_v3(norm_v2);
f = e2->fprev;
if (dot_v3v3(norm_v2, f ? f->no : v->no) < 0.0f) {
negate_v3(norm_v2);
}
}
cross_v3_v3v3(norm_perp1, dir1, norm_v1);
cross_v3_v3v3(norm_perp2, dir2, norm_v2);
normalize_v3(norm_perp1);
normalize_v3(norm_perp2);
copy_v3_v3(off1a, v->co);
madd_v3_v3fl(off1a, norm_perp1, e1->offset_r);
add_v3_v3v3(off1b, off1a, dir1);
copy_v3_v3(off2a, v->co);
madd_v3_v3fl(off2a, norm_perp2, e2->offset_l);
add_v3_v3v3(off2b, off2a, dir2);
isect_kind = isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2);
if (isect_kind == 0) {
copy_v3_v3(meetco, off1a);
}
else {
if (e1->offset_r == 0.0f && is_outside_edge(e1, meetco, &closer_v)) {
copy_v3_v3(meetco, closer_v->co);
}
if (e2->offset_l == 0.0f && is_outside_edge(e2, meetco, &closer_v)) {
copy_v3_v3(meetco, closer_v->co);
}
if (edges_between && e1->offset_r > 0.0f && e2->offset_l > 0.0f) {
if (isect_kind == 2) {
mid_v3_v3v3(meetco, meetco, isect2);
}
for (e = e1; e != e2; e = e->next) {
ff = e->fnext;
if (!ff) {
continue;
}
plane_from_point_normal_v3(plane, v->co, ff->no);
closest_to_plane_normalized_v3(dropco, plane, meetco);
if (point_between_edges(dropco, v, ff, e, e->next)) {
copy_v3_v3(meetco, dropco);
break;
}
}
}
}
}
} | [
"static",
"void",
"offset_meet",
"(",
"EdgeHalf",
"*",
"e1",
",",
"EdgeHalf",
"*",
"e2",
",",
"BMVert",
"*",
"v",
",",
"BMFace",
"*",
"f",
",",
"bool",
"edges_between",
",",
"float",
"meetco",
"[",
"3",
"]",
")",
"{",
"float",
"dir1",
"[",
"3",
"]",
",",
"dir2",
"[",
"3",
"]",
",",
"dir1n",
"[",
"3",
"]",
",",
"dir2p",
"[",
"3",
"]",
",",
"norm_v",
"[",
"3",
"]",
",",
"norm_v1",
"[",
"3",
"]",
",",
"norm_v2",
"[",
"3",
"]",
";",
"float",
"norm_perp1",
"[",
"3",
"]",
",",
"norm_perp2",
"[",
"3",
"]",
",",
"off1a",
"[",
"3",
"]",
",",
"off1b",
"[",
"3",
"]",
",",
"off2a",
"[",
"3",
"]",
",",
"off2b",
"[",
"3",
"]",
";",
"float",
"isect2",
"[",
"3",
"]",
",",
"dropco",
"[",
"3",
"]",
",",
"plane",
"[",
"4",
"]",
";",
"float",
"ang",
",",
"d",
";",
"BMVert",
"*",
"closer_v",
";",
"EdgeHalf",
"*",
"e",
",",
"*",
"e1next",
",",
"*",
"e2prev",
";",
"BMFace",
"*",
"ff",
";",
"int",
"isect_kind",
";",
"sub_v3_v3v3",
"(",
"dir1",
",",
"v",
"->",
"co",
",",
"BM_edge_other_vert",
"(",
"e1",
"->",
"e",
",",
"v",
")",
"->",
"co",
")",
";",
"sub_v3_v3v3",
"(",
"dir2",
",",
"BM_edge_other_vert",
"(",
"e2",
"->",
"e",
",",
"v",
")",
"->",
"co",
",",
"v",
"->",
"co",
")",
";",
"if",
"(",
"edges_between",
")",
"{",
"e1next",
"=",
"e1",
"->",
"next",
";",
"e2prev",
"=",
"e2",
"->",
"prev",
";",
"sub_v3_v3v3",
"(",
"dir1n",
",",
"BM_edge_other_vert",
"(",
"e1next",
"->",
"e",
",",
"v",
")",
"->",
"co",
",",
"v",
"->",
"co",
")",
";",
"sub_v3_v3v3",
"(",
"dir2p",
",",
"v",
"->",
"co",
",",
"BM_edge_other_vert",
"(",
"e2prev",
"->",
"e",
",",
"v",
")",
"->",
"co",
")",
";",
"}",
"else",
"{",
"zero_v3",
"(",
"dir1n",
")",
";",
"zero_v3",
"(",
"dir2p",
")",
";",
"}",
"ang",
"=",
"angle_v3v3",
"(",
"dir1",
",",
"dir2",
")",
";",
"if",
"(",
"ang",
"<",
"BEVEL_EPSILON_ANG",
")",
"{",
"if",
"(",
"f",
")",
"{",
"copy_v3_v3",
"(",
"norm_v",
",",
"f",
"->",
"no",
")",
";",
"}",
"else",
"{",
"copy_v3_v3",
"(",
"norm_v",
",",
"v",
"->",
"no",
")",
";",
"}",
"add_v3_v3",
"(",
"dir1",
",",
"dir2",
")",
";",
"cross_v3_v3v3",
"(",
"norm_perp1",
",",
"dir1",
",",
"norm_v",
")",
";",
"normalize_v3",
"(",
"norm_perp1",
")",
";",
"copy_v3_v3",
"(",
"off1a",
",",
"v",
"->",
"co",
")",
";",
"d",
"=",
"max_ff",
"(",
"e1",
"->",
"offset_r",
",",
"e2",
"->",
"offset_l",
")",
";",
"d",
"=",
"d",
"/",
"cos",
"(",
"ang",
"/",
"2.0f",
")",
";",
"madd_v3_v3fl",
"(",
"off1a",
",",
"norm_perp1",
",",
"d",
")",
";",
"copy_v3_v3",
"(",
"meetco",
",",
"off1a",
")",
";",
"}",
"else",
"if",
"(",
"fabsf",
"(",
"ang",
"-",
"(",
"float",
")",
"M_PI",
")",
"<",
"BEVEL_EPSILON_ANG",
")",
"{",
"d",
"=",
"max_ff",
"(",
"e1",
"->",
"offset_r",
",",
"e2",
"->",
"offset_l",
")",
";",
"slide_dist",
"(",
"e2",
",",
"v",
",",
"d",
",",
"meetco",
")",
";",
"}",
"else",
"{",
"if",
"(",
"f",
"&&",
"ang",
"<",
"BEVEL_SMALL_ANG",
")",
"{",
"copy_v3_v3",
"(",
"norm_v1",
",",
"f",
"->",
"no",
")",
";",
"copy_v3_v3",
"(",
"norm_v2",
",",
"f",
"->",
"no",
")",
";",
"}",
"else",
"if",
"(",
"!",
"edges_between",
")",
"{",
"cross_v3_v3v3",
"(",
"norm_v1",
",",
"dir2",
",",
"dir1",
")",
";",
"normalize_v3",
"(",
"norm_v1",
")",
";",
"if",
"(",
"dot_v3v3",
"(",
"norm_v1",
",",
"f",
"?",
"f",
"->",
"no",
":",
"v",
"->",
"no",
")",
"<",
"0.0f",
")",
"{",
"negate_v3",
"(",
"norm_v1",
")",
";",
"}",
"copy_v3_v3",
"(",
"norm_v2",
",",
"norm_v1",
")",
";",
"}",
"else",
"{",
"cross_v3_v3v3",
"(",
"norm_v1",
",",
"dir1n",
",",
"dir1",
")",
";",
"normalize_v3",
"(",
"norm_v1",
")",
";",
"f",
"=",
"e1",
"->",
"fnext",
";",
"if",
"(",
"dot_v3v3",
"(",
"norm_v1",
",",
"f",
"?",
"f",
"->",
"no",
":",
"v",
"->",
"no",
")",
"<",
"0.0f",
")",
"{",
"negate_v3",
"(",
"norm_v1",
")",
";",
"}",
"cross_v3_v3v3",
"(",
"norm_v2",
",",
"dir2",
",",
"dir2p",
")",
";",
"normalize_v3",
"(",
"norm_v2",
")",
";",
"f",
"=",
"e2",
"->",
"fprev",
";",
"if",
"(",
"dot_v3v3",
"(",
"norm_v2",
",",
"f",
"?",
"f",
"->",
"no",
":",
"v",
"->",
"no",
")",
"<",
"0.0f",
")",
"{",
"negate_v3",
"(",
"norm_v2",
")",
";",
"}",
"}",
"cross_v3_v3v3",
"(",
"norm_perp1",
",",
"dir1",
",",
"norm_v1",
")",
";",
"cross_v3_v3v3",
"(",
"norm_perp2",
",",
"dir2",
",",
"norm_v2",
")",
";",
"normalize_v3",
"(",
"norm_perp1",
")",
";",
"normalize_v3",
"(",
"norm_perp2",
")",
";",
"copy_v3_v3",
"(",
"off1a",
",",
"v",
"->",
"co",
")",
";",
"madd_v3_v3fl",
"(",
"off1a",
",",
"norm_perp1",
",",
"e1",
"->",
"offset_r",
")",
";",
"add_v3_v3v3",
"(",
"off1b",
",",
"off1a",
",",
"dir1",
")",
";",
"copy_v3_v3",
"(",
"off2a",
",",
"v",
"->",
"co",
")",
";",
"madd_v3_v3fl",
"(",
"off2a",
",",
"norm_perp2",
",",
"e2",
"->",
"offset_l",
")",
";",
"add_v3_v3v3",
"(",
"off2b",
",",
"off2a",
",",
"dir2",
")",
";",
"isect_kind",
"=",
"isect_line_line_v3",
"(",
"off1a",
",",
"off1b",
",",
"off2a",
",",
"off2b",
",",
"meetco",
",",
"isect2",
")",
";",
"if",
"(",
"isect_kind",
"==",
"0",
")",
"{",
"copy_v3_v3",
"(",
"meetco",
",",
"off1a",
")",
";",
"}",
"else",
"{",
"if",
"(",
"e1",
"->",
"offset_r",
"==",
"0.0f",
"&&",
"is_outside_edge",
"(",
"e1",
",",
"meetco",
",",
"&",
"closer_v",
")",
")",
"{",
"copy_v3_v3",
"(",
"meetco",
",",
"closer_v",
"->",
"co",
")",
";",
"}",
"if",
"(",
"e2",
"->",
"offset_l",
"==",
"0.0f",
"&&",
"is_outside_edge",
"(",
"e2",
",",
"meetco",
",",
"&",
"closer_v",
")",
")",
"{",
"copy_v3_v3",
"(",
"meetco",
",",
"closer_v",
"->",
"co",
")",
";",
"}",
"if",
"(",
"edges_between",
"&&",
"e1",
"->",
"offset_r",
">",
"0.0f",
"&&",
"e2",
"->",
"offset_l",
">",
"0.0f",
")",
"{",
"if",
"(",
"isect_kind",
"==",
"2",
")",
"{",
"mid_v3_v3v3",
"(",
"meetco",
",",
"meetco",
",",
"isect2",
")",
";",
"}",
"for",
"(",
"e",
"=",
"e1",
";",
"e",
"!=",
"e2",
";",
"e",
"=",
"e",
"->",
"next",
")",
"{",
"ff",
"=",
"e",
"->",
"fnext",
";",
"if",
"(",
"!",
"ff",
")",
"{",
"continue",
";",
"}",
"plane_from_point_normal_v3",
"(",
"plane",
",",
"v",
"->",
"co",
",",
"ff",
"->",
"no",
")",
";",
"closest_to_plane_normalized_v3",
"(",
"dropco",
",",
"plane",
",",
"meetco",
")",
";",
"if",
"(",
"point_between_edges",
"(",
"dropco",
",",
"v",
",",
"ff",
",",
"e",
",",
"e",
"->",
"next",
")",
")",
"{",
"copy_v3_v3",
"(",
"meetco",
",",
"dropco",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] | Calculate the meeting point between the offset edges for e1 and e2, putting answer in meetco. | [
"Calculate",
"the",
"meeting",
"point",
"between",
"the",
"offset",
"edges",
"for",
"e1",
"and",
"e2",
"putting",
"answer",
"in",
"meetco",
"."
] | [
"/* get direction vectors for two offset lines */",
"/* shup up 'maybe unused' warnings */",
"/* special case: e1 and e2 are parallel; put offset point perp to both, from v.\n * need to find a suitable plane.\n * this code used to just use offset and dir1, but that makes for visible errors\n * on a circle with > 200 sides, which trips this \"nearly perp\" code (see T61214).\n * so use the average of the two, and the offset formula for angle bisector.\n * if offsets are different, we're out of luck:\n * use the max of the two (so get consistent looking results if the same situation\n * arises elsewhere in the object but with opposite roles for e1 and e2 */",
"/* special case e1 and e2 are antiparallel, so bevel is into\n * a zero-area face. Just make the offset point on the\n * common line, at offset distance from v. */",
"/* Get normal to plane where meet point should be,\n * using cross product instead of f->no in case f is non-planar.\n * Except: sometimes locally there can be a small angle\n * between dir1 and dir2 that leads to a normal that is actually almost\n * perpendicular to the face normal; in this case it looks wrong to use\n * the local (cross-product) normal, so use the face normal if the angle\n * between dir1 and dir2 is smallish.\n * If e1-v-e2 is a reflex angle (viewed from vertex normal side), need to flip.\n * Use f->no to figure out which side to look at angle from, as even if\n * f is non-planar, will be more accurate than vertex normal */",
"/* separate faces; get face norms at corners for each separately */",
"/* get vectors perp to each edge, perp to norm_v, and pointing into face */",
"/* get points that are offset distances from each line, then another point on each line */",
"/* intersect the lines */",
"/* lines are collinear: we already tested for this, but this used a different epsilon */",
"/* just to do something */",
"/* The lines intersect, but is it at a reasonable place?\n * One problem to check: if one of the offsets is 0, then don't\n * want an intersection that is outside that edge itself.\n * This can happen if angle between them is > 180 degrees,\n * or if the offset amount is > the edge length*/",
"/* Try to drop meetco to a face between e1 and e2 */",
"/* lines didn't meet in 3d: get average of meetco and isect2 */"
] | [
{
"param": "e1",
"type": "EdgeHalf"
},
{
"param": "e2",
"type": "EdgeHalf"
},
{
"param": "v",
"type": "BMVert"
},
{
"param": "f",
"type": "BMFace"
},
{
"param": "edges_between",
"type": "bool"
},
{
"param": "meetco",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "e1",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "e2",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v",
"type": "BMVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "f",
"type": "BMFace",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "edges_between",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "meetco",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | offset_meet_edge | bool | static bool offset_meet_edge(
EdgeHalf *e1, EdgeHalf *e2, BMVert *v, float meetco[3], float *r_angle)
{
float dir1[3], dir2[3], fno[3], ang, sinang;
sub_v3_v3v3(dir1, BM_edge_other_vert(e1->e, v)->co, v->co);
sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
normalize_v3(dir1);
normalize_v3(dir2);
/* find angle from dir1 to dir2 as viewed from vertex normal side */
ang = angle_normalized_v3v3(dir1, dir2);
if (fabsf(ang) < BEVEL_GOOD_ANGLE) {
if (r_angle) {
*r_angle = 0.0f;
}
return false;
}
cross_v3_v3v3(fno, dir1, dir2);
if (dot_v3v3(fno, v->no) < 0.0f) {
ang = 2.0f * (float)M_PI - ang; /* angle is reflex */
if (r_angle) {
*r_angle = ang;
}
return false;
}
if (r_angle) {
*r_angle = ang;
}
if (fabsf(ang - (float)M_PI) < BEVEL_GOOD_ANGLE) {
return false;
}
sinang = sinf(ang);
copy_v3_v3(meetco, v->co);
if (e1->offset_r == 0.0f) {
madd_v3_v3fl(meetco, dir1, e2->offset_l / sinang);
}
else {
madd_v3_v3fl(meetco, dir2, e1->offset_r / sinang);
}
return true;
} | /* Calculate the meeting point between e1 and e2 (one of which should have zero offsets),
* where e1 precedes e2 in CCW order around their common vertex v (viewed from normal side).
* If r_angle is provided, return the angle between e and emeet in *r_angle.
* If the angle is 0, or it is 180 degrees or larger, there will be no meeting point;
* return false in that case, else true. */ | Calculate the meeting point between e1 and e2 (one of which should have zero offsets),
where e1 precedes e2 in CCW order around their common vertex v (viewed from normal side).
If r_angle is provided, return the angle between e and emeet in *r_angle.
If the angle is 0, or it is 180 degrees or larger, there will be no meeting point;
return false in that case, else true. | [
"Calculate",
"the",
"meeting",
"point",
"between",
"e1",
"and",
"e2",
"(",
"one",
"of",
"which",
"should",
"have",
"zero",
"offsets",
")",
"where",
"e1",
"precedes",
"e2",
"in",
"CCW",
"order",
"around",
"their",
"common",
"vertex",
"v",
"(",
"viewed",
"from",
"normal",
"side",
")",
".",
"If",
"r_angle",
"is",
"provided",
"return",
"the",
"angle",
"between",
"e",
"and",
"emeet",
"in",
"*",
"r_angle",
".",
"If",
"the",
"angle",
"is",
"0",
"or",
"it",
"is",
"180",
"degrees",
"or",
"larger",
"there",
"will",
"be",
"no",
"meeting",
"point",
";",
"return",
"false",
"in",
"that",
"case",
"else",
"true",
"."
] | static bool offset_meet_edge(
EdgeHalf *e1, EdgeHalf *e2, BMVert *v, float meetco[3], float *r_angle)
{
float dir1[3], dir2[3], fno[3], ang, sinang;
sub_v3_v3v3(dir1, BM_edge_other_vert(e1->e, v)->co, v->co);
sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
normalize_v3(dir1);
normalize_v3(dir2);
ang = angle_normalized_v3v3(dir1, dir2);
if (fabsf(ang) < BEVEL_GOOD_ANGLE) {
if (r_angle) {
*r_angle = 0.0f;
}
return false;
}
cross_v3_v3v3(fno, dir1, dir2);
if (dot_v3v3(fno, v->no) < 0.0f) {
ang = 2.0f * (float)M_PI - ang;
if (r_angle) {
*r_angle = ang;
}
return false;
}
if (r_angle) {
*r_angle = ang;
}
if (fabsf(ang - (float)M_PI) < BEVEL_GOOD_ANGLE) {
return false;
}
sinang = sinf(ang);
copy_v3_v3(meetco, v->co);
if (e1->offset_r == 0.0f) {
madd_v3_v3fl(meetco, dir1, e2->offset_l / sinang);
}
else {
madd_v3_v3fl(meetco, dir2, e1->offset_r / sinang);
}
return true;
} | [
"static",
"bool",
"offset_meet_edge",
"(",
"EdgeHalf",
"*",
"e1",
",",
"EdgeHalf",
"*",
"e2",
",",
"BMVert",
"*",
"v",
",",
"float",
"meetco",
"[",
"3",
"]",
",",
"float",
"*",
"r_angle",
")",
"{",
"float",
"dir1",
"[",
"3",
"]",
",",
"dir2",
"[",
"3",
"]",
",",
"fno",
"[",
"3",
"]",
",",
"ang",
",",
"sinang",
";",
"sub_v3_v3v3",
"(",
"dir1",
",",
"BM_edge_other_vert",
"(",
"e1",
"->",
"e",
",",
"v",
")",
"->",
"co",
",",
"v",
"->",
"co",
")",
";",
"sub_v3_v3v3",
"(",
"dir2",
",",
"BM_edge_other_vert",
"(",
"e2",
"->",
"e",
",",
"v",
")",
"->",
"co",
",",
"v",
"->",
"co",
")",
";",
"normalize_v3",
"(",
"dir1",
")",
";",
"normalize_v3",
"(",
"dir2",
")",
";",
"ang",
"=",
"angle_normalized_v3v3",
"(",
"dir1",
",",
"dir2",
")",
";",
"if",
"(",
"fabsf",
"(",
"ang",
")",
"<",
"BEVEL_GOOD_ANGLE",
")",
"{",
"if",
"(",
"r_angle",
")",
"{",
"*",
"r_angle",
"=",
"0.0f",
";",
"}",
"return",
"false",
";",
"}",
"cross_v3_v3v3",
"(",
"fno",
",",
"dir1",
",",
"dir2",
")",
";",
"if",
"(",
"dot_v3v3",
"(",
"fno",
",",
"v",
"->",
"no",
")",
"<",
"0.0f",
")",
"{",
"ang",
"=",
"2.0f",
"*",
"(",
"float",
")",
"M_PI",
"-",
"ang",
";",
"if",
"(",
"r_angle",
")",
"{",
"*",
"r_angle",
"=",
"ang",
";",
"}",
"return",
"false",
";",
"}",
"if",
"(",
"r_angle",
")",
"{",
"*",
"r_angle",
"=",
"ang",
";",
"}",
"if",
"(",
"fabsf",
"(",
"ang",
"-",
"(",
"float",
")",
"M_PI",
")",
"<",
"BEVEL_GOOD_ANGLE",
")",
"{",
"return",
"false",
";",
"}",
"sinang",
"=",
"sinf",
"(",
"ang",
")",
";",
"copy_v3_v3",
"(",
"meetco",
",",
"v",
"->",
"co",
")",
";",
"if",
"(",
"e1",
"->",
"offset_r",
"==",
"0.0f",
")",
"{",
"madd_v3_v3fl",
"(",
"meetco",
",",
"dir1",
",",
"e2",
"->",
"offset_l",
"/",
"sinang",
")",
";",
"}",
"else",
"{",
"madd_v3_v3fl",
"(",
"meetco",
",",
"dir2",
",",
"e1",
"->",
"offset_r",
"/",
"sinang",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Calculate the meeting point between e1 and e2 (one of which should have zero offsets),
where e1 precedes e2 in CCW order around their common vertex v (viewed from normal side). | [
"Calculate",
"the",
"meeting",
"point",
"between",
"e1",
"and",
"e2",
"(",
"one",
"of",
"which",
"should",
"have",
"zero",
"offsets",
")",
"where",
"e1",
"precedes",
"e2",
"in",
"CCW",
"order",
"around",
"their",
"common",
"vertex",
"v",
"(",
"viewed",
"from",
"normal",
"side",
")",
"."
] | [
"/* find angle from dir1 to dir2 as viewed from vertex normal side */",
"/* angle is reflex */"
] | [
{
"param": "e1",
"type": "EdgeHalf"
},
{
"param": "e2",
"type": "EdgeHalf"
},
{
"param": "v",
"type": "BMVert"
},
{
"param": "meetco",
"type": "float"
},
{
"param": "r_angle",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "e1",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "e2",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v",
"type": "BMVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "meetco",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r_angle",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | good_offset_on_edge_between | bool | static bool good_offset_on_edge_between(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, BMVert *v)
{
float ang;
float meet[3];
return offset_meet_edge(e1, emid, v, meet, &ang) && offset_meet_edge(emid, e2, v, meet, &ang);
} | /* Return true if it will look good to put the meeting point where offset_on_edge_between
* would put it. This means that neither side sees a reflex angle */ | Return true if it will look good to put the meeting point where offset_on_edge_between
would put it. This means that neither side sees a reflex angle | [
"Return",
"true",
"if",
"it",
"will",
"look",
"good",
"to",
"put",
"the",
"meeting",
"point",
"where",
"offset_on_edge_between",
"would",
"put",
"it",
".",
"This",
"means",
"that",
"neither",
"side",
"sees",
"a",
"reflex",
"angle"
] | static bool good_offset_on_edge_between(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, BMVert *v)
{
float ang;
float meet[3];
return offset_meet_edge(e1, emid, v, meet, &ang) && offset_meet_edge(emid, e2, v, meet, &ang);
} | [
"static",
"bool",
"good_offset_on_edge_between",
"(",
"EdgeHalf",
"*",
"e1",
",",
"EdgeHalf",
"*",
"e2",
",",
"EdgeHalf",
"*",
"emid",
",",
"BMVert",
"*",
"v",
")",
"{",
"float",
"ang",
";",
"float",
"meet",
"[",
"3",
"]",
";",
"return",
"offset_meet_edge",
"(",
"e1",
",",
"emid",
",",
"v",
",",
"meet",
",",
"&",
"ang",
")",
"&&",
"offset_meet_edge",
"(",
"emid",
",",
"e2",
",",
"v",
",",
"meet",
",",
"&",
"ang",
")",
";",
"}"
] | Return true if it will look good to put the meeting point where offset_on_edge_between
would put it. | [
"Return",
"true",
"if",
"it",
"will",
"look",
"good",
"to",
"put",
"the",
"meeting",
"point",
"where",
"offset_on_edge_between",
"would",
"put",
"it",
"."
] | [] | [
{
"param": "e1",
"type": "EdgeHalf"
},
{
"param": "e2",
"type": "EdgeHalf"
},
{
"param": "emid",
"type": "EdgeHalf"
},
{
"param": "v",
"type": "BMVert"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "e1",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "e2",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "emid",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v",
"type": "BMVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | offset_on_edge_between | bool | static bool offset_on_edge_between(
EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, BMVert *v, float meetco[3], float *r_sinratio)
{
float ang1, ang2;
float meet1[3], meet2[3];
bool ok1, ok2;
bool retval = false;
BLI_assert(e1->is_bev && e2->is_bev && !emid->is_bev);
ok1 = offset_meet_edge(e1, emid, v, meet1, &ang1);
ok2 = offset_meet_edge(emid, e2, v, meet2, &ang2);
if (ok1 && ok2) {
mid_v3_v3v3(meetco, meet1, meet2);
if (r_sinratio) {
/* ang1 should not be 0, but be paranoid */
*r_sinratio = (ang1 == 0.0f) ? 1.0f : sinf(ang2) / sinf(ang1);
}
retval = true;
}
else if (ok1 && !ok2) {
copy_v3_v3(meetco, meet1);
}
else if (!ok1 && ok2) {
copy_v3_v3(meetco, meet2);
}
else {
/* Neither offset line met emid.
* This should only happen if all three lines are on top of each other */
slide_dist(emid, v, e1->offset_r, meetco);
}
return retval;
} | /* Calculate the best place for a meeting point for the offsets from edges e1 and e2
* on the in-between edge emid. Viewed from the vertex normal side, the CCW
* order of these edges is e1, emid, e2.
* Return true if we placed meetco as compromise between where two edges met.
* If we did, put ration of sines of angles in *r_sinratio too */ | Calculate the best place for a meeting point for the offsets from edges e1 and e2
on the in-between edge emid. Viewed from the vertex normal side, the CCW
order of these edges is e1, emid, e2.
Return true if we placed meetco as compromise between where two edges met.
If we did, put ration of sines of angles in *r_sinratio too | [
"Calculate",
"the",
"best",
"place",
"for",
"a",
"meeting",
"point",
"for",
"the",
"offsets",
"from",
"edges",
"e1",
"and",
"e2",
"on",
"the",
"in",
"-",
"between",
"edge",
"emid",
".",
"Viewed",
"from",
"the",
"vertex",
"normal",
"side",
"the",
"CCW",
"order",
"of",
"these",
"edges",
"is",
"e1",
"emid",
"e2",
".",
"Return",
"true",
"if",
"we",
"placed",
"meetco",
"as",
"compromise",
"between",
"where",
"two",
"edges",
"met",
".",
"If",
"we",
"did",
"put",
"ration",
"of",
"sines",
"of",
"angles",
"in",
"*",
"r_sinratio",
"too"
] | static bool offset_on_edge_between(
EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, BMVert *v, float meetco[3], float *r_sinratio)
{
float ang1, ang2;
float meet1[3], meet2[3];
bool ok1, ok2;
bool retval = false;
BLI_assert(e1->is_bev && e2->is_bev && !emid->is_bev);
ok1 = offset_meet_edge(e1, emid, v, meet1, &ang1);
ok2 = offset_meet_edge(emid, e2, v, meet2, &ang2);
if (ok1 && ok2) {
mid_v3_v3v3(meetco, meet1, meet2);
if (r_sinratio) {
*r_sinratio = (ang1 == 0.0f) ? 1.0f : sinf(ang2) / sinf(ang1);
}
retval = true;
}
else if (ok1 && !ok2) {
copy_v3_v3(meetco, meet1);
}
else if (!ok1 && ok2) {
copy_v3_v3(meetco, meet2);
}
else {
slide_dist(emid, v, e1->offset_r, meetco);
}
return retval;
} | [
"static",
"bool",
"offset_on_edge_between",
"(",
"EdgeHalf",
"*",
"e1",
",",
"EdgeHalf",
"*",
"e2",
",",
"EdgeHalf",
"*",
"emid",
",",
"BMVert",
"*",
"v",
",",
"float",
"meetco",
"[",
"3",
"]",
",",
"float",
"*",
"r_sinratio",
")",
"{",
"float",
"ang1",
",",
"ang2",
";",
"float",
"meet1",
"[",
"3",
"]",
",",
"meet2",
"[",
"3",
"]",
";",
"bool",
"ok1",
",",
"ok2",
";",
"bool",
"retval",
"=",
"false",
";",
"BLI_assert",
"(",
"e1",
"->",
"is_bev",
"&&",
"e2",
"->",
"is_bev",
"&&",
"!",
"emid",
"->",
"is_bev",
")",
";",
"ok1",
"=",
"offset_meet_edge",
"(",
"e1",
",",
"emid",
",",
"v",
",",
"meet1",
",",
"&",
"ang1",
")",
";",
"ok2",
"=",
"offset_meet_edge",
"(",
"emid",
",",
"e2",
",",
"v",
",",
"meet2",
",",
"&",
"ang2",
")",
";",
"if",
"(",
"ok1",
"&&",
"ok2",
")",
"{",
"mid_v3_v3v3",
"(",
"meetco",
",",
"meet1",
",",
"meet2",
")",
";",
"if",
"(",
"r_sinratio",
")",
"{",
"*",
"r_sinratio",
"=",
"(",
"ang1",
"==",
"0.0f",
")",
"?",
"1.0f",
":",
"sinf",
"(",
"ang2",
")",
"/",
"sinf",
"(",
"ang1",
")",
";",
"}",
"retval",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"ok1",
"&&",
"!",
"ok2",
")",
"{",
"copy_v3_v3",
"(",
"meetco",
",",
"meet1",
")",
";",
"}",
"else",
"if",
"(",
"!",
"ok1",
"&&",
"ok2",
")",
"{",
"copy_v3_v3",
"(",
"meetco",
",",
"meet2",
")",
";",
"}",
"else",
"{",
"slide_dist",
"(",
"emid",
",",
"v",
",",
"e1",
"->",
"offset_r",
",",
"meetco",
")",
";",
"}",
"return",
"retval",
";",
"}"
] | Calculate the best place for a meeting point for the offsets from edges e1 and e2
on the in-between edge emid. | [
"Calculate",
"the",
"best",
"place",
"for",
"a",
"meeting",
"point",
"for",
"the",
"offsets",
"from",
"edges",
"e1",
"and",
"e2",
"on",
"the",
"in",
"-",
"between",
"edge",
"emid",
"."
] | [
"/* ang1 should not be 0, but be paranoid */",
"/* Neither offset line met emid.\n * This should only happen if all three lines are on top of each other */"
] | [
{
"param": "e1",
"type": "EdgeHalf"
},
{
"param": "e2",
"type": "EdgeHalf"
},
{
"param": "emid",
"type": "EdgeHalf"
},
{
"param": "v",
"type": "BMVert"
},
{
"param": "meetco",
"type": "float"
},
{
"param": "r_sinratio",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "e1",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "e2",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "emid",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v",
"type": "BMVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "meetco",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r_sinratio",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | offset_in_plane | void | static void offset_in_plane(EdgeHalf *e, const float plane_no[3], bool left, float r[3])
{
float dir[3], no[3], fdir[3];
BMVert *v;
v = e->is_rev ? e->e->v2 : e->e->v1;
sub_v3_v3v3(dir, BM_edge_other_vert(e->e, v)->co, v->co);
normalize_v3(dir);
if (plane_no) {
copy_v3_v3(no, plane_no);
}
else {
zero_v3(no);
if (fabsf(dir[0]) < fabsf(dir[1])) {
no[0] = 1.0f;
}
else {
no[1] = 1.0f;
}
}
if (left) {
cross_v3_v3v3(fdir, dir, no);
}
else {
cross_v3_v3v3(fdir, no, dir);
}
normalize_v3(fdir);
copy_v3_v3(r, v->co);
madd_v3_v3fl(r, fdir, left ? e->offset_l : e->offset_r);
} | /* Offset by e->offset in plane with normal plane_no, on left if left==true,
* else on right. If no is NULL, choose an arbitrary plane different
* from eh's direction. */ | Offset by e->offset in plane with normal plane_no, on left if left==true,
else on right. If no is NULL, choose an arbitrary plane different
from eh's direction. | [
"Offset",
"by",
"e",
"-",
">",
"offset",
"in",
"plane",
"with",
"normal",
"plane_no",
"on",
"left",
"if",
"left",
"==",
"true",
"else",
"on",
"right",
".",
"If",
"no",
"is",
"NULL",
"choose",
"an",
"arbitrary",
"plane",
"different",
"from",
"eh",
"'",
"s",
"direction",
"."
] | static void offset_in_plane(EdgeHalf *e, const float plane_no[3], bool left, float r[3])
{
float dir[3], no[3], fdir[3];
BMVert *v;
v = e->is_rev ? e->e->v2 : e->e->v1;
sub_v3_v3v3(dir, BM_edge_other_vert(e->e, v)->co, v->co);
normalize_v3(dir);
if (plane_no) {
copy_v3_v3(no, plane_no);
}
else {
zero_v3(no);
if (fabsf(dir[0]) < fabsf(dir[1])) {
no[0] = 1.0f;
}
else {
no[1] = 1.0f;
}
}
if (left) {
cross_v3_v3v3(fdir, dir, no);
}
else {
cross_v3_v3v3(fdir, no, dir);
}
normalize_v3(fdir);
copy_v3_v3(r, v->co);
madd_v3_v3fl(r, fdir, left ? e->offset_l : e->offset_r);
} | [
"static",
"void",
"offset_in_plane",
"(",
"EdgeHalf",
"*",
"e",
",",
"const",
"float",
"plane_no",
"[",
"3",
"]",
",",
"bool",
"left",
",",
"float",
"r",
"[",
"3",
"]",
")",
"{",
"float",
"dir",
"[",
"3",
"]",
",",
"no",
"[",
"3",
"]",
",",
"fdir",
"[",
"3",
"]",
";",
"BMVert",
"*",
"v",
";",
"v",
"=",
"e",
"->",
"is_rev",
"?",
"e",
"->",
"e",
"->",
"v2",
":",
"e",
"->",
"e",
"->",
"v1",
";",
"sub_v3_v3v3",
"(",
"dir",
",",
"BM_edge_other_vert",
"(",
"e",
"->",
"e",
",",
"v",
")",
"->",
"co",
",",
"v",
"->",
"co",
")",
";",
"normalize_v3",
"(",
"dir",
")",
";",
"if",
"(",
"plane_no",
")",
"{",
"copy_v3_v3",
"(",
"no",
",",
"plane_no",
")",
";",
"}",
"else",
"{",
"zero_v3",
"(",
"no",
")",
";",
"if",
"(",
"fabsf",
"(",
"dir",
"[",
"0",
"]",
")",
"<",
"fabsf",
"(",
"dir",
"[",
"1",
"]",
")",
")",
"{",
"no",
"[",
"0",
"]",
"=",
"1.0f",
";",
"}",
"else",
"{",
"no",
"[",
"1",
"]",
"=",
"1.0f",
";",
"}",
"}",
"if",
"(",
"left",
")",
"{",
"cross_v3_v3v3",
"(",
"fdir",
",",
"dir",
",",
"no",
")",
";",
"}",
"else",
"{",
"cross_v3_v3v3",
"(",
"fdir",
",",
"no",
",",
"dir",
")",
";",
"}",
"normalize_v3",
"(",
"fdir",
")",
";",
"copy_v3_v3",
"(",
"r",
",",
"v",
"->",
"co",
")",
";",
"madd_v3_v3fl",
"(",
"r",
",",
"fdir",
",",
"left",
"?",
"e",
"->",
"offset_l",
":",
"e",
"->",
"offset_r",
")",
";",
"}"
] | Offset by e->offset in plane with normal plane_no, on left if left==true,
else on right. | [
"Offset",
"by",
"e",
"-",
">",
"offset",
"in",
"plane",
"with",
"normal",
"plane_no",
"on",
"left",
"if",
"left",
"==",
"true",
"else",
"on",
"right",
"."
] | [] | [
{
"param": "e",
"type": "EdgeHalf"
},
{
"param": "plane_no",
"type": "float"
},
{
"param": "left",
"type": "bool"
},
{
"param": "r",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "e",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "plane_no",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "left",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | project_to_edge | void | static void project_to_edge(BMEdge *e, const float co_a[3], const float co_b[3], float projco[3])
{
float otherco[3];
if (!isect_line_line_v3(e->v1->co, e->v2->co, co_a, co_b, projco, otherco)) {
#ifdef BEVEL_ASSERT_PROJECT
BLI_assert(!"project meet failure");
#endif
copy_v3_v3(projco, e->v1->co);
}
} | /* Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco */ | Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco | [
"Calculate",
"the",
"point",
"on",
"e",
"where",
"line",
"(",
"co_a",
"co_b",
")",
"comes",
"closest",
"to",
"and",
"return",
"it",
"in",
"projco"
] | static void project_to_edge(BMEdge *e, const float co_a[3], const float co_b[3], float projco[3])
{
float otherco[3];
if (!isect_line_line_v3(e->v1->co, e->v2->co, co_a, co_b, projco, otherco)) {
#ifdef BEVEL_ASSERT_PROJECT
BLI_assert(!"project meet failure");
#endif
copy_v3_v3(projco, e->v1->co);
}
} | [
"static",
"void",
"project_to_edge",
"(",
"BMEdge",
"*",
"e",
",",
"const",
"float",
"co_a",
"[",
"3",
"]",
",",
"const",
"float",
"co_b",
"[",
"3",
"]",
",",
"float",
"projco",
"[",
"3",
"]",
")",
"{",
"float",
"otherco",
"[",
"3",
"]",
";",
"if",
"(",
"!",
"isect_line_line_v3",
"(",
"e",
"->",
"v1",
"->",
"co",
",",
"e",
"->",
"v2",
"->",
"co",
",",
"co_a",
",",
"co_b",
",",
"projco",
",",
"otherco",
")",
")",
"{",
"#ifdef",
"BEVEL_ASSERT_PROJECT",
"BLI_assert",
"(",
"!",
"\"",
"\"",
")",
";",
"#endif",
"copy_v3_v3",
"(",
"projco",
",",
"e",
"->",
"v1",
"->",
"co",
")",
";",
"}",
"}"
] | Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco | [
"Calculate",
"the",
"point",
"on",
"e",
"where",
"line",
"(",
"co_a",
"co_b",
")",
"comes",
"closest",
"to",
"and",
"return",
"it",
"in",
"projco"
] | [] | [
{
"param": "e",
"type": "BMEdge"
},
{
"param": "co_a",
"type": "float"
},
{
"param": "co_b",
"type": "float"
},
{
"param": "projco",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "e",
"type": "BMEdge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "co_a",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "co_b",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "projco",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | move_profile_plane | void | static void move_profile_plane(BoundVert *bndv, BMVert *bmv)
{
float d1[3], d2[3], no[3], no2[3], no3[3], dot2, dot3;
Profile *pro = &bndv->profile;
/* only do this if projecting, and coa, cob, and proj_dir are not coplanar */
if (is_zero_v3(pro->proj_dir)) {
return;
}
sub_v3_v3v3(d1, bmv->co, pro->coa);
normalize_v3(d1);
sub_v3_v3v3(d2, bmv->co, pro->cob);
normalize_v3(d2);
cross_v3_v3v3(no, d1, d2);
cross_v3_v3v3(no2, d1, pro->proj_dir);
cross_v3_v3v3(no3, d2, pro->proj_dir);
if (normalize_v3(no) > BEVEL_EPSILON_BIG && normalize_v3(no2) > BEVEL_EPSILON_BIG &&
normalize_v3(no3) > BEVEL_EPSILON_BIG) {
dot2 = dot_v3v3(no, no2);
dot3 = dot_v3v3(no, no3);
if (fabsf(dot2) < (1 - BEVEL_EPSILON_BIG) && fabsf(dot3) < (1 - BEVEL_EPSILON_BIG)) {
copy_v3_v3(bndv->profile.plane_no, no);
}
}
} | /* Maybe move the profile plane for bndv->ebev to the plane its profile's coa, cob and the
* original beveled vert, bmv. This will usually be the plane containing its adjacent
* non-beveled edges, but sometimes coa and cob are not on those edges.
*/ | Maybe move the profile plane for bndv->ebev to the plane its profile's coa, cob and the
original beveled vert, bmv. This will usually be the plane containing its adjacent
non-beveled edges, but sometimes coa and cob are not on those edges. | [
"Maybe",
"move",
"the",
"profile",
"plane",
"for",
"bndv",
"-",
">",
"ebev",
"to",
"the",
"plane",
"its",
"profile",
"'",
"s",
"coa",
"cob",
"and",
"the",
"original",
"beveled",
"vert",
"bmv",
".",
"This",
"will",
"usually",
"be",
"the",
"plane",
"containing",
"its",
"adjacent",
"non",
"-",
"beveled",
"edges",
"but",
"sometimes",
"coa",
"and",
"cob",
"are",
"not",
"on",
"those",
"edges",
"."
] | static void move_profile_plane(BoundVert *bndv, BMVert *bmv)
{
float d1[3], d2[3], no[3], no2[3], no3[3], dot2, dot3;
Profile *pro = &bndv->profile;
if (is_zero_v3(pro->proj_dir)) {
return;
}
sub_v3_v3v3(d1, bmv->co, pro->coa);
normalize_v3(d1);
sub_v3_v3v3(d2, bmv->co, pro->cob);
normalize_v3(d2);
cross_v3_v3v3(no, d1, d2);
cross_v3_v3v3(no2, d1, pro->proj_dir);
cross_v3_v3v3(no3, d2, pro->proj_dir);
if (normalize_v3(no) > BEVEL_EPSILON_BIG && normalize_v3(no2) > BEVEL_EPSILON_BIG &&
normalize_v3(no3) > BEVEL_EPSILON_BIG) {
dot2 = dot_v3v3(no, no2);
dot3 = dot_v3v3(no, no3);
if (fabsf(dot2) < (1 - BEVEL_EPSILON_BIG) && fabsf(dot3) < (1 - BEVEL_EPSILON_BIG)) {
copy_v3_v3(bndv->profile.plane_no, no);
}
}
} | [
"static",
"void",
"move_profile_plane",
"(",
"BoundVert",
"*",
"bndv",
",",
"BMVert",
"*",
"bmv",
")",
"{",
"float",
"d1",
"[",
"3",
"]",
",",
"d2",
"[",
"3",
"]",
",",
"no",
"[",
"3",
"]",
",",
"no2",
"[",
"3",
"]",
",",
"no3",
"[",
"3",
"]",
",",
"dot2",
",",
"dot3",
";",
"Profile",
"*",
"pro",
"=",
"&",
"bndv",
"->",
"profile",
";",
"if",
"(",
"is_zero_v3",
"(",
"pro",
"->",
"proj_dir",
")",
")",
"{",
"return",
";",
"}",
"sub_v3_v3v3",
"(",
"d1",
",",
"bmv",
"->",
"co",
",",
"pro",
"->",
"coa",
")",
";",
"normalize_v3",
"(",
"d1",
")",
";",
"sub_v3_v3v3",
"(",
"d2",
",",
"bmv",
"->",
"co",
",",
"pro",
"->",
"cob",
")",
";",
"normalize_v3",
"(",
"d2",
")",
";",
"cross_v3_v3v3",
"(",
"no",
",",
"d1",
",",
"d2",
")",
";",
"cross_v3_v3v3",
"(",
"no2",
",",
"d1",
",",
"pro",
"->",
"proj_dir",
")",
";",
"cross_v3_v3v3",
"(",
"no3",
",",
"d2",
",",
"pro",
"->",
"proj_dir",
")",
";",
"if",
"(",
"normalize_v3",
"(",
"no",
")",
">",
"BEVEL_EPSILON_BIG",
"&&",
"normalize_v3",
"(",
"no2",
")",
">",
"BEVEL_EPSILON_BIG",
"&&",
"normalize_v3",
"(",
"no3",
")",
">",
"BEVEL_EPSILON_BIG",
")",
"{",
"dot2",
"=",
"dot_v3v3",
"(",
"no",
",",
"no2",
")",
";",
"dot3",
"=",
"dot_v3v3",
"(",
"no",
",",
"no3",
")",
";",
"if",
"(",
"fabsf",
"(",
"dot2",
")",
"<",
"(",
"1",
"-",
"BEVEL_EPSILON_BIG",
")",
"&&",
"fabsf",
"(",
"dot3",
")",
"<",
"(",
"1",
"-",
"BEVEL_EPSILON_BIG",
")",
")",
"{",
"copy_v3_v3",
"(",
"bndv",
"->",
"profile",
".",
"plane_no",
",",
"no",
")",
";",
"}",
"}",
"}"
] | Maybe move the profile plane for bndv->ebev to the plane its profile's coa, cob and the
original beveled vert, bmv. | [
"Maybe",
"move",
"the",
"profile",
"plane",
"for",
"bndv",
"-",
">",
"ebev",
"to",
"the",
"plane",
"its",
"profile",
"'",
"s",
"coa",
"cob",
"and",
"the",
"original",
"beveled",
"vert",
"bmv",
"."
] | [
"/* only do this if projecting, and coa, cob, and proj_dir are not coplanar */"
] | [
{
"param": "bndv",
"type": "BoundVert"
},
{
"param": "bmv",
"type": "BMVert"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bndv",
"type": "BoundVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bmv",
"type": "BMVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | move_weld_profile_planes | void | static void move_weld_profile_planes(BevVert *bv, BoundVert *bndv1, BoundVert *bndv2)
{
float d1[3], d2[3], no[3], no2[3], no3[3], dot1, dot2, l1, l2, l3;
/* only do this if projecting, and d1, d2, and proj_dir are not coplanar */
if (is_zero_v3(bndv1->profile.proj_dir) || is_zero_v3(bndv2->profile.proj_dir)) {
return;
}
sub_v3_v3v3(d1, bv->v->co, bndv1->nv.co);
sub_v3_v3v3(d2, bv->v->co, bndv2->nv.co);
cross_v3_v3v3(no, d1, d2);
l1 = normalize_v3(no);
/* "no" is new normal projection plane, but don't move if
* it is coplanar with both of the projection dirs */
cross_v3_v3v3(no2, d1, bndv1->profile.proj_dir);
l2 = normalize_v3(no2);
cross_v3_v3v3(no3, d2, bndv2->profile.proj_dir);
l3 = normalize_v3(no3);
if (l1 > BEVEL_EPSILON && (l2 > BEVEL_EPSILON || l3 > BEVEL_EPSILON)) {
dot1 = fabsf(dot_v3v3(no, no2));
dot2 = fabsf(dot_v3v3(no, no3));
if (fabsf(dot1 - 1.0f) > BEVEL_EPSILON) {
copy_v3_v3(bndv1->profile.plane_no, no);
}
if (fabsf(dot2 - 1.0f) > BEVEL_EPSILON) {
copy_v3_v3(bndv2->profile.plane_no, no);
}
}
} | /* Move the profile plane for the two BoundVerts involved in a weld.
* We want the plane that is most likely to have the intersections of the
* two edges' profile projections on it. bndv1 and bndv2 are by
* construction the intersection points of the outside parts of the profiles.
* The original vertex should form a third point of the desired plane. */ | Move the profile plane for the two BoundVerts involved in a weld.
We want the plane that is most likely to have the intersections of the
two edges' profile projections on it. bndv1 and bndv2 are by
construction the intersection points of the outside parts of the profiles.
The original vertex should form a third point of the desired plane. | [
"Move",
"the",
"profile",
"plane",
"for",
"the",
"two",
"BoundVerts",
"involved",
"in",
"a",
"weld",
".",
"We",
"want",
"the",
"plane",
"that",
"is",
"most",
"likely",
"to",
"have",
"the",
"intersections",
"of",
"the",
"two",
"edges",
"'",
"profile",
"projections",
"on",
"it",
".",
"bndv1",
"and",
"bndv2",
"are",
"by",
"construction",
"the",
"intersection",
"points",
"of",
"the",
"outside",
"parts",
"of",
"the",
"profiles",
".",
"The",
"original",
"vertex",
"should",
"form",
"a",
"third",
"point",
"of",
"the",
"desired",
"plane",
"."
] | static void move_weld_profile_planes(BevVert *bv, BoundVert *bndv1, BoundVert *bndv2)
{
float d1[3], d2[3], no[3], no2[3], no3[3], dot1, dot2, l1, l2, l3;
if (is_zero_v3(bndv1->profile.proj_dir) || is_zero_v3(bndv2->profile.proj_dir)) {
return;
}
sub_v3_v3v3(d1, bv->v->co, bndv1->nv.co);
sub_v3_v3v3(d2, bv->v->co, bndv2->nv.co);
cross_v3_v3v3(no, d1, d2);
l1 = normalize_v3(no);
cross_v3_v3v3(no2, d1, bndv1->profile.proj_dir);
l2 = normalize_v3(no2);
cross_v3_v3v3(no3, d2, bndv2->profile.proj_dir);
l3 = normalize_v3(no3);
if (l1 > BEVEL_EPSILON && (l2 > BEVEL_EPSILON || l3 > BEVEL_EPSILON)) {
dot1 = fabsf(dot_v3v3(no, no2));
dot2 = fabsf(dot_v3v3(no, no3));
if (fabsf(dot1 - 1.0f) > BEVEL_EPSILON) {
copy_v3_v3(bndv1->profile.plane_no, no);
}
if (fabsf(dot2 - 1.0f) > BEVEL_EPSILON) {
copy_v3_v3(bndv2->profile.plane_no, no);
}
}
} | [
"static",
"void",
"move_weld_profile_planes",
"(",
"BevVert",
"*",
"bv",
",",
"BoundVert",
"*",
"bndv1",
",",
"BoundVert",
"*",
"bndv2",
")",
"{",
"float",
"d1",
"[",
"3",
"]",
",",
"d2",
"[",
"3",
"]",
",",
"no",
"[",
"3",
"]",
",",
"no2",
"[",
"3",
"]",
",",
"no3",
"[",
"3",
"]",
",",
"dot1",
",",
"dot2",
",",
"l1",
",",
"l2",
",",
"l3",
";",
"if",
"(",
"is_zero_v3",
"(",
"bndv1",
"->",
"profile",
".",
"proj_dir",
")",
"||",
"is_zero_v3",
"(",
"bndv2",
"->",
"profile",
".",
"proj_dir",
")",
")",
"{",
"return",
";",
"}",
"sub_v3_v3v3",
"(",
"d1",
",",
"bv",
"->",
"v",
"->",
"co",
",",
"bndv1",
"->",
"nv",
".",
"co",
")",
";",
"sub_v3_v3v3",
"(",
"d2",
",",
"bv",
"->",
"v",
"->",
"co",
",",
"bndv2",
"->",
"nv",
".",
"co",
")",
";",
"cross_v3_v3v3",
"(",
"no",
",",
"d1",
",",
"d2",
")",
";",
"l1",
"=",
"normalize_v3",
"(",
"no",
")",
";",
"cross_v3_v3v3",
"(",
"no2",
",",
"d1",
",",
"bndv1",
"->",
"profile",
".",
"proj_dir",
")",
";",
"l2",
"=",
"normalize_v3",
"(",
"no2",
")",
";",
"cross_v3_v3v3",
"(",
"no3",
",",
"d2",
",",
"bndv2",
"->",
"profile",
".",
"proj_dir",
")",
";",
"l3",
"=",
"normalize_v3",
"(",
"no3",
")",
";",
"if",
"(",
"l1",
">",
"BEVEL_EPSILON",
"&&",
"(",
"l2",
">",
"BEVEL_EPSILON",
"||",
"l3",
">",
"BEVEL_EPSILON",
")",
")",
"{",
"dot1",
"=",
"fabsf",
"(",
"dot_v3v3",
"(",
"no",
",",
"no2",
")",
")",
";",
"dot2",
"=",
"fabsf",
"(",
"dot_v3v3",
"(",
"no",
",",
"no3",
")",
")",
";",
"if",
"(",
"fabsf",
"(",
"dot1",
"-",
"1.0f",
")",
">",
"BEVEL_EPSILON",
")",
"{",
"copy_v3_v3",
"(",
"bndv1",
"->",
"profile",
".",
"plane_no",
",",
"no",
")",
";",
"}",
"if",
"(",
"fabsf",
"(",
"dot2",
"-",
"1.0f",
")",
">",
"BEVEL_EPSILON",
")",
"{",
"copy_v3_v3",
"(",
"bndv2",
"->",
"profile",
".",
"plane_no",
",",
"no",
")",
";",
"}",
"}",
"}"
] | Move the profile plane for the two BoundVerts involved in a weld. | [
"Move",
"the",
"profile",
"plane",
"for",
"the",
"two",
"BoundVerts",
"involved",
"in",
"a",
"weld",
"."
] | [
"/* only do this if projecting, and d1, d2, and proj_dir are not coplanar */",
"/* \"no\" is new normal projection plane, but don't move if\n * it is coplanar with both of the projection dirs */"
] | [
{
"param": "bv",
"type": "BevVert"
},
{
"param": "bndv1",
"type": "BoundVert"
},
{
"param": "bndv2",
"type": "BoundVert"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bv",
"type": "BevVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bndv1",
"type": "BoundVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bndv2",
"type": "BoundVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | make_unit_square_map | bool | static bool make_unit_square_map(const float va[3],
const float vmid[3],
const float vb[3],
float r_mat[4][4])
{
float vo[3], vd[3], vb_vmid[3], va_vmid[3], vddir[3];
sub_v3_v3v3(va_vmid, vmid, va);
sub_v3_v3v3(vb_vmid, vmid, vb);
if (is_zero_v3(va_vmid) || is_zero_v3(vb_vmid)) {
return false;
}
if (fabsf(angle_v3v3(va_vmid, vb_vmid) - (float)M_PI) <= BEVEL_EPSILON_ANG) {
return false;
}
sub_v3_v3v3(vo, va, vb_vmid);
cross_v3_v3v3(vddir, vb_vmid, va_vmid);
normalize_v3(vddir);
add_v3_v3v3(vd, vo, vddir);
/* The cols of m are: {vmid - va, vmid - vb, vmid + vd - va -vb, va + vb - vmid;
* blender transform matrices are stored such that m[i][*] is ith column;
* the last elements of each col remain as they are in unity matrix. */
sub_v3_v3v3(&r_mat[0][0], vmid, va);
r_mat[0][3] = 0.0f;
sub_v3_v3v3(&r_mat[1][0], vmid, vb);
r_mat[1][3] = 0.0f;
add_v3_v3v3(&r_mat[2][0], vmid, vd);
sub_v3_v3(&r_mat[2][0], va);
sub_v3_v3(&r_mat[2][0], vb);
r_mat[2][3] = 0.0f;
add_v3_v3v3(&r_mat[3][0], va, vb);
sub_v3_v3(&r_mat[3][0], vmid);
r_mat[3][3] = 1.0f;
return true;
} | /* Fill matrix r_mat so that a point in the sheared parallelogram with corners
* va, vmid, vb (and the 4th that is implied by it being a parallelogram)
* is the result of transforming the unit square by multiplication with r_mat.
* If it can't be done because the parallelogram is degenerate, return false
* else return true.
* Method:
* Find vo, the origin of the parallelogram with other three points va, vmid, vb.
* Also find vd, which is in direction normal to parallelogram and 1 unit away
* from the origin.
* The quarter circle in first quadrant of unit square will be mapped to the
* quadrant of a sheared ellipse in the parallelogram, using a matrix.
* The matrix mat is calculated to map:
* (0,1,0) -> va
* (1,1,0) -> vmid
* (1,0,0) -> vb
* (0,1,1) -> vd
* We want M to make M*A=B where A has the left side above, as columns
* and B has the right side as columns - both extended into homogeneous coords.
* So M = B*(Ainverse). Doing Ainverse by hand gives the code below.
*/ | Fill matrix r_mat so that a point in the sheared parallelogram with corners
va, vmid, vb (and the 4th that is implied by it being a parallelogram)
is the result of transforming the unit square by multiplication with r_mat.
If it can't be done because the parallelogram is degenerate, return false
else return true.
Method:
Find vo, the origin of the parallelogram with other three points va, vmid, vb.
Also find vd, which is in direction normal to parallelogram and 1 unit away
from the origin.
The quarter circle in first quadrant of unit square will be mapped to the
quadrant of a sheared ellipse in the parallelogram, using a matrix. | [
"Fill",
"matrix",
"r_mat",
"so",
"that",
"a",
"point",
"in",
"the",
"sheared",
"parallelogram",
"with",
"corners",
"va",
"vmid",
"vb",
"(",
"and",
"the",
"4th",
"that",
"is",
"implied",
"by",
"it",
"being",
"a",
"parallelogram",
")",
"is",
"the",
"result",
"of",
"transforming",
"the",
"unit",
"square",
"by",
"multiplication",
"with",
"r_mat",
".",
"If",
"it",
"can",
"'",
"t",
"be",
"done",
"because",
"the",
"parallelogram",
"is",
"degenerate",
"return",
"false",
"else",
"return",
"true",
".",
"Method",
":",
"Find",
"vo",
"the",
"origin",
"of",
"the",
"parallelogram",
"with",
"other",
"three",
"points",
"va",
"vmid",
"vb",
".",
"Also",
"find",
"vd",
"which",
"is",
"in",
"direction",
"normal",
"to",
"parallelogram",
"and",
"1",
"unit",
"away",
"from",
"the",
"origin",
".",
"The",
"quarter",
"circle",
"in",
"first",
"quadrant",
"of",
"unit",
"square",
"will",
"be",
"mapped",
"to",
"the",
"quadrant",
"of",
"a",
"sheared",
"ellipse",
"in",
"the",
"parallelogram",
"using",
"a",
"matrix",
"."
] | static bool make_unit_square_map(const float va[3],
const float vmid[3],
const float vb[3],
float r_mat[4][4])
{
float vo[3], vd[3], vb_vmid[3], va_vmid[3], vddir[3];
sub_v3_v3v3(va_vmid, vmid, va);
sub_v3_v3v3(vb_vmid, vmid, vb);
if (is_zero_v3(va_vmid) || is_zero_v3(vb_vmid)) {
return false;
}
if (fabsf(angle_v3v3(va_vmid, vb_vmid) - (float)M_PI) <= BEVEL_EPSILON_ANG) {
return false;
}
sub_v3_v3v3(vo, va, vb_vmid);
cross_v3_v3v3(vddir, vb_vmid, va_vmid);
normalize_v3(vddir);
add_v3_v3v3(vd, vo, vddir);
sub_v3_v3v3(&r_mat[0][0], vmid, va);
r_mat[0][3] = 0.0f;
sub_v3_v3v3(&r_mat[1][0], vmid, vb);
r_mat[1][3] = 0.0f;
add_v3_v3v3(&r_mat[2][0], vmid, vd);
sub_v3_v3(&r_mat[2][0], va);
sub_v3_v3(&r_mat[2][0], vb);
r_mat[2][3] = 0.0f;
add_v3_v3v3(&r_mat[3][0], va, vb);
sub_v3_v3(&r_mat[3][0], vmid);
r_mat[3][3] = 1.0f;
return true;
} | [
"static",
"bool",
"make_unit_square_map",
"(",
"const",
"float",
"va",
"[",
"3",
"]",
",",
"const",
"float",
"vmid",
"[",
"3",
"]",
",",
"const",
"float",
"vb",
"[",
"3",
"]",
",",
"float",
"r_mat",
"[",
"4",
"]",
"[",
"4",
"]",
")",
"{",
"float",
"vo",
"[",
"3",
"]",
",",
"vd",
"[",
"3",
"]",
",",
"vb_vmid",
"[",
"3",
"]",
",",
"va_vmid",
"[",
"3",
"]",
",",
"vddir",
"[",
"3",
"]",
";",
"sub_v3_v3v3",
"(",
"va_vmid",
",",
"vmid",
",",
"va",
")",
";",
"sub_v3_v3v3",
"(",
"vb_vmid",
",",
"vmid",
",",
"vb",
")",
";",
"if",
"(",
"is_zero_v3",
"(",
"va_vmid",
")",
"||",
"is_zero_v3",
"(",
"vb_vmid",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"fabsf",
"(",
"angle_v3v3",
"(",
"va_vmid",
",",
"vb_vmid",
")",
"-",
"(",
"float",
")",
"M_PI",
")",
"<=",
"BEVEL_EPSILON_ANG",
")",
"{",
"return",
"false",
";",
"}",
"sub_v3_v3v3",
"(",
"vo",
",",
"va",
",",
"vb_vmid",
")",
";",
"cross_v3_v3v3",
"(",
"vddir",
",",
"vb_vmid",
",",
"va_vmid",
")",
";",
"normalize_v3",
"(",
"vddir",
")",
";",
"add_v3_v3v3",
"(",
"vd",
",",
"vo",
",",
"vddir",
")",
";",
"sub_v3_v3v3",
"(",
"&",
"r_mat",
"[",
"0",
"]",
"[",
"0",
"]",
",",
"vmid",
",",
"va",
")",
";",
"r_mat",
"[",
"0",
"]",
"[",
"3",
"]",
"=",
"0.0f",
";",
"sub_v3_v3v3",
"(",
"&",
"r_mat",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"vmid",
",",
"vb",
")",
";",
"r_mat",
"[",
"1",
"]",
"[",
"3",
"]",
"=",
"0.0f",
";",
"add_v3_v3v3",
"(",
"&",
"r_mat",
"[",
"2",
"]",
"[",
"0",
"]",
",",
"vmid",
",",
"vd",
")",
";",
"sub_v3_v3",
"(",
"&",
"r_mat",
"[",
"2",
"]",
"[",
"0",
"]",
",",
"va",
")",
";",
"sub_v3_v3",
"(",
"&",
"r_mat",
"[",
"2",
"]",
"[",
"0",
"]",
",",
"vb",
")",
";",
"r_mat",
"[",
"2",
"]",
"[",
"3",
"]",
"=",
"0.0f",
";",
"add_v3_v3v3",
"(",
"&",
"r_mat",
"[",
"3",
"]",
"[",
"0",
"]",
",",
"va",
",",
"vb",
")",
";",
"sub_v3_v3",
"(",
"&",
"r_mat",
"[",
"3",
"]",
"[",
"0",
"]",
",",
"vmid",
")",
";",
"r_mat",
"[",
"3",
"]",
"[",
"3",
"]",
"=",
"1.0f",
";",
"return",
"true",
";",
"}"
] | Fill matrix r_mat so that a point in the sheared parallelogram with corners
va, vmid, vb (and the 4th that is implied by it being a parallelogram)
is the result of transforming the unit square by multiplication with r_mat. | [
"Fill",
"matrix",
"r_mat",
"so",
"that",
"a",
"point",
"in",
"the",
"sheared",
"parallelogram",
"with",
"corners",
"va",
"vmid",
"vb",
"(",
"and",
"the",
"4th",
"that",
"is",
"implied",
"by",
"it",
"being",
"a",
"parallelogram",
")",
"is",
"the",
"result",
"of",
"transforming",
"the",
"unit",
"square",
"by",
"multiplication",
"with",
"r_mat",
"."
] | [
"/* The cols of m are: {vmid - va, vmid - vb, vmid + vd - va -vb, va + vb - vmid;\n * blender transform matrices are stored such that m[i][*] is ith column;\n * the last elements of each col remain as they are in unity matrix. */"
] | [
{
"param": "va",
"type": "float"
},
{
"param": "vmid",
"type": "float"
},
{
"param": "vb",
"type": "float"
},
{
"param": "r_mat",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "va",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vmid",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vb",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r_mat",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | make_unit_cube_map | void | static void make_unit_cube_map(
const float va[3], const float vb[3], const float vc[3], const float vd[3], float r_mat[4][4])
{
copy_v3_v3(r_mat[0], va);
sub_v3_v3(r_mat[0], vb);
sub_v3_v3(r_mat[0], vc);
add_v3_v3(r_mat[0], vd);
mul_v3_fl(r_mat[0], 0.5f);
r_mat[0][3] = 0.0f;
copy_v3_v3(r_mat[1], vb);
sub_v3_v3(r_mat[1], va);
sub_v3_v3(r_mat[1], vc);
add_v3_v3(r_mat[1], vd);
mul_v3_fl(r_mat[1], 0.5f);
r_mat[1][3] = 0.0f;
copy_v3_v3(r_mat[2], vc);
sub_v3_v3(r_mat[2], va);
sub_v3_v3(r_mat[2], vb);
add_v3_v3(r_mat[2], vd);
mul_v3_fl(r_mat[2], 0.5f);
r_mat[2][3] = 0.0f;
copy_v3_v3(r_mat[3], va);
add_v3_v3(r_mat[3], vb);
add_v3_v3(r_mat[3], vc);
sub_v3_v3(r_mat[3], vd);
mul_v3_fl(r_mat[3], 0.5f);
r_mat[3][3] = 1.0f;
} | /* Like make_unit_square_map, but this one makes a matrix that transforms the
* (1,1,1) corner of a unit cube into an arbitrary corner with corner vert d
* and verts around it a, b, c (in ccw order, viewed from d normal dir).
* The matrix mat is calculated to map:
* (1,0,0) -> va
* (0,1,0) -> vb
* (0,0,1) -> vc
* (1,1,1) -> vd
* We want M to make M*A=B where A has the left side above, as columns
* and B has the right side as columns - both extended into homogeneous coords.
* So M = B*(Ainverse). Doing Ainverse by hand gives the code below.
* The cols of M are 1/2{va-vb+vc-vd}, 1/2{-va+vb-vc+vd}, 1/2{-va-vb+vc+vd},
* and 1/2{va+vb+vc-vd}
* and Blender matrices have cols at m[i][*].
*/ | Like make_unit_square_map, but this one makes a matrix that transforms the
(1,1,1) corner of a unit cube into an arbitrary corner with corner vert d
and verts around it a, b, c (in ccw order, viewed from d normal dir). | [
"Like",
"make_unit_square_map",
"but",
"this",
"one",
"makes",
"a",
"matrix",
"that",
"transforms",
"the",
"(",
"1",
"1",
"1",
")",
"corner",
"of",
"a",
"unit",
"cube",
"into",
"an",
"arbitrary",
"corner",
"with",
"corner",
"vert",
"d",
"and",
"verts",
"around",
"it",
"a",
"b",
"c",
"(",
"in",
"ccw",
"order",
"viewed",
"from",
"d",
"normal",
"dir",
")",
"."
] | static void make_unit_cube_map(
const float va[3], const float vb[3], const float vc[3], const float vd[3], float r_mat[4][4])
{
copy_v3_v3(r_mat[0], va);
sub_v3_v3(r_mat[0], vb);
sub_v3_v3(r_mat[0], vc);
add_v3_v3(r_mat[0], vd);
mul_v3_fl(r_mat[0], 0.5f);
r_mat[0][3] = 0.0f;
copy_v3_v3(r_mat[1], vb);
sub_v3_v3(r_mat[1], va);
sub_v3_v3(r_mat[1], vc);
add_v3_v3(r_mat[1], vd);
mul_v3_fl(r_mat[1], 0.5f);
r_mat[1][3] = 0.0f;
copy_v3_v3(r_mat[2], vc);
sub_v3_v3(r_mat[2], va);
sub_v3_v3(r_mat[2], vb);
add_v3_v3(r_mat[2], vd);
mul_v3_fl(r_mat[2], 0.5f);
r_mat[2][3] = 0.0f;
copy_v3_v3(r_mat[3], va);
add_v3_v3(r_mat[3], vb);
add_v3_v3(r_mat[3], vc);
sub_v3_v3(r_mat[3], vd);
mul_v3_fl(r_mat[3], 0.5f);
r_mat[3][3] = 1.0f;
} | [
"static",
"void",
"make_unit_cube_map",
"(",
"const",
"float",
"va",
"[",
"3",
"]",
",",
"const",
"float",
"vb",
"[",
"3",
"]",
",",
"const",
"float",
"vc",
"[",
"3",
"]",
",",
"const",
"float",
"vd",
"[",
"3",
"]",
",",
"float",
"r_mat",
"[",
"4",
"]",
"[",
"4",
"]",
")",
"{",
"copy_v3_v3",
"(",
"r_mat",
"[",
"0",
"]",
",",
"va",
")",
";",
"sub_v3_v3",
"(",
"r_mat",
"[",
"0",
"]",
",",
"vb",
")",
";",
"sub_v3_v3",
"(",
"r_mat",
"[",
"0",
"]",
",",
"vc",
")",
";",
"add_v3_v3",
"(",
"r_mat",
"[",
"0",
"]",
",",
"vd",
")",
";",
"mul_v3_fl",
"(",
"r_mat",
"[",
"0",
"]",
",",
"0.5f",
")",
";",
"r_mat",
"[",
"0",
"]",
"[",
"3",
"]",
"=",
"0.0f",
";",
"copy_v3_v3",
"(",
"r_mat",
"[",
"1",
"]",
",",
"vb",
")",
";",
"sub_v3_v3",
"(",
"r_mat",
"[",
"1",
"]",
",",
"va",
")",
";",
"sub_v3_v3",
"(",
"r_mat",
"[",
"1",
"]",
",",
"vc",
")",
";",
"add_v3_v3",
"(",
"r_mat",
"[",
"1",
"]",
",",
"vd",
")",
";",
"mul_v3_fl",
"(",
"r_mat",
"[",
"1",
"]",
",",
"0.5f",
")",
";",
"r_mat",
"[",
"1",
"]",
"[",
"3",
"]",
"=",
"0.0f",
";",
"copy_v3_v3",
"(",
"r_mat",
"[",
"2",
"]",
",",
"vc",
")",
";",
"sub_v3_v3",
"(",
"r_mat",
"[",
"2",
"]",
",",
"va",
")",
";",
"sub_v3_v3",
"(",
"r_mat",
"[",
"2",
"]",
",",
"vb",
")",
";",
"add_v3_v3",
"(",
"r_mat",
"[",
"2",
"]",
",",
"vd",
")",
";",
"mul_v3_fl",
"(",
"r_mat",
"[",
"2",
"]",
",",
"0.5f",
")",
";",
"r_mat",
"[",
"2",
"]",
"[",
"3",
"]",
"=",
"0.0f",
";",
"copy_v3_v3",
"(",
"r_mat",
"[",
"3",
"]",
",",
"va",
")",
";",
"add_v3_v3",
"(",
"r_mat",
"[",
"3",
"]",
",",
"vb",
")",
";",
"add_v3_v3",
"(",
"r_mat",
"[",
"3",
"]",
",",
"vc",
")",
";",
"sub_v3_v3",
"(",
"r_mat",
"[",
"3",
"]",
",",
"vd",
")",
";",
"mul_v3_fl",
"(",
"r_mat",
"[",
"3",
"]",
",",
"0.5f",
")",
";",
"r_mat",
"[",
"3",
"]",
"[",
"3",
"]",
"=",
"1.0f",
";",
"}"
] | Like make_unit_square_map, but this one makes a matrix that transforms the
(1,1,1) corner of a unit cube into an arbitrary corner with corner vert d
and verts around it a, b, c (in ccw order, viewed from d normal dir). | [
"Like",
"make_unit_square_map",
"but",
"this",
"one",
"makes",
"a",
"matrix",
"that",
"transforms",
"the",
"(",
"1",
"1",
"1",
")",
"corner",
"of",
"a",
"unit",
"cube",
"into",
"an",
"arbitrary",
"corner",
"with",
"corner",
"vert",
"d",
"and",
"verts",
"around",
"it",
"a",
"b",
"c",
"(",
"in",
"ccw",
"order",
"viewed",
"from",
"d",
"normal",
"dir",
")",
"."
] | [] | [
{
"param": "va",
"type": "float"
},
{
"param": "vb",
"type": "float"
},
{
"param": "vc",
"type": "float"
},
{
"param": "vd",
"type": "float"
},
{
"param": "r_mat",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "va",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vb",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vc",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vd",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r_mat",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | calculate_profile | void | static void calculate_profile(BevelParams *bp, BoundVert *bndv)
{
int i, k, ns;
const double *xvals, *yvals;
float co[3], co2[3], p[3], m[4][4];
float *prof_co, *prof_co_k;
float r;
bool need_2, map_ok;
Profile *pro = &bndv->profile;
if (bp->seg == 1) {
return;
}
need_2 = bp->seg != bp->pro_spacing.seg_2;
if (!pro->prof_co) {
pro->prof_co = (float *)BLI_memarena_alloc(bp->mem_arena, (bp->seg + 1) * 3 * sizeof(float));
if (need_2) {
pro->prof_co_2 = (float *)BLI_memarena_alloc(
bp->mem_arena, (bp->pro_spacing.seg_2 + 1) * 3 * sizeof(float));
}
else {
pro->prof_co_2 = pro->prof_co;
}
}
r = pro->super_r;
if (r == PRO_LINE_R) {
map_ok = false;
}
else {
map_ok = make_unit_square_map(pro->coa, pro->midco, pro->cob, m);
}
for (i = 0; i < 2; i++) {
if (i == 0) {
ns = bp->seg;
xvals = bp->pro_spacing.xvals;
yvals = bp->pro_spacing.yvals;
prof_co = pro->prof_co;
}
else {
if (!need_2) {
break; /* shares coords with pro->prof_co */
}
ns = bp->pro_spacing.seg_2;
xvals = bp->pro_spacing.xvals_2;
yvals = bp->pro_spacing.yvals_2;
prof_co = pro->prof_co_2;
}
BLI_assert((r == PRO_LINE_R || (xvals != NULL && yvals != NULL)) && prof_co != NULL);
for (k = 0; k <= ns; k++) {
if (k == 0) {
copy_v3_v3(co, pro->coa);
}
else if (k == ns) {
copy_v3_v3(co, pro->cob);
}
else {
if (map_ok) {
p[0] = xvals[k];
p[1] = yvals[k];
p[2] = 0.0f;
mul_v3_m4v3(co, m, p);
}
else {
interp_v3_v3v3(co, pro->coa, pro->cob, (float)k / (float)ns);
}
}
/* project co onto final profile plane */
prof_co_k = prof_co + 3 * k;
if (!is_zero_v3(pro->proj_dir)) {
add_v3_v3v3(co2, co, pro->proj_dir);
if (!isect_line_plane_v3(prof_co_k, co, co2, pro->plane_co, pro->plane_no)) {
/* shouldn't happen */
copy_v3_v3(prof_co_k, co);
}
}
else {
copy_v3_v3(prof_co_k, co);
}
}
}
} | /* Calculate the actual coordinate values for bndv's profile.
* This is only needed if bp->seg > 1.
* Allocate the space for them if that hasn't been done already.
* If bp->seg is not a power of 2, also need to calculate
* the coordinate values for the power of 2 >= bp->seg,
* because the ADJ pattern needs power-of-2 boundaries
* during construction. */ | Calculate the actual coordinate values for bndv's profile.
This is only needed if bp->seg > 1.
Allocate the space for them if that hasn't been done already.
If bp->seg is not a power of 2, also need to calculate
the coordinate values for the power of 2 >= bp->seg,
because the ADJ pattern needs power-of-2 boundaries
during construction. | [
"Calculate",
"the",
"actual",
"coordinate",
"values",
"for",
"bndv",
"'",
"s",
"profile",
".",
"This",
"is",
"only",
"needed",
"if",
"bp",
"-",
">",
"seg",
">",
"1",
".",
"Allocate",
"the",
"space",
"for",
"them",
"if",
"that",
"hasn",
"'",
"t",
"been",
"done",
"already",
".",
"If",
"bp",
"-",
">",
"seg",
"is",
"not",
"a",
"power",
"of",
"2",
"also",
"need",
"to",
"calculate",
"the",
"coordinate",
"values",
"for",
"the",
"power",
"of",
"2",
">",
"=",
"bp",
"-",
">",
"seg",
"because",
"the",
"ADJ",
"pattern",
"needs",
"power",
"-",
"of",
"-",
"2",
"boundaries",
"during",
"construction",
"."
] | static void calculate_profile(BevelParams *bp, BoundVert *bndv)
{
int i, k, ns;
const double *xvals, *yvals;
float co[3], co2[3], p[3], m[4][4];
float *prof_co, *prof_co_k;
float r;
bool need_2, map_ok;
Profile *pro = &bndv->profile;
if (bp->seg == 1) {
return;
}
need_2 = bp->seg != bp->pro_spacing.seg_2;
if (!pro->prof_co) {
pro->prof_co = (float *)BLI_memarena_alloc(bp->mem_arena, (bp->seg + 1) * 3 * sizeof(float));
if (need_2) {
pro->prof_co_2 = (float *)BLI_memarena_alloc(
bp->mem_arena, (bp->pro_spacing.seg_2 + 1) * 3 * sizeof(float));
}
else {
pro->prof_co_2 = pro->prof_co;
}
}
r = pro->super_r;
if (r == PRO_LINE_R) {
map_ok = false;
}
else {
map_ok = make_unit_square_map(pro->coa, pro->midco, pro->cob, m);
}
for (i = 0; i < 2; i++) {
if (i == 0) {
ns = bp->seg;
xvals = bp->pro_spacing.xvals;
yvals = bp->pro_spacing.yvals;
prof_co = pro->prof_co;
}
else {
if (!need_2) {
break;
}
ns = bp->pro_spacing.seg_2;
xvals = bp->pro_spacing.xvals_2;
yvals = bp->pro_spacing.yvals_2;
prof_co = pro->prof_co_2;
}
BLI_assert((r == PRO_LINE_R || (xvals != NULL && yvals != NULL)) && prof_co != NULL);
for (k = 0; k <= ns; k++) {
if (k == 0) {
copy_v3_v3(co, pro->coa);
}
else if (k == ns) {
copy_v3_v3(co, pro->cob);
}
else {
if (map_ok) {
p[0] = xvals[k];
p[1] = yvals[k];
p[2] = 0.0f;
mul_v3_m4v3(co, m, p);
}
else {
interp_v3_v3v3(co, pro->coa, pro->cob, (float)k / (float)ns);
}
}
prof_co_k = prof_co + 3 * k;
if (!is_zero_v3(pro->proj_dir)) {
add_v3_v3v3(co2, co, pro->proj_dir);
if (!isect_line_plane_v3(prof_co_k, co, co2, pro->plane_co, pro->plane_no)) {
copy_v3_v3(prof_co_k, co);
}
}
else {
copy_v3_v3(prof_co_k, co);
}
}
}
} | [
"static",
"void",
"calculate_profile",
"(",
"BevelParams",
"*",
"bp",
",",
"BoundVert",
"*",
"bndv",
")",
"{",
"int",
"i",
",",
"k",
",",
"ns",
";",
"const",
"double",
"*",
"xvals",
",",
"*",
"yvals",
";",
"float",
"co",
"[",
"3",
"]",
",",
"co2",
"[",
"3",
"]",
",",
"p",
"[",
"3",
"]",
",",
"m",
"[",
"4",
"]",
"[",
"4",
"]",
";",
"float",
"*",
"prof_co",
",",
"*",
"prof_co_k",
";",
"float",
"r",
";",
"bool",
"need_2",
",",
"map_ok",
";",
"Profile",
"*",
"pro",
"=",
"&",
"bndv",
"->",
"profile",
";",
"if",
"(",
"bp",
"->",
"seg",
"==",
"1",
")",
"{",
"return",
";",
"}",
"need_2",
"=",
"bp",
"->",
"seg",
"!=",
"bp",
"->",
"pro_spacing",
".",
"seg_2",
";",
"if",
"(",
"!",
"pro",
"->",
"prof_co",
")",
"{",
"pro",
"->",
"prof_co",
"=",
"(",
"float",
"*",
")",
"BLI_memarena_alloc",
"(",
"bp",
"->",
"mem_arena",
",",
"(",
"bp",
"->",
"seg",
"+",
"1",
")",
"*",
"3",
"*",
"sizeof",
"(",
"float",
")",
")",
";",
"if",
"(",
"need_2",
")",
"{",
"pro",
"->",
"prof_co_2",
"=",
"(",
"float",
"*",
")",
"BLI_memarena_alloc",
"(",
"bp",
"->",
"mem_arena",
",",
"(",
"bp",
"->",
"pro_spacing",
".",
"seg_2",
"+",
"1",
")",
"*",
"3",
"*",
"sizeof",
"(",
"float",
")",
")",
";",
"}",
"else",
"{",
"pro",
"->",
"prof_co_2",
"=",
"pro",
"->",
"prof_co",
";",
"}",
"}",
"r",
"=",
"pro",
"->",
"super_r",
";",
"if",
"(",
"r",
"==",
"PRO_LINE_R",
")",
"{",
"map_ok",
"=",
"false",
";",
"}",
"else",
"{",
"map_ok",
"=",
"make_unit_square_map",
"(",
"pro",
"->",
"coa",
",",
"pro",
"->",
"midco",
",",
"pro",
"->",
"cob",
",",
"m",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"2",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"==",
"0",
")",
"{",
"ns",
"=",
"bp",
"->",
"seg",
";",
"xvals",
"=",
"bp",
"->",
"pro_spacing",
".",
"xvals",
";",
"yvals",
"=",
"bp",
"->",
"pro_spacing",
".",
"yvals",
";",
"prof_co",
"=",
"pro",
"->",
"prof_co",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"need_2",
")",
"{",
"break",
";",
"}",
"ns",
"=",
"bp",
"->",
"pro_spacing",
".",
"seg_2",
";",
"xvals",
"=",
"bp",
"->",
"pro_spacing",
".",
"xvals_2",
";",
"yvals",
"=",
"bp",
"->",
"pro_spacing",
".",
"yvals_2",
";",
"prof_co",
"=",
"pro",
"->",
"prof_co_2",
";",
"}",
"BLI_assert",
"(",
"(",
"r",
"==",
"PRO_LINE_R",
"||",
"(",
"xvals",
"!=",
"NULL",
"&&",
"yvals",
"!=",
"NULL",
")",
")",
"&&",
"prof_co",
"!=",
"NULL",
")",
";",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<=",
"ns",
";",
"k",
"++",
")",
"{",
"if",
"(",
"k",
"==",
"0",
")",
"{",
"copy_v3_v3",
"(",
"co",
",",
"pro",
"->",
"coa",
")",
";",
"}",
"else",
"if",
"(",
"k",
"==",
"ns",
")",
"{",
"copy_v3_v3",
"(",
"co",
",",
"pro",
"->",
"cob",
")",
";",
"}",
"else",
"{",
"if",
"(",
"map_ok",
")",
"{",
"p",
"[",
"0",
"]",
"=",
"xvals",
"[",
"k",
"]",
";",
"p",
"[",
"1",
"]",
"=",
"yvals",
"[",
"k",
"]",
";",
"p",
"[",
"2",
"]",
"=",
"0.0f",
";",
"mul_v3_m4v3",
"(",
"co",
",",
"m",
",",
"p",
")",
";",
"}",
"else",
"{",
"interp_v3_v3v3",
"(",
"co",
",",
"pro",
"->",
"coa",
",",
"pro",
"->",
"cob",
",",
"(",
"float",
")",
"k",
"/",
"(",
"float",
")",
"ns",
")",
";",
"}",
"}",
"prof_co_k",
"=",
"prof_co",
"+",
"3",
"*",
"k",
";",
"if",
"(",
"!",
"is_zero_v3",
"(",
"pro",
"->",
"proj_dir",
")",
")",
"{",
"add_v3_v3v3",
"(",
"co2",
",",
"co",
",",
"pro",
"->",
"proj_dir",
")",
";",
"if",
"(",
"!",
"isect_line_plane_v3",
"(",
"prof_co_k",
",",
"co",
",",
"co2",
",",
"pro",
"->",
"plane_co",
",",
"pro",
"->",
"plane_no",
")",
")",
"{",
"copy_v3_v3",
"(",
"prof_co_k",
",",
"co",
")",
";",
"}",
"}",
"else",
"{",
"copy_v3_v3",
"(",
"prof_co_k",
",",
"co",
")",
";",
"}",
"}",
"}",
"}"
] | Calculate the actual coordinate values for bndv's profile. | [
"Calculate",
"the",
"actual",
"coordinate",
"values",
"for",
"bndv",
"'",
"s",
"profile",
"."
] | [
"/* shares coords with pro->prof_co */",
"/* project co onto final profile plane */",
"/* shouldn't happen */"
] | [
{
"param": "bp",
"type": "BevelParams"
},
{
"param": "bndv",
"type": "BoundVert"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bp",
"type": "BevelParams",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bndv",
"type": "BoundVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | snap_to_superellipsoid | void | static void snap_to_superellipsoid(float co[3], const float super_r, bool midline)
{
float a, b, c, x, y, z, r, rinv, dx, dy;
r = super_r;
if (r == PRO_CIRCLE_R) {
normalize_v3(co);
return;
}
x = a = max_ff(0.0f, co[0]);
y = b = max_ff(0.0f, co[1]);
z = c = max_ff(0.0f, co[2]);
if (r == PRO_SQUARE_R || r == PRO_SQUARE_IN_R) {
/* will only be called for 2d profile */
BLI_assert(fabsf(z) < BEVEL_EPSILON);
z = 0.0f;
x = min_ff(1.0f, x);
y = min_ff(1.0f, y);
if (r == PRO_SQUARE_R) {
/* snap to closer of x==1 and y==1 lines, or maybe both */
dx = 1.0f - x;
dy = 1.0f - y;
if (dx < dy) {
x = 1.0f;
y = midline ? 1.0f : y;
}
else {
y = 1.0f;
x = midline ? 1.0f : x;
}
}
else {
/* snap to closer of x==0 and y==0 lines, or maybe both */
if (x < y) {
x = 0.0f;
y = midline ? 0.0f : y;
}
else {
y = 0.0f;
x = midline ? 0.0f : x;
}
}
}
else {
rinv = 1.0f / r;
if (a == 0.0f) {
if (b == 0.0f) {
x = 0.0f;
y = 0.0f;
z = powf(c, rinv);
}
else {
x = 0.0f;
y = powf(1.0f / (1.0f + powf(c / b, r)), rinv);
z = c * y / b;
}
}
else {
x = powf(1.0f / (1.0f + powf(b / a, r) + powf(c / a, r)), rinv);
y = b * x / a;
z = c * x / a;
}
}
co[0] = x;
co[1] = y;
co[2] = z;
} | /* Snap a direction co to a superellipsoid with parameter super_r.
* For square profiles, midline says whether or not to snap to both planes. */ | Snap a direction co to a superellipsoid with parameter super_r.
For square profiles, midline says whether or not to snap to both planes. | [
"Snap",
"a",
"direction",
"co",
"to",
"a",
"superellipsoid",
"with",
"parameter",
"super_r",
".",
"For",
"square",
"profiles",
"midline",
"says",
"whether",
"or",
"not",
"to",
"snap",
"to",
"both",
"planes",
"."
] | static void snap_to_superellipsoid(float co[3], const float super_r, bool midline)
{
float a, b, c, x, y, z, r, rinv, dx, dy;
r = super_r;
if (r == PRO_CIRCLE_R) {
normalize_v3(co);
return;
}
x = a = max_ff(0.0f, co[0]);
y = b = max_ff(0.0f, co[1]);
z = c = max_ff(0.0f, co[2]);
if (r == PRO_SQUARE_R || r == PRO_SQUARE_IN_R) {
BLI_assert(fabsf(z) < BEVEL_EPSILON);
z = 0.0f;
x = min_ff(1.0f, x);
y = min_ff(1.0f, y);
if (r == PRO_SQUARE_R) {
dx = 1.0f - x;
dy = 1.0f - y;
if (dx < dy) {
x = 1.0f;
y = midline ? 1.0f : y;
}
else {
y = 1.0f;
x = midline ? 1.0f : x;
}
}
else {
if (x < y) {
x = 0.0f;
y = midline ? 0.0f : y;
}
else {
y = 0.0f;
x = midline ? 0.0f : x;
}
}
}
else {
rinv = 1.0f / r;
if (a == 0.0f) {
if (b == 0.0f) {
x = 0.0f;
y = 0.0f;
z = powf(c, rinv);
}
else {
x = 0.0f;
y = powf(1.0f / (1.0f + powf(c / b, r)), rinv);
z = c * y / b;
}
}
else {
x = powf(1.0f / (1.0f + powf(b / a, r) + powf(c / a, r)), rinv);
y = b * x / a;
z = c * x / a;
}
}
co[0] = x;
co[1] = y;
co[2] = z;
} | [
"static",
"void",
"snap_to_superellipsoid",
"(",
"float",
"co",
"[",
"3",
"]",
",",
"const",
"float",
"super_r",
",",
"bool",
"midline",
")",
"{",
"float",
"a",
",",
"b",
",",
"c",
",",
"x",
",",
"y",
",",
"z",
",",
"r",
",",
"rinv",
",",
"dx",
",",
"dy",
";",
"r",
"=",
"super_r",
";",
"if",
"(",
"r",
"==",
"PRO_CIRCLE_R",
")",
"{",
"normalize_v3",
"(",
"co",
")",
";",
"return",
";",
"}",
"x",
"=",
"a",
"=",
"max_ff",
"(",
"0.0f",
",",
"co",
"[",
"0",
"]",
")",
";",
"y",
"=",
"b",
"=",
"max_ff",
"(",
"0.0f",
",",
"co",
"[",
"1",
"]",
")",
";",
"z",
"=",
"c",
"=",
"max_ff",
"(",
"0.0f",
",",
"co",
"[",
"2",
"]",
")",
";",
"if",
"(",
"r",
"==",
"PRO_SQUARE_R",
"||",
"r",
"==",
"PRO_SQUARE_IN_R",
")",
"{",
"BLI_assert",
"(",
"fabsf",
"(",
"z",
")",
"<",
"BEVEL_EPSILON",
")",
";",
"z",
"=",
"0.0f",
";",
"x",
"=",
"min_ff",
"(",
"1.0f",
",",
"x",
")",
";",
"y",
"=",
"min_ff",
"(",
"1.0f",
",",
"y",
")",
";",
"if",
"(",
"r",
"==",
"PRO_SQUARE_R",
")",
"{",
"dx",
"=",
"1.0f",
"-",
"x",
";",
"dy",
"=",
"1.0f",
"-",
"y",
";",
"if",
"(",
"dx",
"<",
"dy",
")",
"{",
"x",
"=",
"1.0f",
";",
"y",
"=",
"midline",
"?",
"1.0f",
":",
"y",
";",
"}",
"else",
"{",
"y",
"=",
"1.0f",
";",
"x",
"=",
"midline",
"?",
"1.0f",
":",
"x",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"x",
"<",
"y",
")",
"{",
"x",
"=",
"0.0f",
";",
"y",
"=",
"midline",
"?",
"0.0f",
":",
"y",
";",
"}",
"else",
"{",
"y",
"=",
"0.0f",
";",
"x",
"=",
"midline",
"?",
"0.0f",
":",
"x",
";",
"}",
"}",
"}",
"else",
"{",
"rinv",
"=",
"1.0f",
"/",
"r",
";",
"if",
"(",
"a",
"==",
"0.0f",
")",
"{",
"if",
"(",
"b",
"==",
"0.0f",
")",
"{",
"x",
"=",
"0.0f",
";",
"y",
"=",
"0.0f",
";",
"z",
"=",
"powf",
"(",
"c",
",",
"rinv",
")",
";",
"}",
"else",
"{",
"x",
"=",
"0.0f",
";",
"y",
"=",
"powf",
"(",
"1.0f",
"/",
"(",
"1.0f",
"+",
"powf",
"(",
"c",
"/",
"b",
",",
"r",
")",
")",
",",
"rinv",
")",
";",
"z",
"=",
"c",
"*",
"y",
"/",
"b",
";",
"}",
"}",
"else",
"{",
"x",
"=",
"powf",
"(",
"1.0f",
"/",
"(",
"1.0f",
"+",
"powf",
"(",
"b",
"/",
"a",
",",
"r",
")",
"+",
"powf",
"(",
"c",
"/",
"a",
",",
"r",
")",
")",
",",
"rinv",
")",
";",
"y",
"=",
"b",
"*",
"x",
"/",
"a",
";",
"z",
"=",
"c",
"*",
"x",
"/",
"a",
";",
"}",
"}",
"co",
"[",
"0",
"]",
"=",
"x",
";",
"co",
"[",
"1",
"]",
"=",
"y",
";",
"co",
"[",
"2",
"]",
"=",
"z",
";",
"}"
] | Snap a direction co to a superellipsoid with parameter super_r. | [
"Snap",
"a",
"direction",
"co",
"to",
"a",
"superellipsoid",
"with",
"parameter",
"super_r",
"."
] | [
"/* will only be called for 2d profile */",
"/* snap to closer of x==1 and y==1 lines, or maybe both */",
"/* snap to closer of x==0 and y==0 lines, or maybe both */"
] | [
{
"param": "co",
"type": "float"
},
{
"param": "super_r",
"type": "float"
},
{
"param": "midline",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "co",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "super_r",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "midline",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | bevel_edges_sharp_boundary | void | static void bevel_edges_sharp_boundary(BMesh *bm, BevelParams *bp)
{
BMIter fiter, liter;
BMFace *f, *fother;
BMLoop *l, *lother;
FKind fkind;
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(f, BM_ELEM_SMOOTH)) {
continue;
}
if (get_face_kind(bp, f) != F_RECON) {
continue;
}
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
/* cases we care about will have exactly one adjacent face */
lother = l->radial_next;
fother = lother->f;
if (lother != l && fother) {
fkind = get_face_kind(bp, lother->f);
if (ELEM(fkind, F_EDGE, F_VERT)) {
BM_elem_flag_disable(l->e, BM_ELEM_SMOOTH);
}
}
}
}
} | /* Mark edges as sharp if they are between a smooth recon face and a new face. */ | Mark edges as sharp if they are between a smooth recon face and a new face. | [
"Mark",
"edges",
"as",
"sharp",
"if",
"they",
"are",
"between",
"a",
"smooth",
"recon",
"face",
"and",
"a",
"new",
"face",
"."
] | static void bevel_edges_sharp_boundary(BMesh *bm, BevelParams *bp)
{
BMIter fiter, liter;
BMFace *f, *fother;
BMLoop *l, *lother;
FKind fkind;
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(f, BM_ELEM_SMOOTH)) {
continue;
}
if (get_face_kind(bp, f) != F_RECON) {
continue;
}
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
lother = l->radial_next;
fother = lother->f;
if (lother != l && fother) {
fkind = get_face_kind(bp, lother->f);
if (ELEM(fkind, F_EDGE, F_VERT)) {
BM_elem_flag_disable(l->e, BM_ELEM_SMOOTH);
}
}
}
}
} | [
"static",
"void",
"bevel_edges_sharp_boundary",
"(",
"BMesh",
"*",
"bm",
",",
"BevelParams",
"*",
"bp",
")",
"{",
"BMIter",
"fiter",
",",
"liter",
";",
"BMFace",
"*",
"f",
",",
"*",
"fother",
";",
"BMLoop",
"*",
"l",
",",
"*",
"lother",
";",
"FKind",
"fkind",
";",
"BM_ITER_MESH",
"(",
"f",
",",
"&",
"fiter",
",",
"bm",
",",
"BM_FACES_OF_MESH",
")",
"",
"{",
"if",
"(",
"!",
"BM_elem_flag_test",
"(",
"f",
",",
"BM_ELEM_SMOOTH",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"get_face_kind",
"(",
"bp",
",",
"f",
")",
"!=",
"F_RECON",
")",
"{",
"continue",
";",
"}",
"BM_ITER_ELEM",
"(",
"l",
",",
"&",
"liter",
",",
"f",
",",
"BM_LOOPS_OF_FACE",
")",
"",
"{",
"lother",
"=",
"l",
"->",
"radial_next",
";",
"fother",
"=",
"lother",
"->",
"f",
";",
"if",
"(",
"lother",
"!=",
"l",
"&&",
"fother",
")",
"{",
"fkind",
"=",
"get_face_kind",
"(",
"bp",
",",
"lother",
"->",
"f",
")",
";",
"if",
"(",
"ELEM",
"(",
"fkind",
",",
"F_EDGE",
",",
"F_VERT",
")",
")",
"{",
"BM_elem_flag_disable",
"(",
"l",
"->",
"e",
",",
"BM_ELEM_SMOOTH",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Mark edges as sharp if they are between a smooth recon face and a new face. | [
"Mark",
"edges",
"as",
"sharp",
"if",
"they",
"are",
"between",
"a",
"smooth",
"recon",
"face",
"and",
"a",
"new",
"face",
"."
] | [
"/* cases we care about will have exactly one adjacent face */"
] | [
{
"param": "bm",
"type": "BMesh"
},
{
"param": "bp",
"type": "BevelParams"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bm",
"type": "BMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bp",
"type": "BevelParams",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | bevel_harden_normals | void | static void bevel_harden_normals(BMesh *bm, BevelParams *bp)
{
BMIter liter, fiter;
BMFace *f;
BMLoop *l, *lnext, *lprev, *lprevprev, *lnextnext;
BMEdge *estep;
FKind fkind, fprevkind, fnextkind, fprevprevkind, fnextnextkind;
int cd_clnors_offset, l_index;
short *clnors;
float *pnorm, norm[3];
if (bp->offset == 0.0 || !bp->harden_normals) {
return;
}
/* recalculate all face and vertex normals; side effect: ensures vertex, edge, face indices */
/* I suspect this is not necessary: TODO: test that guess */
BM_mesh_normals_update(bm);
cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
/* If there is not already a custom split normal layer then making one (with BM_lnorspace_update)
* will not respect the autosmooth angle between smooth faces. To get that to happen, we have
* to mark the sharpen the edges that are only sharp because
* of the angle test -- otherwise would be smooth.
*/
if (cd_clnors_offset == -1) {
BM_edges_sharp_from_angle_set(bm, bp->smoothresh);
bevel_edges_sharp_boundary(bm, bp);
}
/* Ensure that bm->lnor_spacearr has properly stored loop normals;
* side effect: ensures loop indices. */
BM_lnorspace_update(bm);
if (cd_clnors_offset == -1) {
cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
}
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
fkind = get_face_kind(bp, f);
if (fkind == F_ORIG || fkind == F_RECON) {
continue;
}
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
estep = l->prev->e; /* causes CW walk around l->v fan */
lprev = BM_vert_step_fan_loop(l, &estep);
estep = l->e; /* causes CCW walk around l->v fan */
lnext = BM_vert_step_fan_loop(l, &estep);
fprevkind = lprev ? get_face_kind(bp, lprev->f) : F_NONE;
fnextkind = lnext ? get_face_kind(bp, lnext->f) : F_NONE;
pnorm = NULL;
if (fkind == F_EDGE) {
if (fprevkind == F_EDGE && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
add_v3_v3v3(norm, f->no, lprev->f->no);
pnorm = norm;
}
else if (fnextkind == F_EDGE && BM_elem_flag_test(lnext, BM_ELEM_LONG_TAG)) {
add_v3_v3v3(norm, f->no, lnext->f->no);
pnorm = norm;
}
else if (fprevkind == F_RECON && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
pnorm = lprev->f->no;
}
else if (fnextkind == F_RECON && BM_elem_flag_test(l->prev, BM_ELEM_LONG_TAG)) {
pnorm = lnext->f->no;
}
else {
/* printf("unexpected harden case (edge)\n"); */
}
}
else if (fkind == F_VERT) {
if (fprevkind == F_VERT && fnextkind == F_VERT) {
pnorm = l->v->no;
}
else if (fprevkind == F_RECON) {
pnorm = lprev->f->no;
}
else if (fnextkind == F_RECON) {
pnorm = lnext->f->no;
}
else {
if (lprev) {
estep = lprev->prev->e;
lprevprev = BM_vert_step_fan_loop(lprev, &estep);
}
else {
lprevprev = NULL;
}
if (lnext) {
estep = lnext->e;
lnextnext = BM_vert_step_fan_loop(lnext, &estep);
}
else {
lnextnext = NULL;
}
fprevprevkind = lprevprev ? get_face_kind(bp, lprevprev->f) : F_NONE;
fnextnextkind = lnextnext ? get_face_kind(bp, lnextnext->f) : F_NONE;
if (fprevkind == F_EDGE && fprevprevkind == F_RECON) {
pnorm = lprevprev->f->no;
}
else if (fprevkind == F_EDGE && fnextkind == F_VERT && fprevprevkind == F_EDGE) {
add_v3_v3v3(norm, lprev->f->no, lprevprev->f->no);
pnorm = norm;
}
else if (fnextkind == F_EDGE && fprevkind == F_VERT && fnextnextkind == F_EDGE) {
add_v3_v3v3(norm, lnext->f->no, lnextnext->f->no);
pnorm = norm;
}
else {
/* printf("unexpected harden case (vert)\n"); */
}
}
}
if (pnorm) {
if (pnorm == norm) {
normalize_v3(norm);
}
l_index = BM_elem_index_get(l);
clnors = BM_ELEM_CD_GET_VOID_P(l, cd_clnors_offset);
BKE_lnor_space_custom_normal_to_data(bm->lnor_spacearr->lspacearr[l_index], pnorm, clnors);
}
}
}
} | /**
* Harden normals for bevel.
* The desired effect is that the newly created #F_EDGE and F_VERT faces appear smoothly shaded
* with the normals at the boundaries with #F_RECON faces matching those recon faces.
* And at boundaries between #F_EDGE and #F_VERT faces, the normals should match the #F_EDGE ones.
* Assumes custom loop normals are in use.
*/ | Harden normals for bevel.
The desired effect is that the newly created #F_EDGE and F_VERT faces appear smoothly shaded
with the normals at the boundaries with #F_RECON faces matching those recon faces.
And at boundaries between #F_EDGE and #F_VERT faces, the normals should match the #F_EDGE ones.
Assumes custom loop normals are in use. | [
"Harden",
"normals",
"for",
"bevel",
".",
"The",
"desired",
"effect",
"is",
"that",
"the",
"newly",
"created",
"#F_EDGE",
"and",
"F_VERT",
"faces",
"appear",
"smoothly",
"shaded",
"with",
"the",
"normals",
"at",
"the",
"boundaries",
"with",
"#F_RECON",
"faces",
"matching",
"those",
"recon",
"faces",
".",
"And",
"at",
"boundaries",
"between",
"#F_EDGE",
"and",
"#F_VERT",
"faces",
"the",
"normals",
"should",
"match",
"the",
"#F_EDGE",
"ones",
".",
"Assumes",
"custom",
"loop",
"normals",
"are",
"in",
"use",
"."
] | static void bevel_harden_normals(BMesh *bm, BevelParams *bp)
{
BMIter liter, fiter;
BMFace *f;
BMLoop *l, *lnext, *lprev, *lprevprev, *lnextnext;
BMEdge *estep;
FKind fkind, fprevkind, fnextkind, fprevprevkind, fnextnextkind;
int cd_clnors_offset, l_index;
short *clnors;
float *pnorm, norm[3];
if (bp->offset == 0.0 || !bp->harden_normals) {
return;
}
BM_mesh_normals_update(bm);
cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
if (cd_clnors_offset == -1) {
BM_edges_sharp_from_angle_set(bm, bp->smoothresh);
bevel_edges_sharp_boundary(bm, bp);
}
BM_lnorspace_update(bm);
if (cd_clnors_offset == -1) {
cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
}
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
fkind = get_face_kind(bp, f);
if (fkind == F_ORIG || fkind == F_RECON) {
continue;
}
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
estep = l->prev->e;
lprev = BM_vert_step_fan_loop(l, &estep);
estep = l->e;
lnext = BM_vert_step_fan_loop(l, &estep);
fprevkind = lprev ? get_face_kind(bp, lprev->f) : F_NONE;
fnextkind = lnext ? get_face_kind(bp, lnext->f) : F_NONE;
pnorm = NULL;
if (fkind == F_EDGE) {
if (fprevkind == F_EDGE && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
add_v3_v3v3(norm, f->no, lprev->f->no);
pnorm = norm;
}
else if (fnextkind == F_EDGE && BM_elem_flag_test(lnext, BM_ELEM_LONG_TAG)) {
add_v3_v3v3(norm, f->no, lnext->f->no);
pnorm = norm;
}
else if (fprevkind == F_RECON && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
pnorm = lprev->f->no;
}
else if (fnextkind == F_RECON && BM_elem_flag_test(l->prev, BM_ELEM_LONG_TAG)) {
pnorm = lnext->f->no;
}
else {
}
}
else if (fkind == F_VERT) {
if (fprevkind == F_VERT && fnextkind == F_VERT) {
pnorm = l->v->no;
}
else if (fprevkind == F_RECON) {
pnorm = lprev->f->no;
}
else if (fnextkind == F_RECON) {
pnorm = lnext->f->no;
}
else {
if (lprev) {
estep = lprev->prev->e;
lprevprev = BM_vert_step_fan_loop(lprev, &estep);
}
else {
lprevprev = NULL;
}
if (lnext) {
estep = lnext->e;
lnextnext = BM_vert_step_fan_loop(lnext, &estep);
}
else {
lnextnext = NULL;
}
fprevprevkind = lprevprev ? get_face_kind(bp, lprevprev->f) : F_NONE;
fnextnextkind = lnextnext ? get_face_kind(bp, lnextnext->f) : F_NONE;
if (fprevkind == F_EDGE && fprevprevkind == F_RECON) {
pnorm = lprevprev->f->no;
}
else if (fprevkind == F_EDGE && fnextkind == F_VERT && fprevprevkind == F_EDGE) {
add_v3_v3v3(norm, lprev->f->no, lprevprev->f->no);
pnorm = norm;
}
else if (fnextkind == F_EDGE && fprevkind == F_VERT && fnextnextkind == F_EDGE) {
add_v3_v3v3(norm, lnext->f->no, lnextnext->f->no);
pnorm = norm;
}
else {
}
}
}
if (pnorm) {
if (pnorm == norm) {
normalize_v3(norm);
}
l_index = BM_elem_index_get(l);
clnors = BM_ELEM_CD_GET_VOID_P(l, cd_clnors_offset);
BKE_lnor_space_custom_normal_to_data(bm->lnor_spacearr->lspacearr[l_index], pnorm, clnors);
}
}
}
} | [
"static",
"void",
"bevel_harden_normals",
"(",
"BMesh",
"*",
"bm",
",",
"BevelParams",
"*",
"bp",
")",
"{",
"BMIter",
"liter",
",",
"fiter",
";",
"BMFace",
"*",
"f",
";",
"BMLoop",
"*",
"l",
",",
"*",
"lnext",
",",
"*",
"lprev",
",",
"*",
"lprevprev",
",",
"*",
"lnextnext",
";",
"BMEdge",
"*",
"estep",
";",
"FKind",
"fkind",
",",
"fprevkind",
",",
"fnextkind",
",",
"fprevprevkind",
",",
"fnextnextkind",
";",
"int",
"cd_clnors_offset",
",",
"l_index",
";",
"short",
"*",
"clnors",
";",
"float",
"*",
"pnorm",
",",
"norm",
"[",
"3",
"]",
";",
"if",
"(",
"bp",
"->",
"offset",
"==",
"0.0",
"||",
"!",
"bp",
"->",
"harden_normals",
")",
"{",
"return",
";",
"}",
"BM_mesh_normals_update",
"(",
"bm",
")",
";",
"cd_clnors_offset",
"=",
"CustomData_get_offset",
"(",
"&",
"bm",
"->",
"ldata",
",",
"CD_CUSTOMLOOPNORMAL",
")",
";",
"if",
"(",
"cd_clnors_offset",
"==",
"-1",
")",
"{",
"BM_edges_sharp_from_angle_set",
"(",
"bm",
",",
"bp",
"->",
"smoothresh",
")",
";",
"bevel_edges_sharp_boundary",
"(",
"bm",
",",
"bp",
")",
";",
"}",
"BM_lnorspace_update",
"(",
"bm",
")",
";",
"if",
"(",
"cd_clnors_offset",
"==",
"-1",
")",
"{",
"cd_clnors_offset",
"=",
"CustomData_get_offset",
"(",
"&",
"bm",
"->",
"ldata",
",",
"CD_CUSTOMLOOPNORMAL",
")",
";",
"}",
"BM_ITER_MESH",
"(",
"f",
",",
"&",
"fiter",
",",
"bm",
",",
"BM_FACES_OF_MESH",
")",
"",
"{",
"fkind",
"=",
"get_face_kind",
"(",
"bp",
",",
"f",
")",
";",
"if",
"(",
"fkind",
"==",
"F_ORIG",
"||",
"fkind",
"==",
"F_RECON",
")",
"{",
"continue",
";",
"}",
"BM_ITER_ELEM",
"(",
"l",
",",
"&",
"liter",
",",
"f",
",",
"BM_LOOPS_OF_FACE",
")",
"",
"{",
"estep",
"=",
"l",
"->",
"prev",
"->",
"e",
";",
"lprev",
"=",
"BM_vert_step_fan_loop",
"(",
"l",
",",
"&",
"estep",
")",
";",
"estep",
"=",
"l",
"->",
"e",
";",
"lnext",
"=",
"BM_vert_step_fan_loop",
"(",
"l",
",",
"&",
"estep",
")",
";",
"fprevkind",
"=",
"lprev",
"?",
"get_face_kind",
"(",
"bp",
",",
"lprev",
"->",
"f",
")",
":",
"F_NONE",
";",
"fnextkind",
"=",
"lnext",
"?",
"get_face_kind",
"(",
"bp",
",",
"lnext",
"->",
"f",
")",
":",
"F_NONE",
";",
"pnorm",
"=",
"NULL",
";",
"if",
"(",
"fkind",
"==",
"F_EDGE",
")",
"{",
"if",
"(",
"fprevkind",
"==",
"F_EDGE",
"&&",
"BM_elem_flag_test",
"(",
"l",
",",
"BM_ELEM_LONG_TAG",
")",
")",
"{",
"add_v3_v3v3",
"(",
"norm",
",",
"f",
"->",
"no",
",",
"lprev",
"->",
"f",
"->",
"no",
")",
";",
"pnorm",
"=",
"norm",
";",
"}",
"else",
"if",
"(",
"fnextkind",
"==",
"F_EDGE",
"&&",
"BM_elem_flag_test",
"(",
"lnext",
",",
"BM_ELEM_LONG_TAG",
")",
")",
"{",
"add_v3_v3v3",
"(",
"norm",
",",
"f",
"->",
"no",
",",
"lnext",
"->",
"f",
"->",
"no",
")",
";",
"pnorm",
"=",
"norm",
";",
"}",
"else",
"if",
"(",
"fprevkind",
"==",
"F_RECON",
"&&",
"BM_elem_flag_test",
"(",
"l",
",",
"BM_ELEM_LONG_TAG",
")",
")",
"{",
"pnorm",
"=",
"lprev",
"->",
"f",
"->",
"no",
";",
"}",
"else",
"if",
"(",
"fnextkind",
"==",
"F_RECON",
"&&",
"BM_elem_flag_test",
"(",
"l",
"->",
"prev",
",",
"BM_ELEM_LONG_TAG",
")",
")",
"{",
"pnorm",
"=",
"lnext",
"->",
"f",
"->",
"no",
";",
"}",
"else",
"{",
"}",
"}",
"else",
"if",
"(",
"fkind",
"==",
"F_VERT",
")",
"{",
"if",
"(",
"fprevkind",
"==",
"F_VERT",
"&&",
"fnextkind",
"==",
"F_VERT",
")",
"{",
"pnorm",
"=",
"l",
"->",
"v",
"->",
"no",
";",
"}",
"else",
"if",
"(",
"fprevkind",
"==",
"F_RECON",
")",
"{",
"pnorm",
"=",
"lprev",
"->",
"f",
"->",
"no",
";",
"}",
"else",
"if",
"(",
"fnextkind",
"==",
"F_RECON",
")",
"{",
"pnorm",
"=",
"lnext",
"->",
"f",
"->",
"no",
";",
"}",
"else",
"{",
"if",
"(",
"lprev",
")",
"{",
"estep",
"=",
"lprev",
"->",
"prev",
"->",
"e",
";",
"lprevprev",
"=",
"BM_vert_step_fan_loop",
"(",
"lprev",
",",
"&",
"estep",
")",
";",
"}",
"else",
"{",
"lprevprev",
"=",
"NULL",
";",
"}",
"if",
"(",
"lnext",
")",
"{",
"estep",
"=",
"lnext",
"->",
"e",
";",
"lnextnext",
"=",
"BM_vert_step_fan_loop",
"(",
"lnext",
",",
"&",
"estep",
")",
";",
"}",
"else",
"{",
"lnextnext",
"=",
"NULL",
";",
"}",
"fprevprevkind",
"=",
"lprevprev",
"?",
"get_face_kind",
"(",
"bp",
",",
"lprevprev",
"->",
"f",
")",
":",
"F_NONE",
";",
"fnextnextkind",
"=",
"lnextnext",
"?",
"get_face_kind",
"(",
"bp",
",",
"lnextnext",
"->",
"f",
")",
":",
"F_NONE",
";",
"if",
"(",
"fprevkind",
"==",
"F_EDGE",
"&&",
"fprevprevkind",
"==",
"F_RECON",
")",
"{",
"pnorm",
"=",
"lprevprev",
"->",
"f",
"->",
"no",
";",
"}",
"else",
"if",
"(",
"fprevkind",
"==",
"F_EDGE",
"&&",
"fnextkind",
"==",
"F_VERT",
"&&",
"fprevprevkind",
"==",
"F_EDGE",
")",
"{",
"add_v3_v3v3",
"(",
"norm",
",",
"lprev",
"->",
"f",
"->",
"no",
",",
"lprevprev",
"->",
"f",
"->",
"no",
")",
";",
"pnorm",
"=",
"norm",
";",
"}",
"else",
"if",
"(",
"fnextkind",
"==",
"F_EDGE",
"&&",
"fprevkind",
"==",
"F_VERT",
"&&",
"fnextnextkind",
"==",
"F_EDGE",
")",
"{",
"add_v3_v3v3",
"(",
"norm",
",",
"lnext",
"->",
"f",
"->",
"no",
",",
"lnextnext",
"->",
"f",
"->",
"no",
")",
";",
"pnorm",
"=",
"norm",
";",
"}",
"else",
"{",
"}",
"}",
"}",
"if",
"(",
"pnorm",
")",
"{",
"if",
"(",
"pnorm",
"==",
"norm",
")",
"{",
"normalize_v3",
"(",
"norm",
")",
";",
"}",
"l_index",
"=",
"BM_elem_index_get",
"(",
"l",
")",
";",
"clnors",
"=",
"BM_ELEM_CD_GET_VOID_P",
"(",
"l",
",",
"cd_clnors_offset",
")",
";",
"BKE_lnor_space_custom_normal_to_data",
"(",
"bm",
"->",
"lnor_spacearr",
"->",
"lspacearr",
"[",
"l_index",
"]",
",",
"pnorm",
",",
"clnors",
")",
";",
"}",
"}",
"}",
"}"
] | Harden normals for bevel. | [
"Harden",
"normals",
"for",
"bevel",
"."
] | [
"/* recalculate all face and vertex normals; side effect: ensures vertex, edge, face indices */",
"/* I suspect this is not necessary: TODO: test that guess */",
"/* If there is not already a custom split normal layer then making one (with BM_lnorspace_update)\n * will not respect the autosmooth angle between smooth faces. To get that to happen, we have\n * to mark the sharpen the edges that are only sharp because\n * of the angle test -- otherwise would be smooth.\n */",
"/* Ensure that bm->lnor_spacearr has properly stored loop normals;\n * side effect: ensures loop indices. */",
"/* causes CW walk around l->v fan */",
"/* causes CCW walk around l->v fan */",
"/* printf(\"unexpected harden case (edge)\\n\"); */",
"/* printf(\"unexpected harden case (vert)\\n\"); */"
] | [
{
"param": "bm",
"type": "BMesh"
},
{
"param": "bp",
"type": "BevelParams"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bm",
"type": "BMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bp",
"type": "BevelParams",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | calculate_vm_profiles | void | static void calculate_vm_profiles(BevelParams *bp, BevVert *bv, VMesh *vm)
{
BoundVert *v;
v = vm->boundstart;
do {
set_profile_params(bp, bv, v);
calculate_profile(bp, v);
} while ((v = v->next) != vm->boundstart);
} | /* Calculate the profiles for all the BoundVerts of VMesh vm */ | Calculate the profiles for all the BoundVerts of VMesh vm | [
"Calculate",
"the",
"profiles",
"for",
"all",
"the",
"BoundVerts",
"of",
"VMesh",
"vm"
] | static void calculate_vm_profiles(BevelParams *bp, BevVert *bv, VMesh *vm)
{
BoundVert *v;
v = vm->boundstart;
do {
set_profile_params(bp, bv, v);
calculate_profile(bp, v);
} while ((v = v->next) != vm->boundstart);
} | [
"static",
"void",
"calculate_vm_profiles",
"(",
"BevelParams",
"*",
"bp",
",",
"BevVert",
"*",
"bv",
",",
"VMesh",
"*",
"vm",
")",
"{",
"BoundVert",
"*",
"v",
";",
"v",
"=",
"vm",
"->",
"boundstart",
";",
"do",
"{",
"set_profile_params",
"(",
"bp",
",",
"bv",
",",
"v",
")",
";",
"calculate_profile",
"(",
"bp",
",",
"v",
")",
";",
"}",
"while",
"(",
"(",
"v",
"=",
"v",
"->",
"next",
")",
"!=",
"vm",
"->",
"boundstart",
")",
";",
"}"
] | Calculate the profiles for all the BoundVerts of VMesh vm | [
"Calculate",
"the",
"profiles",
"for",
"all",
"the",
"BoundVerts",
"of",
"VMesh",
"vm"
] | [] | [
{
"param": "bp",
"type": "BevelParams"
},
{
"param": "bv",
"type": "BevVert"
},
{
"param": "vm",
"type": "VMesh"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bp",
"type": "BevelParams",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bv",
"type": "BevVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vm",
"type": "VMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | build_boundary_vertex_only | void | static void build_boundary_vertex_only(BevelParams *bp, BevVert *bv, bool construct)
{
VMesh *vm = bv->vmesh;
EdgeHalf *efirst, *e;
BoundVert *v;
float co[3];
BLI_assert(bp->vertex_only);
e = efirst = &bv->edges[0];
do {
slide_dist(e, bv->v, e->offset_l, co);
if (construct) {
v = add_new_bound_vert(bp->mem_arena, vm, co);
v->efirst = v->elast = e;
e->leftv = e->rightv = v;
}
else {
adjust_bound_vert(e->leftv, co);
}
} while ((e = e->next) != efirst);
calculate_vm_profiles(bp, bv, vm);
if (construct) {
set_bound_vert_seams(bv, bp->mark_seam, bp->mark_sharp);
if (vm->count == 2) {
vm->mesh_kind = M_NONE;
}
else if (bp->seg == 1) {
vm->mesh_kind = M_POLY;
}
else {
vm->mesh_kind = M_ADJ;
}
}
} | /* Implements build_boundary for vertex-only case */ | Implements build_boundary for vertex-only case | [
"Implements",
"build_boundary",
"for",
"vertex",
"-",
"only",
"case"
] | static void build_boundary_vertex_only(BevelParams *bp, BevVert *bv, bool construct)
{
VMesh *vm = bv->vmesh;
EdgeHalf *efirst, *e;
BoundVert *v;
float co[3];
BLI_assert(bp->vertex_only);
e = efirst = &bv->edges[0];
do {
slide_dist(e, bv->v, e->offset_l, co);
if (construct) {
v = add_new_bound_vert(bp->mem_arena, vm, co);
v->efirst = v->elast = e;
e->leftv = e->rightv = v;
}
else {
adjust_bound_vert(e->leftv, co);
}
} while ((e = e->next) != efirst);
calculate_vm_profiles(bp, bv, vm);
if (construct) {
set_bound_vert_seams(bv, bp->mark_seam, bp->mark_sharp);
if (vm->count == 2) {
vm->mesh_kind = M_NONE;
}
else if (bp->seg == 1) {
vm->mesh_kind = M_POLY;
}
else {
vm->mesh_kind = M_ADJ;
}
}
} | [
"static",
"void",
"build_boundary_vertex_only",
"(",
"BevelParams",
"*",
"bp",
",",
"BevVert",
"*",
"bv",
",",
"bool",
"construct",
")",
"{",
"VMesh",
"*",
"vm",
"=",
"bv",
"->",
"vmesh",
";",
"EdgeHalf",
"*",
"efirst",
",",
"*",
"e",
";",
"BoundVert",
"*",
"v",
";",
"float",
"co",
"[",
"3",
"]",
";",
"BLI_assert",
"(",
"bp",
"->",
"vertex_only",
")",
";",
"e",
"=",
"efirst",
"=",
"&",
"bv",
"->",
"edges",
"[",
"0",
"]",
";",
"do",
"{",
"slide_dist",
"(",
"e",
",",
"bv",
"->",
"v",
",",
"e",
"->",
"offset_l",
",",
"co",
")",
";",
"if",
"(",
"construct",
")",
"{",
"v",
"=",
"add_new_bound_vert",
"(",
"bp",
"->",
"mem_arena",
",",
"vm",
",",
"co",
")",
";",
"v",
"->",
"efirst",
"=",
"v",
"->",
"elast",
"=",
"e",
";",
"e",
"->",
"leftv",
"=",
"e",
"->",
"rightv",
"=",
"v",
";",
"}",
"else",
"{",
"adjust_bound_vert",
"(",
"e",
"->",
"leftv",
",",
"co",
")",
";",
"}",
"}",
"while",
"(",
"(",
"e",
"=",
"e",
"->",
"next",
")",
"!=",
"efirst",
")",
";",
"calculate_vm_profiles",
"(",
"bp",
",",
"bv",
",",
"vm",
")",
";",
"if",
"(",
"construct",
")",
"{",
"set_bound_vert_seams",
"(",
"bv",
",",
"bp",
"->",
"mark_seam",
",",
"bp",
"->",
"mark_sharp",
")",
";",
"if",
"(",
"vm",
"->",
"count",
"==",
"2",
")",
"{",
"vm",
"->",
"mesh_kind",
"=",
"M_NONE",
";",
"}",
"else",
"if",
"(",
"bp",
"->",
"seg",
"==",
"1",
")",
"{",
"vm",
"->",
"mesh_kind",
"=",
"M_POLY",
";",
"}",
"else",
"{",
"vm",
"->",
"mesh_kind",
"=",
"M_ADJ",
";",
"}",
"}",
"}"
] | Implements build_boundary for vertex-only case | [
"Implements",
"build_boundary",
"for",
"vertex",
"-",
"only",
"case"
] | [] | [
{
"param": "bp",
"type": "BevelParams"
},
{
"param": "bv",
"type": "BevVert"
},
{
"param": "construct",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bp",
"type": "BevelParams",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bv",
"type": "BevVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "construct",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | build_boundary_terminal_edge | void | static void build_boundary_terminal_edge(BevelParams *bp,
BevVert *bv,
EdgeHalf *efirst,
bool construct)
{
MemArena *mem_arena = bp->mem_arena;
VMesh *vm = bv->vmesh;
BoundVert *v;
EdgeHalf *e;
const float *no;
float co[3], d;
e = efirst;
if (bv->edgecount == 2) {
/* only 2 edges in, so terminate the edge with an artificial vertex on the unbeveled edge */
no = e->fprev ? e->fprev->no : (e->fnext ? e->fnext->no : NULL);
offset_in_plane(e, no, true, co);
if (construct) {
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = v->elast = v->ebev = e;
e->leftv = v;
}
else {
adjust_bound_vert(e->leftv, co);
}
no = e->fnext ? e->fnext->no : (e->fprev ? e->fprev->no : NULL);
offset_in_plane(e, no, false, co);
if (construct) {
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = v->elast = e;
e->rightv = v;
}
else {
adjust_bound_vert(e->rightv, co);
}
/* make artificial extra point along unbeveled edge, and form triangle */
slide_dist(e->next, bv->v, e->offset_l, co);
if (construct) {
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = v->elast = e->next;
e->next->leftv = e->next->rightv = v;
/* could use M_POLY too, but tri-fan looks nicer)*/
vm->mesh_kind = M_TRI_FAN;
set_bound_vert_seams(bv, bp->mark_seam, bp->mark_sharp);
}
else {
adjust_bound_vert(e->next->leftv, co);
}
}
else {
/* More than 2 edges in. Put on-edge verts on all the other edges
* and join with the beveled edge to make a poly or adj mesh,
* Because e->prev has offset 0, offset_meet will put co on that edge. */
/* TODO: should do something else if angle between e and e->prev > 180 */
offset_meet(e->prev, e, bv->v, e->fprev, false, co);
if (construct) {
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = e->prev;
v->elast = v->ebev = e;
e->leftv = v;
e->prev->leftv = e->prev->rightv = v;
}
else {
adjust_bound_vert(e->leftv, co);
}
e = e->next;
offset_meet(e->prev, e, bv->v, e->fprev, false, co);
if (construct) {
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = e->prev;
v->elast = e;
e->leftv = e->rightv = v;
e->prev->rightv = v;
}
else {
adjust_bound_vert(e->leftv, co);
}
/* For the edges not adjacent to the beveled edge, slide the bevel amount along. */
d = efirst->offset_l_spec;
for (e = e->next; e->next != efirst; e = e->next) {
slide_dist(e, bv->v, d, co);
if (construct) {
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = v->elast = e;
e->leftv = e->rightv = v;
}
else {
adjust_bound_vert(e->leftv, co);
}
}
}
calculate_vm_profiles(bp, bv, vm);
if (bv->edgecount >= 3) {
/* special case: snap profile to plane of adjacent two edges */
v = vm->boundstart;
BLI_assert(v->ebev != NULL);
move_profile_plane(v, bv->v);
calculate_profile(bp, v);
}
if (construct) {
set_bound_vert_seams(bv, bp->mark_seam, bp->mark_sharp);
if (vm->count == 2 && bv->edgecount == 3) {
vm->mesh_kind = M_NONE;
}
else if (vm->count == 3) {
vm->mesh_kind = M_TRI_FAN;
}
else {
vm->mesh_kind = M_POLY;
}
}
} | /**
* Special case of build_boundary when a single edge is beveled.
* The 'width adjust' part of build_boundary has been done already,
* and \a efirst is the first beveled edge at vertex \a bv.
*/ | Special case of build_boundary when a single edge is beveled.
The 'width adjust' part of build_boundary has been done already,
and \a efirst is the first beveled edge at vertex \a bv. | [
"Special",
"case",
"of",
"build_boundary",
"when",
"a",
"single",
"edge",
"is",
"beveled",
".",
"The",
"'",
"width",
"adjust",
"'",
"part",
"of",
"build_boundary",
"has",
"been",
"done",
"already",
"and",
"\\",
"a",
"efirst",
"is",
"the",
"first",
"beveled",
"edge",
"at",
"vertex",
"\\",
"a",
"bv",
"."
] | static void build_boundary_terminal_edge(BevelParams *bp,
BevVert *bv,
EdgeHalf *efirst,
bool construct)
{
MemArena *mem_arena = bp->mem_arena;
VMesh *vm = bv->vmesh;
BoundVert *v;
EdgeHalf *e;
const float *no;
float co[3], d;
e = efirst;
if (bv->edgecount == 2) {
no = e->fprev ? e->fprev->no : (e->fnext ? e->fnext->no : NULL);
offset_in_plane(e, no, true, co);
if (construct) {
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = v->elast = v->ebev = e;
e->leftv = v;
}
else {
adjust_bound_vert(e->leftv, co);
}
no = e->fnext ? e->fnext->no : (e->fprev ? e->fprev->no : NULL);
offset_in_plane(e, no, false, co);
if (construct) {
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = v->elast = e;
e->rightv = v;
}
else {
adjust_bound_vert(e->rightv, co);
}
slide_dist(e->next, bv->v, e->offset_l, co);
if (construct) {
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = v->elast = e->next;
e->next->leftv = e->next->rightv = v;
vm->mesh_kind = M_TRI_FAN;
set_bound_vert_seams(bv, bp->mark_seam, bp->mark_sharp);
}
else {
adjust_bound_vert(e->next->leftv, co);
}
}
else {
offset_meet(e->prev, e, bv->v, e->fprev, false, co);
if (construct) {
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = e->prev;
v->elast = v->ebev = e;
e->leftv = v;
e->prev->leftv = e->prev->rightv = v;
}
else {
adjust_bound_vert(e->leftv, co);
}
e = e->next;
offset_meet(e->prev, e, bv->v, e->fprev, false, co);
if (construct) {
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = e->prev;
v->elast = e;
e->leftv = e->rightv = v;
e->prev->rightv = v;
}
else {
adjust_bound_vert(e->leftv, co);
}
d = efirst->offset_l_spec;
for (e = e->next; e->next != efirst; e = e->next) {
slide_dist(e, bv->v, d, co);
if (construct) {
v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = v->elast = e;
e->leftv = e->rightv = v;
}
else {
adjust_bound_vert(e->leftv, co);
}
}
}
calculate_vm_profiles(bp, bv, vm);
if (bv->edgecount >= 3) {
v = vm->boundstart;
BLI_assert(v->ebev != NULL);
move_profile_plane(v, bv->v);
calculate_profile(bp, v);
}
if (construct) {
set_bound_vert_seams(bv, bp->mark_seam, bp->mark_sharp);
if (vm->count == 2 && bv->edgecount == 3) {
vm->mesh_kind = M_NONE;
}
else if (vm->count == 3) {
vm->mesh_kind = M_TRI_FAN;
}
else {
vm->mesh_kind = M_POLY;
}
}
} | [
"static",
"void",
"build_boundary_terminal_edge",
"(",
"BevelParams",
"*",
"bp",
",",
"BevVert",
"*",
"bv",
",",
"EdgeHalf",
"*",
"efirst",
",",
"bool",
"construct",
")",
"{",
"MemArena",
"*",
"mem_arena",
"=",
"bp",
"->",
"mem_arena",
";",
"VMesh",
"*",
"vm",
"=",
"bv",
"->",
"vmesh",
";",
"BoundVert",
"*",
"v",
";",
"EdgeHalf",
"*",
"e",
";",
"const",
"float",
"*",
"no",
";",
"float",
"co",
"[",
"3",
"]",
",",
"d",
";",
"e",
"=",
"efirst",
";",
"if",
"(",
"bv",
"->",
"edgecount",
"==",
"2",
")",
"{",
"no",
"=",
"e",
"->",
"fprev",
"?",
"e",
"->",
"fprev",
"->",
"no",
":",
"(",
"e",
"->",
"fnext",
"?",
"e",
"->",
"fnext",
"->",
"no",
":",
"NULL",
")",
";",
"offset_in_plane",
"(",
"e",
",",
"no",
",",
"true",
",",
"co",
")",
";",
"if",
"(",
"construct",
")",
"{",
"v",
"=",
"add_new_bound_vert",
"(",
"mem_arena",
",",
"vm",
",",
"co",
")",
";",
"v",
"->",
"efirst",
"=",
"v",
"->",
"elast",
"=",
"v",
"->",
"ebev",
"=",
"e",
";",
"e",
"->",
"leftv",
"=",
"v",
";",
"}",
"else",
"{",
"adjust_bound_vert",
"(",
"e",
"->",
"leftv",
",",
"co",
")",
";",
"}",
"no",
"=",
"e",
"->",
"fnext",
"?",
"e",
"->",
"fnext",
"->",
"no",
":",
"(",
"e",
"->",
"fprev",
"?",
"e",
"->",
"fprev",
"->",
"no",
":",
"NULL",
")",
";",
"offset_in_plane",
"(",
"e",
",",
"no",
",",
"false",
",",
"co",
")",
";",
"if",
"(",
"construct",
")",
"{",
"v",
"=",
"add_new_bound_vert",
"(",
"mem_arena",
",",
"vm",
",",
"co",
")",
";",
"v",
"->",
"efirst",
"=",
"v",
"->",
"elast",
"=",
"e",
";",
"e",
"->",
"rightv",
"=",
"v",
";",
"}",
"else",
"{",
"adjust_bound_vert",
"(",
"e",
"->",
"rightv",
",",
"co",
")",
";",
"}",
"slide_dist",
"(",
"e",
"->",
"next",
",",
"bv",
"->",
"v",
",",
"e",
"->",
"offset_l",
",",
"co",
")",
";",
"if",
"(",
"construct",
")",
"{",
"v",
"=",
"add_new_bound_vert",
"(",
"mem_arena",
",",
"vm",
",",
"co",
")",
";",
"v",
"->",
"efirst",
"=",
"v",
"->",
"elast",
"=",
"e",
"->",
"next",
";",
"e",
"->",
"next",
"->",
"leftv",
"=",
"e",
"->",
"next",
"->",
"rightv",
"=",
"v",
";",
"vm",
"->",
"mesh_kind",
"=",
"M_TRI_FAN",
";",
"set_bound_vert_seams",
"(",
"bv",
",",
"bp",
"->",
"mark_seam",
",",
"bp",
"->",
"mark_sharp",
")",
";",
"}",
"else",
"{",
"adjust_bound_vert",
"(",
"e",
"->",
"next",
"->",
"leftv",
",",
"co",
")",
";",
"}",
"}",
"else",
"{",
"offset_meet",
"(",
"e",
"->",
"prev",
",",
"e",
",",
"bv",
"->",
"v",
",",
"e",
"->",
"fprev",
",",
"false",
",",
"co",
")",
";",
"if",
"(",
"construct",
")",
"{",
"v",
"=",
"add_new_bound_vert",
"(",
"mem_arena",
",",
"vm",
",",
"co",
")",
";",
"v",
"->",
"efirst",
"=",
"e",
"->",
"prev",
";",
"v",
"->",
"elast",
"=",
"v",
"->",
"ebev",
"=",
"e",
";",
"e",
"->",
"leftv",
"=",
"v",
";",
"e",
"->",
"prev",
"->",
"leftv",
"=",
"e",
"->",
"prev",
"->",
"rightv",
"=",
"v",
";",
"}",
"else",
"{",
"adjust_bound_vert",
"(",
"e",
"->",
"leftv",
",",
"co",
")",
";",
"}",
"e",
"=",
"e",
"->",
"next",
";",
"offset_meet",
"(",
"e",
"->",
"prev",
",",
"e",
",",
"bv",
"->",
"v",
",",
"e",
"->",
"fprev",
",",
"false",
",",
"co",
")",
";",
"if",
"(",
"construct",
")",
"{",
"v",
"=",
"add_new_bound_vert",
"(",
"mem_arena",
",",
"vm",
",",
"co",
")",
";",
"v",
"->",
"efirst",
"=",
"e",
"->",
"prev",
";",
"v",
"->",
"elast",
"=",
"e",
";",
"e",
"->",
"leftv",
"=",
"e",
"->",
"rightv",
"=",
"v",
";",
"e",
"->",
"prev",
"->",
"rightv",
"=",
"v",
";",
"}",
"else",
"{",
"adjust_bound_vert",
"(",
"e",
"->",
"leftv",
",",
"co",
")",
";",
"}",
"d",
"=",
"efirst",
"->",
"offset_l_spec",
";",
"for",
"(",
"e",
"=",
"e",
"->",
"next",
";",
"e",
"->",
"next",
"!=",
"efirst",
";",
"e",
"=",
"e",
"->",
"next",
")",
"{",
"slide_dist",
"(",
"e",
",",
"bv",
"->",
"v",
",",
"d",
",",
"co",
")",
";",
"if",
"(",
"construct",
")",
"{",
"v",
"=",
"add_new_bound_vert",
"(",
"mem_arena",
",",
"vm",
",",
"co",
")",
";",
"v",
"->",
"efirst",
"=",
"v",
"->",
"elast",
"=",
"e",
";",
"e",
"->",
"leftv",
"=",
"e",
"->",
"rightv",
"=",
"v",
";",
"}",
"else",
"{",
"adjust_bound_vert",
"(",
"e",
"->",
"leftv",
",",
"co",
")",
";",
"}",
"}",
"}",
"calculate_vm_profiles",
"(",
"bp",
",",
"bv",
",",
"vm",
")",
";",
"if",
"(",
"bv",
"->",
"edgecount",
">=",
"3",
")",
"{",
"v",
"=",
"vm",
"->",
"boundstart",
";",
"BLI_assert",
"(",
"v",
"->",
"ebev",
"!=",
"NULL",
")",
";",
"move_profile_plane",
"(",
"v",
",",
"bv",
"->",
"v",
")",
";",
"calculate_profile",
"(",
"bp",
",",
"v",
")",
";",
"}",
"if",
"(",
"construct",
")",
"{",
"set_bound_vert_seams",
"(",
"bv",
",",
"bp",
"->",
"mark_seam",
",",
"bp",
"->",
"mark_sharp",
")",
";",
"if",
"(",
"vm",
"->",
"count",
"==",
"2",
"&&",
"bv",
"->",
"edgecount",
"==",
"3",
")",
"{",
"vm",
"->",
"mesh_kind",
"=",
"M_NONE",
";",
"}",
"else",
"if",
"(",
"vm",
"->",
"count",
"==",
"3",
")",
"{",
"vm",
"->",
"mesh_kind",
"=",
"M_TRI_FAN",
";",
"}",
"else",
"{",
"vm",
"->",
"mesh_kind",
"=",
"M_POLY",
";",
"}",
"}",
"}"
] | Special case of build_boundary when a single edge is beveled. | [
"Special",
"case",
"of",
"build_boundary",
"when",
"a",
"single",
"edge",
"is",
"beveled",
"."
] | [
"/* only 2 edges in, so terminate the edge with an artificial vertex on the unbeveled edge */",
"/* make artificial extra point along unbeveled edge, and form triangle */",
"/* could use M_POLY too, but tri-fan looks nicer)*/",
"/* More than 2 edges in. Put on-edge verts on all the other edges\n * and join with the beveled edge to make a poly or adj mesh,\n * Because e->prev has offset 0, offset_meet will put co on that edge. */",
"/* TODO: should do something else if angle between e and e->prev > 180 */",
"/* For the edges not adjacent to the beveled edge, slide the bevel amount along. */",
"/* special case: snap profile to plane of adjacent two edges */"
] | [
{
"param": "bp",
"type": "BevelParams"
},
{
"param": "bv",
"type": "BevVert"
},
{
"param": "efirst",
"type": "EdgeHalf"
},
{
"param": "construct",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bp",
"type": "BevelParams",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bv",
"type": "BevVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "efirst",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "construct",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | adjust_miter_coords | void | static void adjust_miter_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter)
{
float co1[3], co2[3], co3[3], edge_dir[3], line_p[3];
BoundVert *v1, *v2, *v3, *v1prev, *v3next;
BMVert *vother;
EdgeHalf *emiter_other;
int miter_outer = bp->miter_outer;
v1 = emiter->rightv;
if (miter_outer == BEVEL_MITER_PATCH) {
v2 = v1->next;
v3 = v2->next;
}
else {
BLI_assert(miter_outer == BEVEL_MITER_ARC);
v2 = NULL;
v3 = v1->next;
}
v1prev = v1->prev;
v3next = v3->next;
copy_v3_v3(co2, v1->nv.co);
if (v1->is_arc_start) {
copy_v3_v3(v1->profile.midco, co2);
}
/* co1 is intersection of line through co2 in dir of emiter->e
* and plane with normal the dir of emiter->e and through v1prev */
vother = BM_edge_other_vert(emiter->e, bv->v);
sub_v3_v3v3(edge_dir, bv->v->co, vother->co);
normalize_v3(edge_dir);
float d = bp->offset / (bp->seg / 2.0f); /* a fallback amount to move */
madd_v3_v3v3fl(line_p, co2, edge_dir, d);
if (!isect_line_plane_v3(co1, co2, line_p, v1prev->nv.co, edge_dir)) {
copy_v3_v3(co1, line_p);
}
adjust_bound_vert(v1, co1);
/* co3 is similar, but plane is through v3next and line is other side of miter edge */
emiter_other = v3->elast; /*v3->efirst;*/
vother = BM_edge_other_vert(emiter_other->e, bv->v);
sub_v3_v3v3(edge_dir, bv->v->co, vother->co);
normalize_v3(edge_dir);
madd_v3_v3v3fl(line_p, co2, edge_dir, d);
if (!isect_line_plane_v3(co3, co2, line_p, v3next->nv.co, edge_dir)) {
copy_v3_v3(co1, line_p);
}
adjust_bound_vert(v3, co3);
} | /* Helper for build_boundary to handle special miters */ | Helper for build_boundary to handle special miters | [
"Helper",
"for",
"build_boundary",
"to",
"handle",
"special",
"miters"
] | static void adjust_miter_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter)
{
float co1[3], co2[3], co3[3], edge_dir[3], line_p[3];
BoundVert *v1, *v2, *v3, *v1prev, *v3next;
BMVert *vother;
EdgeHalf *emiter_other;
int miter_outer = bp->miter_outer;
v1 = emiter->rightv;
if (miter_outer == BEVEL_MITER_PATCH) {
v2 = v1->next;
v3 = v2->next;
}
else {
BLI_assert(miter_outer == BEVEL_MITER_ARC);
v2 = NULL;
v3 = v1->next;
}
v1prev = v1->prev;
v3next = v3->next;
copy_v3_v3(co2, v1->nv.co);
if (v1->is_arc_start) {
copy_v3_v3(v1->profile.midco, co2);
}
vother = BM_edge_other_vert(emiter->e, bv->v);
sub_v3_v3v3(edge_dir, bv->v->co, vother->co);
normalize_v3(edge_dir);
float d = bp->offset / (bp->seg / 2.0f);
madd_v3_v3v3fl(line_p, co2, edge_dir, d);
if (!isect_line_plane_v3(co1, co2, line_p, v1prev->nv.co, edge_dir)) {
copy_v3_v3(co1, line_p);
}
adjust_bound_vert(v1, co1);
emiter_other = v3->elast;
vother = BM_edge_other_vert(emiter_other->e, bv->v);
sub_v3_v3v3(edge_dir, bv->v->co, vother->co);
normalize_v3(edge_dir);
madd_v3_v3v3fl(line_p, co2, edge_dir, d);
if (!isect_line_plane_v3(co3, co2, line_p, v3next->nv.co, edge_dir)) {
copy_v3_v3(co1, line_p);
}
adjust_bound_vert(v3, co3);
} | [
"static",
"void",
"adjust_miter_coords",
"(",
"BevelParams",
"*",
"bp",
",",
"BevVert",
"*",
"bv",
",",
"EdgeHalf",
"*",
"emiter",
")",
"{",
"float",
"co1",
"[",
"3",
"]",
",",
"co2",
"[",
"3",
"]",
",",
"co3",
"[",
"3",
"]",
",",
"edge_dir",
"[",
"3",
"]",
",",
"line_p",
"[",
"3",
"]",
";",
"BoundVert",
"*",
"v1",
",",
"*",
"v2",
",",
"*",
"v3",
",",
"*",
"v1prev",
",",
"*",
"v3next",
";",
"BMVert",
"*",
"vother",
";",
"EdgeHalf",
"*",
"emiter_other",
";",
"int",
"miter_outer",
"=",
"bp",
"->",
"miter_outer",
";",
"v1",
"=",
"emiter",
"->",
"rightv",
";",
"if",
"(",
"miter_outer",
"==",
"BEVEL_MITER_PATCH",
")",
"{",
"v2",
"=",
"v1",
"->",
"next",
";",
"v3",
"=",
"v2",
"->",
"next",
";",
"}",
"else",
"{",
"BLI_assert",
"(",
"miter_outer",
"==",
"BEVEL_MITER_ARC",
")",
";",
"v2",
"=",
"NULL",
";",
"v3",
"=",
"v1",
"->",
"next",
";",
"}",
"v1prev",
"=",
"v1",
"->",
"prev",
";",
"v3next",
"=",
"v3",
"->",
"next",
";",
"copy_v3_v3",
"(",
"co2",
",",
"v1",
"->",
"nv",
".",
"co",
")",
";",
"if",
"(",
"v1",
"->",
"is_arc_start",
")",
"{",
"copy_v3_v3",
"(",
"v1",
"->",
"profile",
".",
"midco",
",",
"co2",
")",
";",
"}",
"vother",
"=",
"BM_edge_other_vert",
"(",
"emiter",
"->",
"e",
",",
"bv",
"->",
"v",
")",
";",
"sub_v3_v3v3",
"(",
"edge_dir",
",",
"bv",
"->",
"v",
"->",
"co",
",",
"vother",
"->",
"co",
")",
";",
"normalize_v3",
"(",
"edge_dir",
")",
";",
"float",
"d",
"=",
"bp",
"->",
"offset",
"/",
"(",
"bp",
"->",
"seg",
"/",
"2.0f",
")",
";",
"madd_v3_v3v3fl",
"(",
"line_p",
",",
"co2",
",",
"edge_dir",
",",
"d",
")",
";",
"if",
"(",
"!",
"isect_line_plane_v3",
"(",
"co1",
",",
"co2",
",",
"line_p",
",",
"v1prev",
"->",
"nv",
".",
"co",
",",
"edge_dir",
")",
")",
"{",
"copy_v3_v3",
"(",
"co1",
",",
"line_p",
")",
";",
"}",
"adjust_bound_vert",
"(",
"v1",
",",
"co1",
")",
";",
"emiter_other",
"=",
"v3",
"->",
"elast",
";",
"vother",
"=",
"BM_edge_other_vert",
"(",
"emiter_other",
"->",
"e",
",",
"bv",
"->",
"v",
")",
";",
"sub_v3_v3v3",
"(",
"edge_dir",
",",
"bv",
"->",
"v",
"->",
"co",
",",
"vother",
"->",
"co",
")",
";",
"normalize_v3",
"(",
"edge_dir",
")",
";",
"madd_v3_v3v3fl",
"(",
"line_p",
",",
"co2",
",",
"edge_dir",
",",
"d",
")",
";",
"if",
"(",
"!",
"isect_line_plane_v3",
"(",
"co3",
",",
"co2",
",",
"line_p",
",",
"v3next",
"->",
"nv",
".",
"co",
",",
"edge_dir",
")",
")",
"{",
"copy_v3_v3",
"(",
"co1",
",",
"line_p",
")",
";",
"}",
"adjust_bound_vert",
"(",
"v3",
",",
"co3",
")",
";",
"}"
] | Helper for build_boundary to handle special miters | [
"Helper",
"for",
"build_boundary",
"to",
"handle",
"special",
"miters"
] | [
"/* co1 is intersection of line through co2 in dir of emiter->e\n * and plane with normal the dir of emiter->e and through v1prev */",
"/* a fallback amount to move */",
"/* co3 is similar, but plane is through v3next and line is other side of miter edge */",
"/*v3->efirst;*/"
] | [
{
"param": "bp",
"type": "BevelParams"
},
{
"param": "bv",
"type": "BevVert"
},
{
"param": "emiter",
"type": "EdgeHalf"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bp",
"type": "BevelParams",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bv",
"type": "BevVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "emiter",
"type": "EdgeHalf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | adjust_the_cycle_or_chain_fast | bool | static bool adjust_the_cycle_or_chain_fast(BoundVert *vstart, int np, bool iscycle)
{
BoundVert *v;
EdgeHalf *eleft, *eright;
float *g;
float *g_prod;
float gprod, gprod_sum, spec_sum, p;
int i;
g = MEM_mallocN(np * sizeof(float), "beveladjust");
g_prod = MEM_mallocN(np * sizeof(float), "beveladjust");
v = vstart;
spec_sum = 0.0f;
i = 0;
do {
g[i] = v->sinratio;
if (iscycle || v->adjchain != NULL) {
spec_sum += v->efirst->offset_r;
}
else {
spec_sum += v->elast->offset_l;
}
i++;
v = v->adjchain;
} while (v && v != vstart);
gprod = 1.00f;
gprod_sum = 1.0f;
for (i = np - 1; i > 0; i--) {
gprod *= g[i];
g_prod[i] = gprod;
gprod_sum += gprod;
}
g_prod[0] = 1.0f;
if (iscycle) {
gprod *= g[0];
if (fabs(gprod - 1.0f) > BEVEL_EPSILON) {
/* fast cycle calc only works if total product is 1 */
MEM_freeN(g);
MEM_freeN(g_prod);
return false;
}
}
if (gprod_sum == 0.0f) {
MEM_freeN(g);
MEM_freeN(g_prod);
return false;
}
p = spec_sum / gprod_sum;
/* apply the new offsets */
v = vstart;
i = 0;
do {
if (iscycle || v->adjchain != NULL) {
eright = v->efirst;
eleft = v->elast;
eright->offset_r = g_prod[(i + 1) % np] * p;
if (iscycle || v != vstart) {
eleft->offset_l = v->sinratio * eright->offset_r;
}
}
else {
/* not a cycle, and last of chain */
eleft = v->elast;
eleft->offset_l = p;
}
i++;
v = v->adjchain;
} while (v && v != vstart);
MEM_freeN(g);
MEM_freeN(g_prod);
return true;
} | /* This code uses a direct solution to the adjustment problem for chains and certain cycles.
* It is a two-step approach: first solve for the exact solution of the 'match widths' constraints
* using the one degree of freedom that allows for expressing all other widths in terms of that.
* And then minimize the spec-matching constraints using the derivative of the least squares
* residual in terms of that one degree of freedom.
* Unfortunately, the results are in some cases worse than the general least squares solution
* for the combined (with weights) problem, so this code is not used.
* But keep it here for a while in case performance issues demand that it be used sometimes. */ | This code uses a direct solution to the adjustment problem for chains and certain cycles.
It is a two-step approach: first solve for the exact solution of the 'match widths' constraints
using the one degree of freedom that allows for expressing all other widths in terms of that.
And then minimize the spec-matching constraints using the derivative of the least squares
residual in terms of that one degree of freedom.
Unfortunately, the results are in some cases worse than the general least squares solution
for the combined (with weights) problem, so this code is not used.
But keep it here for a while in case performance issues demand that it be used sometimes. | [
"This",
"code",
"uses",
"a",
"direct",
"solution",
"to",
"the",
"adjustment",
"problem",
"for",
"chains",
"and",
"certain",
"cycles",
".",
"It",
"is",
"a",
"two",
"-",
"step",
"approach",
":",
"first",
"solve",
"for",
"the",
"exact",
"solution",
"of",
"the",
"'",
"match",
"widths",
"'",
"constraints",
"using",
"the",
"one",
"degree",
"of",
"freedom",
"that",
"allows",
"for",
"expressing",
"all",
"other",
"widths",
"in",
"terms",
"of",
"that",
".",
"And",
"then",
"minimize",
"the",
"spec",
"-",
"matching",
"constraints",
"using",
"the",
"derivative",
"of",
"the",
"least",
"squares",
"residual",
"in",
"terms",
"of",
"that",
"one",
"degree",
"of",
"freedom",
".",
"Unfortunately",
"the",
"results",
"are",
"in",
"some",
"cases",
"worse",
"than",
"the",
"general",
"least",
"squares",
"solution",
"for",
"the",
"combined",
"(",
"with",
"weights",
")",
"problem",
"so",
"this",
"code",
"is",
"not",
"used",
".",
"But",
"keep",
"it",
"here",
"for",
"a",
"while",
"in",
"case",
"performance",
"issues",
"demand",
"that",
"it",
"be",
"used",
"sometimes",
"."
] | static bool adjust_the_cycle_or_chain_fast(BoundVert *vstart, int np, bool iscycle)
{
BoundVert *v;
EdgeHalf *eleft, *eright;
float *g;
float *g_prod;
float gprod, gprod_sum, spec_sum, p;
int i;
g = MEM_mallocN(np * sizeof(float), "beveladjust");
g_prod = MEM_mallocN(np * sizeof(float), "beveladjust");
v = vstart;
spec_sum = 0.0f;
i = 0;
do {
g[i] = v->sinratio;
if (iscycle || v->adjchain != NULL) {
spec_sum += v->efirst->offset_r;
}
else {
spec_sum += v->elast->offset_l;
}
i++;
v = v->adjchain;
} while (v && v != vstart);
gprod = 1.00f;
gprod_sum = 1.0f;
for (i = np - 1; i > 0; i--) {
gprod *= g[i];
g_prod[i] = gprod;
gprod_sum += gprod;
}
g_prod[0] = 1.0f;
if (iscycle) {
gprod *= g[0];
if (fabs(gprod - 1.0f) > BEVEL_EPSILON) {
MEM_freeN(g);
MEM_freeN(g_prod);
return false;
}
}
if (gprod_sum == 0.0f) {
MEM_freeN(g);
MEM_freeN(g_prod);
return false;
}
p = spec_sum / gprod_sum;
v = vstart;
i = 0;
do {
if (iscycle || v->adjchain != NULL) {
eright = v->efirst;
eleft = v->elast;
eright->offset_r = g_prod[(i + 1) % np] * p;
if (iscycle || v != vstart) {
eleft->offset_l = v->sinratio * eright->offset_r;
}
}
else {
eleft = v->elast;
eleft->offset_l = p;
}
i++;
v = v->adjchain;
} while (v && v != vstart);
MEM_freeN(g);
MEM_freeN(g_prod);
return true;
} | [
"static",
"bool",
"adjust_the_cycle_or_chain_fast",
"(",
"BoundVert",
"*",
"vstart",
",",
"int",
"np",
",",
"bool",
"iscycle",
")",
"{",
"BoundVert",
"*",
"v",
";",
"EdgeHalf",
"*",
"eleft",
",",
"*",
"eright",
";",
"float",
"*",
"g",
";",
"float",
"*",
"g_prod",
";",
"float",
"gprod",
",",
"gprod_sum",
",",
"spec_sum",
",",
"p",
";",
"int",
"i",
";",
"g",
"=",
"MEM_mallocN",
"(",
"np",
"*",
"sizeof",
"(",
"float",
")",
",",
"\"",
"\"",
")",
";",
"g_prod",
"=",
"MEM_mallocN",
"(",
"np",
"*",
"sizeof",
"(",
"float",
")",
",",
"\"",
"\"",
")",
";",
"v",
"=",
"vstart",
";",
"spec_sum",
"=",
"0.0f",
";",
"i",
"=",
"0",
";",
"do",
"{",
"g",
"[",
"i",
"]",
"=",
"v",
"->",
"sinratio",
";",
"if",
"(",
"iscycle",
"||",
"v",
"->",
"adjchain",
"!=",
"NULL",
")",
"{",
"spec_sum",
"+=",
"v",
"->",
"efirst",
"->",
"offset_r",
";",
"}",
"else",
"{",
"spec_sum",
"+=",
"v",
"->",
"elast",
"->",
"offset_l",
";",
"}",
"i",
"++",
";",
"v",
"=",
"v",
"->",
"adjchain",
";",
"}",
"while",
"(",
"v",
"&&",
"v",
"!=",
"vstart",
")",
";",
"gprod",
"=",
"1.00f",
";",
"gprod_sum",
"=",
"1.0f",
";",
"for",
"(",
"i",
"=",
"np",
"-",
"1",
";",
"i",
">",
"0",
";",
"i",
"--",
")",
"{",
"gprod",
"*=",
"g",
"[",
"i",
"]",
";",
"g_prod",
"[",
"i",
"]",
"=",
"gprod",
";",
"gprod_sum",
"+=",
"gprod",
";",
"}",
"g_prod",
"[",
"0",
"]",
"=",
"1.0f",
";",
"if",
"(",
"iscycle",
")",
"{",
"gprod",
"*=",
"g",
"[",
"0",
"]",
";",
"if",
"(",
"fabs",
"(",
"gprod",
"-",
"1.0f",
")",
">",
"BEVEL_EPSILON",
")",
"{",
"MEM_freeN",
"(",
"g",
")",
";",
"MEM_freeN",
"(",
"g_prod",
")",
";",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"gprod_sum",
"==",
"0.0f",
")",
"{",
"MEM_freeN",
"(",
"g",
")",
";",
"MEM_freeN",
"(",
"g_prod",
")",
";",
"return",
"false",
";",
"}",
"p",
"=",
"spec_sum",
"/",
"gprod_sum",
";",
"v",
"=",
"vstart",
";",
"i",
"=",
"0",
";",
"do",
"{",
"if",
"(",
"iscycle",
"||",
"v",
"->",
"adjchain",
"!=",
"NULL",
")",
"{",
"eright",
"=",
"v",
"->",
"efirst",
";",
"eleft",
"=",
"v",
"->",
"elast",
";",
"eright",
"->",
"offset_r",
"=",
"g_prod",
"[",
"(",
"i",
"+",
"1",
")",
"%",
"np",
"]",
"*",
"p",
";",
"if",
"(",
"iscycle",
"||",
"v",
"!=",
"vstart",
")",
"{",
"eleft",
"->",
"offset_l",
"=",
"v",
"->",
"sinratio",
"*",
"eright",
"->",
"offset_r",
";",
"}",
"}",
"else",
"{",
"eleft",
"=",
"v",
"->",
"elast",
";",
"eleft",
"->",
"offset_l",
"=",
"p",
";",
"}",
"i",
"++",
";",
"v",
"=",
"v",
"->",
"adjchain",
";",
"}",
"while",
"(",
"v",
"&&",
"v",
"!=",
"vstart",
")",
";",
"MEM_freeN",
"(",
"g",
")",
";",
"MEM_freeN",
"(",
"g_prod",
")",
";",
"return",
"true",
";",
"}"
] | This code uses a direct solution to the adjustment problem for chains and certain cycles. | [
"This",
"code",
"uses",
"a",
"direct",
"solution",
"to",
"the",
"adjustment",
"problem",
"for",
"chains",
"and",
"certain",
"cycles",
"."
] | [
"/* fast cycle calc only works if total product is 1 */",
"/* apply the new offsets */",
"/* not a cycle, and last of chain */"
] | [
{
"param": "vstart",
"type": "BoundVert"
},
{
"param": "np",
"type": "int"
},
{
"param": "iscycle",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "vstart",
"type": "BoundVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "np",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "iscycle",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | adjust_the_cycle_or_chain | void | static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
{
BoundVert *v;
EdgeHalf *eleft, *eright, *enextleft;
LinearSolver *solver;
double weight, val;
int i, np, nrows, row;
np = 0;
#ifdef DEBUG_ADJUST
printf("\nadjust the %s (with eigen)\n", iscycle ? "cycle" : "chain");
#endif
v = vstart;
do {
#ifdef DEBUG_ADJUST
eleft = v->elast;
eright = v->efirst;
printf(" (left=e%d, right=e%d)", BM_elem_index_get(eleft->e), BM_elem_index_get(eright->e));
#endif
np++;
v = v->adjchain;
} while (v && v != vstart);
#ifdef DEBUG_ADJUST
printf(" -> %d parms\n", np);
#endif
#ifdef FAST_ADJUST_CODE
if (adjust_the_cycle_or_chain_fast(vstart, np, iscycle)) {
return;
}
#endif
nrows = iscycle ? 3 * np : 3 * np - 3;
solver = EIG_linear_least_squares_solver_new(nrows, np, 1);
v = vstart;
i = 0;
weight = BEVEL_MATCH_SPEC_WEIGHT; /* sqrt of factor to weight down importance of spec match */
do {
/* except at end of chain, v's indep variable is offset_r of v->efirst */
if (iscycle || i < np - 1) {
eright = v->efirst;
eleft = v->elast;
enextleft = v->adjchain->elast;
#ifdef DEBUG_ADJUST
printf("p%d: e%d->offset_r = %f\n", i, BM_elem_index_get(eright->e), eright->offset_r);
if (iscycle || v != vstart) {
printf(" dependent: e%d->offset_l = %f * p%d\n",
BM_elem_index_get(eleft->e),
v->sinratio,
i);
}
#endif
/* residue i: width difference between eright and eleft of next */
EIG_linear_solver_matrix_add(solver, i, i, 1.0);
EIG_linear_solver_right_hand_side_add(solver, 0, i, 0.0);
if (iscycle) {
EIG_linear_solver_matrix_add(solver, i > 0 ? i - 1 : np - 1, i, -v->sinratio);
}
else {
if (i > 0) {
EIG_linear_solver_matrix_add(solver, i - 1, i, -v->sinratio);
}
}
/* residue np + 2*i (if cycle) else np - 1 + 2*i:
* right offset for parm i matches its spec; weighted */
row = iscycle ? np + 2 * i : np - 1 + 2 * i;
EIG_linear_solver_matrix_add(solver, row, i, weight);
EIG_linear_solver_right_hand_side_add(solver, 0, row, weight * eright->offset_r);
#ifdef DEBUG_ADJUST
printf("b[%d]=%f * %f, for e%d->offset_r\n",
row,
weight,
eright->offset_r,
BM_elem_index_get(eright->e));
#endif
/* residue np + 2*i + 1 (if cycle) else np - 1 + 2*i + 1:
* left offset for parm i matches its spec; weighted */
row = row + 1;
EIG_linear_solver_matrix_add(
solver, row, (i == np - 1) ? 0 : i + 1, weight * v->adjchain->sinratio);
EIG_linear_solver_right_hand_side_add(solver, 0, row, weight * enextleft->offset_l);
#ifdef DEBUG_ADJUST
printf("b[%d]=%f * %f, for e%d->offset_l\n",
row,
weight,
enextleft->offset_l,
BM_elem_index_get(enextleft->e));
#endif
}
else {
/* not a cycle, and last of chain */
eleft = v->elast;
#ifdef DEBUG_ADJUST
printf("p%d: e%d->offset_l = %f\n", i, BM_elem_index_get(eleft->e), eleft->offset_l);
#endif
/* second part of residue i for last i */
EIG_linear_solver_matrix_add(solver, i - 1, i, -1.0);
}
i++;
v = v->adjchain;
} while (v && v != vstart);
EIG_linear_solver_solve(solver);
#ifdef DEBUG_ADJUST
/* Note: this print only works after solve, but by that time b has been cleared */
EIG_linear_solver_print_matrix(solver);
printf("\nSolution:\n");
for (i = 0; i < np; i++) {
printf("p%d = %f\n", i, EIG_linear_solver_variable_get(solver, 0, i));
}
#endif
/* Use the solution to set new widths */
v = vstart;
i = 0;
do {
val = EIG_linear_solver_variable_get(solver, 0, i);
if (iscycle || i < np - 1) {
eright = v->efirst;
eleft = v->elast;
eright->offset_r = (float)val;
#ifdef DEBUG_ADJUST
printf("e%d->offset_r = %f\n", BM_elem_index_get(eright->e), eright->offset_r);
#endif
if (iscycle || v != vstart) {
eleft->offset_l = (float)(v->sinratio * val);
#ifdef DEBUG_ADJUST
printf("e%d->offset_l = %f\n", BM_elem_index_get(eleft->e), eleft->offset_l);
#endif
}
}
else {
/* not a cycle, and last of chain */
eleft = v->elast;
eleft->offset_l = (float)val;
#ifdef DEBUG_ADJUST
printf("e%d->offset_l = %f\n", BM_elem_index_get(eleft->e), eleft->offset_l);
#endif
}
i++;
v = v->adjchain;
} while (v && v != vstart);
#ifdef DEBUG_ADJUST
print_adjust_stats(vstart);
EIG_linear_solver_print_matrix(solver);
#endif
EIG_linear_solver_delete(solver);
} | /* Adjust the offsets for a single cycle or chain.
* For chains and some cycles, a fast solution exists.
* Otherwise, we set up and solve a linear least squares problem
* that tries to minimize the squared differences of lengths
* at each end of an edge, and (with smaller weight) the
* squared differences of the offsets from their specs.
*/ | Adjust the offsets for a single cycle or chain.
For chains and some cycles, a fast solution exists.
Otherwise, we set up and solve a linear least squares problem
that tries to minimize the squared differences of lengths
at each end of an edge, and (with smaller weight) the
squared differences of the offsets from their specs. | [
"Adjust",
"the",
"offsets",
"for",
"a",
"single",
"cycle",
"or",
"chain",
".",
"For",
"chains",
"and",
"some",
"cycles",
"a",
"fast",
"solution",
"exists",
".",
"Otherwise",
"we",
"set",
"up",
"and",
"solve",
"a",
"linear",
"least",
"squares",
"problem",
"that",
"tries",
"to",
"minimize",
"the",
"squared",
"differences",
"of",
"lengths",
"at",
"each",
"end",
"of",
"an",
"edge",
"and",
"(",
"with",
"smaller",
"weight",
")",
"the",
"squared",
"differences",
"of",
"the",
"offsets",
"from",
"their",
"specs",
"."
] | static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
{
BoundVert *v;
EdgeHalf *eleft, *eright, *enextleft;
LinearSolver *solver;
double weight, val;
int i, np, nrows, row;
np = 0;
#ifdef DEBUG_ADJUST
printf("\nadjust the %s (with eigen)\n", iscycle ? "cycle" : "chain");
#endif
v = vstart;
do {
#ifdef DEBUG_ADJUST
eleft = v->elast;
eright = v->efirst;
printf(" (left=e%d, right=e%d)", BM_elem_index_get(eleft->e), BM_elem_index_get(eright->e));
#endif
np++;
v = v->adjchain;
} while (v && v != vstart);
#ifdef DEBUG_ADJUST
printf(" -> %d parms\n", np);
#endif
#ifdef FAST_ADJUST_CODE
if (adjust_the_cycle_or_chain_fast(vstart, np, iscycle)) {
return;
}
#endif
nrows = iscycle ? 3 * np : 3 * np - 3;
solver = EIG_linear_least_squares_solver_new(nrows, np, 1);
v = vstart;
i = 0;
weight = BEVEL_MATCH_SPEC_WEIGHT;
do {
if (iscycle || i < np - 1) {
eright = v->efirst;
eleft = v->elast;
enextleft = v->adjchain->elast;
#ifdef DEBUG_ADJUST
printf("p%d: e%d->offset_r = %f\n", i, BM_elem_index_get(eright->e), eright->offset_r);
if (iscycle || v != vstart) {
printf(" dependent: e%d->offset_l = %f * p%d\n",
BM_elem_index_get(eleft->e),
v->sinratio,
i);
}
#endif
EIG_linear_solver_matrix_add(solver, i, i, 1.0);
EIG_linear_solver_right_hand_side_add(solver, 0, i, 0.0);
if (iscycle) {
EIG_linear_solver_matrix_add(solver, i > 0 ? i - 1 : np - 1, i, -v->sinratio);
}
else {
if (i > 0) {
EIG_linear_solver_matrix_add(solver, i - 1, i, -v->sinratio);
}
}
row = iscycle ? np + 2 * i : np - 1 + 2 * i;
EIG_linear_solver_matrix_add(solver, row, i, weight);
EIG_linear_solver_right_hand_side_add(solver, 0, row, weight * eright->offset_r);
#ifdef DEBUG_ADJUST
printf("b[%d]=%f * %f, for e%d->offset_r\n",
row,
weight,
eright->offset_r,
BM_elem_index_get(eright->e));
#endif
row = row + 1;
EIG_linear_solver_matrix_add(
solver, row, (i == np - 1) ? 0 : i + 1, weight * v->adjchain->sinratio);
EIG_linear_solver_right_hand_side_add(solver, 0, row, weight * enextleft->offset_l);
#ifdef DEBUG_ADJUST
printf("b[%d]=%f * %f, for e%d->offset_l\n",
row,
weight,
enextleft->offset_l,
BM_elem_index_get(enextleft->e));
#endif
}
else {
eleft = v->elast;
#ifdef DEBUG_ADJUST
printf("p%d: e%d->offset_l = %f\n", i, BM_elem_index_get(eleft->e), eleft->offset_l);
#endif
EIG_linear_solver_matrix_add(solver, i - 1, i, -1.0);
}
i++;
v = v->adjchain;
} while (v && v != vstart);
EIG_linear_solver_solve(solver);
#ifdef DEBUG_ADJUST
EIG_linear_solver_print_matrix(solver);
printf("\nSolution:\n");
for (i = 0; i < np; i++) {
printf("p%d = %f\n", i, EIG_linear_solver_variable_get(solver, 0, i));
}
#endif
v = vstart;
i = 0;
do {
val = EIG_linear_solver_variable_get(solver, 0, i);
if (iscycle || i < np - 1) {
eright = v->efirst;
eleft = v->elast;
eright->offset_r = (float)val;
#ifdef DEBUG_ADJUST
printf("e%d->offset_r = %f\n", BM_elem_index_get(eright->e), eright->offset_r);
#endif
if (iscycle || v != vstart) {
eleft->offset_l = (float)(v->sinratio * val);
#ifdef DEBUG_ADJUST
printf("e%d->offset_l = %f\n", BM_elem_index_get(eleft->e), eleft->offset_l);
#endif
}
}
else {
eleft = v->elast;
eleft->offset_l = (float)val;
#ifdef DEBUG_ADJUST
printf("e%d->offset_l = %f\n", BM_elem_index_get(eleft->e), eleft->offset_l);
#endif
}
i++;
v = v->adjchain;
} while (v && v != vstart);
#ifdef DEBUG_ADJUST
print_adjust_stats(vstart);
EIG_linear_solver_print_matrix(solver);
#endif
EIG_linear_solver_delete(solver);
} | [
"static",
"void",
"adjust_the_cycle_or_chain",
"(",
"BoundVert",
"*",
"vstart",
",",
"bool",
"iscycle",
")",
"{",
"BoundVert",
"*",
"v",
";",
"EdgeHalf",
"*",
"eleft",
",",
"*",
"eright",
",",
"*",
"enextleft",
";",
"LinearSolver",
"*",
"solver",
";",
"double",
"weight",
",",
"val",
";",
"int",
"i",
",",
"np",
",",
"nrows",
",",
"row",
";",
"np",
"=",
"0",
";",
"#ifdef",
"DEBUG_ADJUST",
"printf",
"(",
"\"",
"\\n",
"\\n",
"\"",
",",
"iscycle",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"#endif",
"v",
"=",
"vstart",
";",
"do",
"{",
"#ifdef",
"DEBUG_ADJUST",
"eleft",
"=",
"v",
"->",
"elast",
";",
"eright",
"=",
"v",
"->",
"efirst",
";",
"printf",
"(",
"\"",
"\"",
",",
"BM_elem_index_get",
"(",
"eleft",
"->",
"e",
")",
",",
"BM_elem_index_get",
"(",
"eright",
"->",
"e",
")",
")",
";",
"#endif",
"np",
"++",
";",
"v",
"=",
"v",
"->",
"adjchain",
";",
"}",
"while",
"(",
"v",
"&&",
"v",
"!=",
"vstart",
")",
";",
"#ifdef",
"DEBUG_ADJUST",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"np",
")",
";",
"#endif",
"#ifdef",
"FAST_ADJUST_CODE",
"if",
"(",
"adjust_the_cycle_or_chain_fast",
"(",
"vstart",
",",
"np",
",",
"iscycle",
")",
")",
"{",
"return",
";",
"}",
"#endif",
"nrows",
"=",
"iscycle",
"?",
"3",
"*",
"np",
":",
"3",
"*",
"np",
"-",
"3",
";",
"solver",
"=",
"EIG_linear_least_squares_solver_new",
"(",
"nrows",
",",
"np",
",",
"1",
")",
";",
"v",
"=",
"vstart",
";",
"i",
"=",
"0",
";",
"weight",
"=",
"BEVEL_MATCH_SPEC_WEIGHT",
";",
"do",
"{",
"if",
"(",
"iscycle",
"||",
"i",
"<",
"np",
"-",
"1",
")",
"{",
"eright",
"=",
"v",
"->",
"efirst",
";",
"eleft",
"=",
"v",
"->",
"elast",
";",
"enextleft",
"=",
"v",
"->",
"adjchain",
"->",
"elast",
";",
"#ifdef",
"DEBUG_ADJUST",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"i",
",",
"BM_elem_index_get",
"(",
"eright",
"->",
"e",
")",
",",
"eright",
"->",
"offset_r",
")",
";",
"if",
"(",
"iscycle",
"||",
"v",
"!=",
"vstart",
")",
"{",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"BM_elem_index_get",
"(",
"eleft",
"->",
"e",
")",
",",
"v",
"->",
"sinratio",
",",
"i",
")",
";",
"}",
"#endif",
"EIG_linear_solver_matrix_add",
"(",
"solver",
",",
"i",
",",
"i",
",",
"1.0",
")",
";",
"EIG_linear_solver_right_hand_side_add",
"(",
"solver",
",",
"0",
",",
"i",
",",
"0.0",
")",
";",
"if",
"(",
"iscycle",
")",
"{",
"EIG_linear_solver_matrix_add",
"(",
"solver",
",",
"i",
">",
"0",
"?",
"i",
"-",
"1",
":",
"np",
"-",
"1",
",",
"i",
",",
"-",
"v",
"->",
"sinratio",
")",
";",
"}",
"else",
"{",
"if",
"(",
"i",
">",
"0",
")",
"{",
"EIG_linear_solver_matrix_add",
"(",
"solver",
",",
"i",
"-",
"1",
",",
"i",
",",
"-",
"v",
"->",
"sinratio",
")",
";",
"}",
"}",
"row",
"=",
"iscycle",
"?",
"np",
"+",
"2",
"*",
"i",
":",
"np",
"-",
"1",
"+",
"2",
"*",
"i",
";",
"EIG_linear_solver_matrix_add",
"(",
"solver",
",",
"row",
",",
"i",
",",
"weight",
")",
";",
"EIG_linear_solver_right_hand_side_add",
"(",
"solver",
",",
"0",
",",
"row",
",",
"weight",
"*",
"eright",
"->",
"offset_r",
")",
";",
"#ifdef",
"DEBUG_ADJUST",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"row",
",",
"weight",
",",
"eright",
"->",
"offset_r",
",",
"BM_elem_index_get",
"(",
"eright",
"->",
"e",
")",
")",
";",
"#endif",
"row",
"=",
"row",
"+",
"1",
";",
"EIG_linear_solver_matrix_add",
"(",
"solver",
",",
"row",
",",
"(",
"i",
"==",
"np",
"-",
"1",
")",
"?",
"0",
":",
"i",
"+",
"1",
",",
"weight",
"*",
"v",
"->",
"adjchain",
"->",
"sinratio",
")",
";",
"EIG_linear_solver_right_hand_side_add",
"(",
"solver",
",",
"0",
",",
"row",
",",
"weight",
"*",
"enextleft",
"->",
"offset_l",
")",
";",
"#ifdef",
"DEBUG_ADJUST",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"row",
",",
"weight",
",",
"enextleft",
"->",
"offset_l",
",",
"BM_elem_index_get",
"(",
"enextleft",
"->",
"e",
")",
")",
";",
"#endif",
"}",
"else",
"{",
"eleft",
"=",
"v",
"->",
"elast",
";",
"#ifdef",
"DEBUG_ADJUST",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"i",
",",
"BM_elem_index_get",
"(",
"eleft",
"->",
"e",
")",
",",
"eleft",
"->",
"offset_l",
")",
";",
"#endif",
"EIG_linear_solver_matrix_add",
"(",
"solver",
",",
"i",
"-",
"1",
",",
"i",
",",
"-1.0",
")",
";",
"}",
"i",
"++",
";",
"v",
"=",
"v",
"->",
"adjchain",
";",
"}",
"while",
"(",
"v",
"&&",
"v",
"!=",
"vstart",
")",
";",
"EIG_linear_solver_solve",
"(",
"solver",
")",
";",
"#ifdef",
"DEBUG_ADJUST",
"EIG_linear_solver_print_matrix",
"(",
"solver",
")",
";",
"printf",
"(",
"\"",
"\\n",
"\\n",
"\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"np",
";",
"i",
"++",
")",
"{",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"i",
",",
"EIG_linear_solver_variable_get",
"(",
"solver",
",",
"0",
",",
"i",
")",
")",
";",
"}",
"#endif",
"v",
"=",
"vstart",
";",
"i",
"=",
"0",
";",
"do",
"{",
"val",
"=",
"EIG_linear_solver_variable_get",
"(",
"solver",
",",
"0",
",",
"i",
")",
";",
"if",
"(",
"iscycle",
"||",
"i",
"<",
"np",
"-",
"1",
")",
"{",
"eright",
"=",
"v",
"->",
"efirst",
";",
"eleft",
"=",
"v",
"->",
"elast",
";",
"eright",
"->",
"offset_r",
"=",
"(",
"float",
")",
"val",
";",
"#ifdef",
"DEBUG_ADJUST",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"BM_elem_index_get",
"(",
"eright",
"->",
"e",
")",
",",
"eright",
"->",
"offset_r",
")",
";",
"#endif",
"if",
"(",
"iscycle",
"||",
"v",
"!=",
"vstart",
")",
"{",
"eleft",
"->",
"offset_l",
"=",
"(",
"float",
")",
"(",
"v",
"->",
"sinratio",
"*",
"val",
")",
";",
"#ifdef",
"DEBUG_ADJUST",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"BM_elem_index_get",
"(",
"eleft",
"->",
"e",
")",
",",
"eleft",
"->",
"offset_l",
")",
";",
"#endif",
"}",
"}",
"else",
"{",
"eleft",
"=",
"v",
"->",
"elast",
";",
"eleft",
"->",
"offset_l",
"=",
"(",
"float",
")",
"val",
";",
"#ifdef",
"DEBUG_ADJUST",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"BM_elem_index_get",
"(",
"eleft",
"->",
"e",
")",
",",
"eleft",
"->",
"offset_l",
")",
";",
"#endif",
"}",
"i",
"++",
";",
"v",
"=",
"v",
"->",
"adjchain",
";",
"}",
"while",
"(",
"v",
"&&",
"v",
"!=",
"vstart",
")",
";",
"#ifdef",
"DEBUG_ADJUST",
"print_adjust_stats",
"(",
"vstart",
")",
";",
"EIG_linear_solver_print_matrix",
"(",
"solver",
")",
";",
"#endif",
"EIG_linear_solver_delete",
"(",
"solver",
")",
";",
"}"
] | Adjust the offsets for a single cycle or chain. | [
"Adjust",
"the",
"offsets",
"for",
"a",
"single",
"cycle",
"or",
"chain",
"."
] | [
"/* sqrt of factor to weight down importance of spec match */",
"/* except at end of chain, v's indep variable is offset_r of v->efirst */",
"/* residue i: width difference between eright and eleft of next */",
"/* residue np + 2*i (if cycle) else np - 1 + 2*i:\n * right offset for parm i matches its spec; weighted */",
"/* residue np + 2*i + 1 (if cycle) else np - 1 + 2*i + 1:\n * left offset for parm i matches its spec; weighted */",
"/* not a cycle, and last of chain */",
"/* second part of residue i for last i */",
"/* Note: this print only works after solve, but by that time b has been cleared */",
"/* Use the solution to set new widths */",
"/* not a cycle, and last of chain */"
] | [
{
"param": "vstart",
"type": "BoundVert"
},
{
"param": "iscycle",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "vstart",
"type": "BoundVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "iscycle",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | adjust_offsets | void | static void adjust_offsets(BevelParams *bp, BMesh *bm)
{
BMVert *bmv;
BevVert *bv, *bvcur;
BoundVert *v, *vanchor, *vchainstart, *vchainend, *vnext;
EdgeHalf *enext;
BMIter iter;
bool iscycle;
int chainlen;
/* find and process chains and cycles of unvisited BoundVerts that have eon set */
/* note: for repeatability, iterate over all verts of mesh rather than over ghash'ed BMVerts */
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
continue;
}
bv = bvcur = find_bevvert(bp, bmv);
if (!bv) {
continue;
}
vanchor = bv->vmesh->boundstart;
do {
if (vanchor->visited || !vanchor->eon) {
continue;
}
/* Find one of (1) a cycle that starts and ends at v
* where each v has v->eon set and had not been visited before;
* or (2) a chain of v's where the start and end of the chain do not have
* v->eon set but all else do.
* It is OK for the first and last elements to
* have been visited before, but not any of the inner ones.
* We chain the v's together through v->adjchain, and are following
* them in left->right direction, meaning that the left side of one edge
* pairs with the right side of the next edge in the cycle or chain. */
/* first follow paired edges in left->right direction */
v = vchainstart = vchainend = vanchor;
iscycle = false;
chainlen = 1;
while (v->eon && !v->visited && !iscycle) {
v->visited = true;
if (!v->efirst) {
break;
}
enext = find_other_end_edge_half(bp, v->efirst, &bvcur);
if (!enext) {
break;
}
BLI_assert(enext != NULL);
vnext = enext->leftv;
v->adjchain = vnext;
vchainend = vnext;
chainlen++;
if (vnext->visited) {
if (vnext != vchainstart) {
break;
}
adjust_the_cycle_or_chain(vchainstart, true);
iscycle = true;
}
v = vnext;
}
if (!iscycle) {
/* right->left direction, changing vchainstart at each step */
v->adjchain = NULL;
v = vchainstart;
bvcur = bv;
do {
v->visited = true;
if (!v->elast) {
break;
}
enext = find_other_end_edge_half(bp, v->elast, &bvcur);
if (!enext) {
break;
}
vnext = enext->rightv;
vnext->adjchain = v;
chainlen++;
vchainstart = vnext;
v = vnext;
} while (!v->visited && v->eon);
if (chainlen >= 3 && !vchainstart->eon && !vchainend->eon) {
adjust_the_cycle_or_chain(vchainstart, false);
}
}
} while ((vanchor = vanchor->next) != bv->vmesh->boundstart);
}
/* Rebuild boundaries with new width specs */
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
bv = find_bevvert(bp, bmv);
if (bv) {
build_boundary(bp, bv, false);
}
}
}
} | /* Adjust the offsets to try to make them, as much as possible,
* have even-width bevels with offsets that match their specs.
* The problem that we can try to ameliorate is that when loop slide
* is active, the meet point will probably not be the one that makes
* both sides have their specified width. And because both ends may be
* on loop slide edges, the widths at each end could be different.
*
* It turns out that the dependent offsets either form chains or
* cycles, and we can process each of those separately.
*/ | Adjust the offsets to try to make them, as much as possible,
have even-width bevels with offsets that match their specs.
The problem that we can try to ameliorate is that when loop slide
is active, the meet point will probably not be the one that makes
both sides have their specified width. And because both ends may be
on loop slide edges, the widths at each end could be different.
It turns out that the dependent offsets either form chains or
cycles, and we can process each of those separately. | [
"Adjust",
"the",
"offsets",
"to",
"try",
"to",
"make",
"them",
"as",
"much",
"as",
"possible",
"have",
"even",
"-",
"width",
"bevels",
"with",
"offsets",
"that",
"match",
"their",
"specs",
".",
"The",
"problem",
"that",
"we",
"can",
"try",
"to",
"ameliorate",
"is",
"that",
"when",
"loop",
"slide",
"is",
"active",
"the",
"meet",
"point",
"will",
"probably",
"not",
"be",
"the",
"one",
"that",
"makes",
"both",
"sides",
"have",
"their",
"specified",
"width",
".",
"And",
"because",
"both",
"ends",
"may",
"be",
"on",
"loop",
"slide",
"edges",
"the",
"widths",
"at",
"each",
"end",
"could",
"be",
"different",
".",
"It",
"turns",
"out",
"that",
"the",
"dependent",
"offsets",
"either",
"form",
"chains",
"or",
"cycles",
"and",
"we",
"can",
"process",
"each",
"of",
"those",
"separately",
"."
] | static void adjust_offsets(BevelParams *bp, BMesh *bm)
{
BMVert *bmv;
BevVert *bv, *bvcur;
BoundVert *v, *vanchor, *vchainstart, *vchainend, *vnext;
EdgeHalf *enext;
BMIter iter;
bool iscycle;
int chainlen;
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
continue;
}
bv = bvcur = find_bevvert(bp, bmv);
if (!bv) {
continue;
}
vanchor = bv->vmesh->boundstart;
do {
if (vanchor->visited || !vanchor->eon) {
continue;
}
v = vchainstart = vchainend = vanchor;
iscycle = false;
chainlen = 1;
while (v->eon && !v->visited && !iscycle) {
v->visited = true;
if (!v->efirst) {
break;
}
enext = find_other_end_edge_half(bp, v->efirst, &bvcur);
if (!enext) {
break;
}
BLI_assert(enext != NULL);
vnext = enext->leftv;
v->adjchain = vnext;
vchainend = vnext;
chainlen++;
if (vnext->visited) {
if (vnext != vchainstart) {
break;
}
adjust_the_cycle_or_chain(vchainstart, true);
iscycle = true;
}
v = vnext;
}
if (!iscycle) {
v->adjchain = NULL;
v = vchainstart;
bvcur = bv;
do {
v->visited = true;
if (!v->elast) {
break;
}
enext = find_other_end_edge_half(bp, v->elast, &bvcur);
if (!enext) {
break;
}
vnext = enext->rightv;
vnext->adjchain = v;
chainlen++;
vchainstart = vnext;
v = vnext;
} while (!v->visited && v->eon);
if (chainlen >= 3 && !vchainstart->eon && !vchainend->eon) {
adjust_the_cycle_or_chain(vchainstart, false);
}
}
} while ((vanchor = vanchor->next) != bv->vmesh->boundstart);
}
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
bv = find_bevvert(bp, bmv);
if (bv) {
build_boundary(bp, bv, false);
}
}
}
} | [
"static",
"void",
"adjust_offsets",
"(",
"BevelParams",
"*",
"bp",
",",
"BMesh",
"*",
"bm",
")",
"{",
"BMVert",
"*",
"bmv",
";",
"BevVert",
"*",
"bv",
",",
"*",
"bvcur",
";",
"BoundVert",
"*",
"v",
",",
"*",
"vanchor",
",",
"*",
"vchainstart",
",",
"*",
"vchainend",
",",
"*",
"vnext",
";",
"EdgeHalf",
"*",
"enext",
";",
"BMIter",
"iter",
";",
"bool",
"iscycle",
";",
"int",
"chainlen",
";",
"BM_ITER_MESH",
"(",
"bmv",
",",
"&",
"iter",
",",
"bm",
",",
"BM_VERTS_OF_MESH",
")",
"",
"{",
"if",
"(",
"!",
"BM_elem_flag_test",
"(",
"bmv",
",",
"BM_ELEM_TAG",
")",
")",
"{",
"continue",
";",
"}",
"bv",
"=",
"bvcur",
"=",
"find_bevvert",
"(",
"bp",
",",
"bmv",
")",
";",
"if",
"(",
"!",
"bv",
")",
"{",
"continue",
";",
"}",
"vanchor",
"=",
"bv",
"->",
"vmesh",
"->",
"boundstart",
";",
"do",
"{",
"if",
"(",
"vanchor",
"->",
"visited",
"||",
"!",
"vanchor",
"->",
"eon",
")",
"{",
"continue",
";",
"}",
"v",
"=",
"vchainstart",
"=",
"vchainend",
"=",
"vanchor",
";",
"iscycle",
"=",
"false",
";",
"chainlen",
"=",
"1",
";",
"while",
"(",
"v",
"->",
"eon",
"&&",
"!",
"v",
"->",
"visited",
"&&",
"!",
"iscycle",
")",
"{",
"v",
"->",
"visited",
"=",
"true",
";",
"if",
"(",
"!",
"v",
"->",
"efirst",
")",
"{",
"break",
";",
"}",
"enext",
"=",
"find_other_end_edge_half",
"(",
"bp",
",",
"v",
"->",
"efirst",
",",
"&",
"bvcur",
")",
";",
"if",
"(",
"!",
"enext",
")",
"{",
"break",
";",
"}",
"BLI_assert",
"(",
"enext",
"!=",
"NULL",
")",
";",
"vnext",
"=",
"enext",
"->",
"leftv",
";",
"v",
"->",
"adjchain",
"=",
"vnext",
";",
"vchainend",
"=",
"vnext",
";",
"chainlen",
"++",
";",
"if",
"(",
"vnext",
"->",
"visited",
")",
"{",
"if",
"(",
"vnext",
"!=",
"vchainstart",
")",
"{",
"break",
";",
"}",
"adjust_the_cycle_or_chain",
"(",
"vchainstart",
",",
"true",
")",
";",
"iscycle",
"=",
"true",
";",
"}",
"v",
"=",
"vnext",
";",
"}",
"if",
"(",
"!",
"iscycle",
")",
"{",
"v",
"->",
"adjchain",
"=",
"NULL",
";",
"v",
"=",
"vchainstart",
";",
"bvcur",
"=",
"bv",
";",
"do",
"{",
"v",
"->",
"visited",
"=",
"true",
";",
"if",
"(",
"!",
"v",
"->",
"elast",
")",
"{",
"break",
";",
"}",
"enext",
"=",
"find_other_end_edge_half",
"(",
"bp",
",",
"v",
"->",
"elast",
",",
"&",
"bvcur",
")",
";",
"if",
"(",
"!",
"enext",
")",
"{",
"break",
";",
"}",
"vnext",
"=",
"enext",
"->",
"rightv",
";",
"vnext",
"->",
"adjchain",
"=",
"v",
";",
"chainlen",
"++",
";",
"vchainstart",
"=",
"vnext",
";",
"v",
"=",
"vnext",
";",
"}",
"while",
"(",
"!",
"v",
"->",
"visited",
"&&",
"v",
"->",
"eon",
")",
";",
"if",
"(",
"chainlen",
">=",
"3",
"&&",
"!",
"vchainstart",
"->",
"eon",
"&&",
"!",
"vchainend",
"->",
"eon",
")",
"{",
"adjust_the_cycle_or_chain",
"(",
"vchainstart",
",",
"false",
")",
";",
"}",
"}",
"}",
"while",
"(",
"(",
"vanchor",
"=",
"vanchor",
"->",
"next",
")",
"!=",
"bv",
"->",
"vmesh",
"->",
"boundstart",
")",
";",
"}",
"BM_ITER_MESH",
"(",
"bmv",
",",
"&",
"iter",
",",
"bm",
",",
"BM_VERTS_OF_MESH",
")",
"",
"{",
"if",
"(",
"BM_elem_flag_test",
"(",
"bmv",
",",
"BM_ELEM_TAG",
")",
")",
"{",
"bv",
"=",
"find_bevvert",
"(",
"bp",
",",
"bmv",
")",
";",
"if",
"(",
"bv",
")",
"{",
"build_boundary",
"(",
"bp",
",",
"bv",
",",
"false",
")",
";",
"}",
"}",
"}",
"}"
] | Adjust the offsets to try to make them, as much as possible,
have even-width bevels with offsets that match their specs. | [
"Adjust",
"the",
"offsets",
"to",
"try",
"to",
"make",
"them",
"as",
"much",
"as",
"possible",
"have",
"even",
"-",
"width",
"bevels",
"with",
"offsets",
"that",
"match",
"their",
"specs",
"."
] | [
"/* find and process chains and cycles of unvisited BoundVerts that have eon set */",
"/* note: for repeatability, iterate over all verts of mesh rather than over ghash'ed BMVerts */",
"/* Find one of (1) a cycle that starts and ends at v\n * where each v has v->eon set and had not been visited before;\n * or (2) a chain of v's where the start and end of the chain do not have\n * v->eon set but all else do.\n * It is OK for the first and last elements to\n * have been visited before, but not any of the inner ones.\n * We chain the v's together through v->adjchain, and are following\n * them in left->right direction, meaning that the left side of one edge\n * pairs with the right side of the next edge in the cycle or chain. */",
"/* first follow paired edges in left->right direction */",
"/* right->left direction, changing vchainstart at each step */",
"/* Rebuild boundaries with new width specs */"
] | [
{
"param": "bp",
"type": "BevelParams"
},
{
"param": "bm",
"type": "BMesh"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bp",
"type": "BevelParams",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bm",
"type": "BMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | vmesh_copy_equiv_verts | void | static void vmesh_copy_equiv_verts(VMesh *vm)
{
int n, ns, ns2, i, j, k;
NewVert *v0, *v1;
n = vm->count;
ns = vm->seg;
ns2 = ns / 2;
for (i = 0; i < n; i++) {
for (j = 0; j <= ns2; j++) {
for (k = 0; k <= ns; k++) {
if (is_canon(vm, i, j, k)) {
continue;
}
v1 = mesh_vert(vm, i, j, k);
v0 = mesh_vert_canon(vm, i, j, k);
copy_v3_v3(v1->co, v0->co);
v1->v = v0->v;
}
}
}
} | /* Copy the vertex data to all of vm verts from canonical ones */ | Copy the vertex data to all of vm verts from canonical ones | [
"Copy",
"the",
"vertex",
"data",
"to",
"all",
"of",
"vm",
"verts",
"from",
"canonical",
"ones"
] | static void vmesh_copy_equiv_verts(VMesh *vm)
{
int n, ns, ns2, i, j, k;
NewVert *v0, *v1;
n = vm->count;
ns = vm->seg;
ns2 = ns / 2;
for (i = 0; i < n; i++) {
for (j = 0; j <= ns2; j++) {
for (k = 0; k <= ns; k++) {
if (is_canon(vm, i, j, k)) {
continue;
}
v1 = mesh_vert(vm, i, j, k);
v0 = mesh_vert_canon(vm, i, j, k);
copy_v3_v3(v1->co, v0->co);
v1->v = v0->v;
}
}
}
} | [
"static",
"void",
"vmesh_copy_equiv_verts",
"(",
"VMesh",
"*",
"vm",
")",
"{",
"int",
"n",
",",
"ns",
",",
"ns2",
",",
"i",
",",
"j",
",",
"k",
";",
"NewVert",
"*",
"v0",
",",
"*",
"v1",
";",
"n",
"=",
"vm",
"->",
"count",
";",
"ns",
"=",
"vm",
"->",
"seg",
";",
"ns2",
"=",
"ns",
"/",
"2",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<=",
"ns2",
";",
"j",
"++",
")",
"{",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<=",
"ns",
";",
"k",
"++",
")",
"{",
"if",
"(",
"is_canon",
"(",
"vm",
",",
"i",
",",
"j",
",",
"k",
")",
")",
"{",
"continue",
";",
"}",
"v1",
"=",
"mesh_vert",
"(",
"vm",
",",
"i",
",",
"j",
",",
"k",
")",
";",
"v0",
"=",
"mesh_vert_canon",
"(",
"vm",
",",
"i",
",",
"j",
",",
"k",
")",
";",
"copy_v3_v3",
"(",
"v1",
"->",
"co",
",",
"v0",
"->",
"co",
")",
";",
"v1",
"->",
"v",
"=",
"v0",
"->",
"v",
";",
"}",
"}",
"}",
"}"
] | Copy the vertex data to all of vm verts from canonical ones | [
"Copy",
"the",
"vertex",
"data",
"to",
"all",
"of",
"vm",
"verts",
"from",
"canonical",
"ones"
] | [] | [
{
"param": "vm",
"type": "VMesh"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "vm",
"type": "VMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | vmesh_center | void | static void vmesh_center(VMesh *vm, float r_cent[3])
{
int n, ns2, i;
n = vm->count;
ns2 = vm->seg / 2;
if (vm->seg % 2) {
zero_v3(r_cent);
for (i = 0; i < n; i++) {
add_v3_v3(r_cent, mesh_vert(vm, i, ns2, ns2)->co);
}
mul_v3_fl(r_cent, 1.0f / (float)n);
}
else {
copy_v3_v3(r_cent, mesh_vert(vm, 0, ns2, ns2)->co);
}
} | /* Calculate and return in r_cent the centroid of the center poly */ | Calculate and return in r_cent the centroid of the center poly | [
"Calculate",
"and",
"return",
"in",
"r_cent",
"the",
"centroid",
"of",
"the",
"center",
"poly"
] | static void vmesh_center(VMesh *vm, float r_cent[3])
{
int n, ns2, i;
n = vm->count;
ns2 = vm->seg / 2;
if (vm->seg % 2) {
zero_v3(r_cent);
for (i = 0; i < n; i++) {
add_v3_v3(r_cent, mesh_vert(vm, i, ns2, ns2)->co);
}
mul_v3_fl(r_cent, 1.0f / (float)n);
}
else {
copy_v3_v3(r_cent, mesh_vert(vm, 0, ns2, ns2)->co);
}
} | [
"static",
"void",
"vmesh_center",
"(",
"VMesh",
"*",
"vm",
",",
"float",
"r_cent",
"[",
"3",
"]",
")",
"{",
"int",
"n",
",",
"ns2",
",",
"i",
";",
"n",
"=",
"vm",
"->",
"count",
";",
"ns2",
"=",
"vm",
"->",
"seg",
"/",
"2",
";",
"if",
"(",
"vm",
"->",
"seg",
"%",
"2",
")",
"{",
"zero_v3",
"(",
"r_cent",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"add_v3_v3",
"(",
"r_cent",
",",
"mesh_vert",
"(",
"vm",
",",
"i",
",",
"ns2",
",",
"ns2",
")",
"->",
"co",
")",
";",
"}",
"mul_v3_fl",
"(",
"r_cent",
",",
"1.0f",
"/",
"(",
"float",
")",
"n",
")",
";",
"}",
"else",
"{",
"copy_v3_v3",
"(",
"r_cent",
",",
"mesh_vert",
"(",
"vm",
",",
"0",
",",
"ns2",
",",
"ns2",
")",
"->",
"co",
")",
";",
"}",
"}"
] | Calculate and return in r_cent the centroid of the center poly | [
"Calculate",
"and",
"return",
"in",
"r_cent",
"the",
"centroid",
"of",
"the",
"center",
"poly"
] | [] | [
{
"param": "vm",
"type": "VMesh"
},
{
"param": "r_cent",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "vm",
"type": "VMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r_cent",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | sabin_gamma | float | static float sabin_gamma(int n)
{
double ans, k, k2, k4, k6, x, y;
/* precalculated for common cases of n */
if (n < 3) {
return 0.0f;
}
else if (n == 3) {
ans = 0.065247584f;
}
else if (n == 4) {
ans = 0.25f;
}
else if (n == 5) {
ans = 0.401983447f;
}
else if (n == 6) {
ans = 0.523423277f;
}
else {
k = cos(M_PI / (double)n);
/* need x, real root of x^3 + (4k^2 - 3)x - 2k = 0.
* answer calculated via Wolfram Alpha */
k2 = k * k;
k4 = k2 * k2;
k6 = k4 * k2;
y = pow(M_SQRT3 * sqrt(64.0 * k6 - 144.0 * k4 + 135.0 * k2 - 27.0) + 9.0 * k, 1.0 / 3.0);
x = 0.480749856769136 * y - (0.231120424783545 * (12.0 * k2 - 9.0)) / y;
ans = (k * x + 2.0 * k2 - 1.0) / (x * x * (k * x + 1.0));
}
return (float)ans;
} | /* gamma needed for smooth Catmull-Clark, Sabin modification */ | gamma needed for smooth Catmull-Clark, Sabin modification | [
"gamma",
"needed",
"for",
"smooth",
"Catmull",
"-",
"Clark",
"Sabin",
"modification"
] | static float sabin_gamma(int n)
{
double ans, k, k2, k4, k6, x, y;
if (n < 3) {
return 0.0f;
}
else if (n == 3) {
ans = 0.065247584f;
}
else if (n == 4) {
ans = 0.25f;
}
else if (n == 5) {
ans = 0.401983447f;
}
else if (n == 6) {
ans = 0.523423277f;
}
else {
k = cos(M_PI / (double)n);
k2 = k * k;
k4 = k2 * k2;
k6 = k4 * k2;
y = pow(M_SQRT3 * sqrt(64.0 * k6 - 144.0 * k4 + 135.0 * k2 - 27.0) + 9.0 * k, 1.0 / 3.0);
x = 0.480749856769136 * y - (0.231120424783545 * (12.0 * k2 - 9.0)) / y;
ans = (k * x + 2.0 * k2 - 1.0) / (x * x * (k * x + 1.0));
}
return (float)ans;
} | [
"static",
"float",
"sabin_gamma",
"(",
"int",
"n",
")",
"{",
"double",
"ans",
",",
"k",
",",
"k2",
",",
"k4",
",",
"k6",
",",
"x",
",",
"y",
";",
"if",
"(",
"n",
"<",
"3",
")",
"{",
"return",
"0.0f",
";",
"}",
"else",
"if",
"(",
"n",
"==",
"3",
")",
"{",
"ans",
"=",
"0.065247584f",
";",
"}",
"else",
"if",
"(",
"n",
"==",
"4",
")",
"{",
"ans",
"=",
"0.25f",
";",
"}",
"else",
"if",
"(",
"n",
"==",
"5",
")",
"{",
"ans",
"=",
"0.401983447f",
";",
"}",
"else",
"if",
"(",
"n",
"==",
"6",
")",
"{",
"ans",
"=",
"0.523423277f",
";",
"}",
"else",
"{",
"k",
"=",
"cos",
"(",
"M_PI",
"/",
"(",
"double",
")",
"n",
")",
";",
"k2",
"=",
"k",
"*",
"k",
";",
"k4",
"=",
"k2",
"*",
"k2",
";",
"k6",
"=",
"k4",
"*",
"k2",
";",
"y",
"=",
"pow",
"(",
"M_SQRT3",
"*",
"sqrt",
"(",
"64.0",
"*",
"k6",
"-",
"144.0",
"*",
"k4",
"+",
"135.0",
"*",
"k2",
"-",
"27.0",
")",
"+",
"9.0",
"*",
"k",
",",
"1.0",
"/",
"3.0",
")",
";",
"x",
"=",
"0.480749856769136",
"*",
"y",
"-",
"(",
"0.231120424783545",
"*",
"(",
"12.0",
"*",
"k2",
"-",
"9.0",
")",
")",
"/",
"y",
";",
"ans",
"=",
"(",
"k",
"*",
"x",
"+",
"2.0",
"*",
"k2",
"-",
"1.0",
")",
"/",
"(",
"x",
"*",
"x",
"*",
"(",
"k",
"*",
"x",
"+",
"1.0",
")",
")",
";",
"}",
"return",
"(",
"float",
")",
"ans",
";",
"}"
] | gamma needed for smooth Catmull-Clark, Sabin modification | [
"gamma",
"needed",
"for",
"smooth",
"Catmull",
"-",
"Clark",
"Sabin",
"modification"
] | [
"/* precalculated for common cases of n */",
"/* need x, real root of x^3 + (4k^2 - 3)x - 2k = 0.\n * answer calculated via Wolfram Alpha */"
] | [
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | fill_vmesh_fracs | void | static void fill_vmesh_fracs(VMesh *vm, float *frac, int i)
{
int k, ns;
float total = 0.0f;
ns = vm->seg;
frac[0] = 0.0f;
for (k = 0; k < ns; k++) {
total += len_v3v3(mesh_vert(vm, i, 0, k)->co, mesh_vert(vm, i, 0, k + 1)->co);
frac[k + 1] = total;
}
if (total > 0.0f) {
for (k = 1; k <= ns; k++) {
frac[k] /= total;
}
}
else {
frac[ns] = 1.0f;
}
} | /* Fill frac with fractions of way along ring 0 for vertex i, for use with interp_range function */ | Fill frac with fractions of way along ring 0 for vertex i, for use with interp_range function | [
"Fill",
"frac",
"with",
"fractions",
"of",
"way",
"along",
"ring",
"0",
"for",
"vertex",
"i",
"for",
"use",
"with",
"interp_range",
"function"
] | static void fill_vmesh_fracs(VMesh *vm, float *frac, int i)
{
int k, ns;
float total = 0.0f;
ns = vm->seg;
frac[0] = 0.0f;
for (k = 0; k < ns; k++) {
total += len_v3v3(mesh_vert(vm, i, 0, k)->co, mesh_vert(vm, i, 0, k + 1)->co);
frac[k + 1] = total;
}
if (total > 0.0f) {
for (k = 1; k <= ns; k++) {
frac[k] /= total;
}
}
else {
frac[ns] = 1.0f;
}
} | [
"static",
"void",
"fill_vmesh_fracs",
"(",
"VMesh",
"*",
"vm",
",",
"float",
"*",
"frac",
",",
"int",
"i",
")",
"{",
"int",
"k",
",",
"ns",
";",
"float",
"total",
"=",
"0.0f",
";",
"ns",
"=",
"vm",
"->",
"seg",
";",
"frac",
"[",
"0",
"]",
"=",
"0.0f",
";",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<",
"ns",
";",
"k",
"++",
")",
"{",
"total",
"+=",
"len_v3v3",
"(",
"mesh_vert",
"(",
"vm",
",",
"i",
",",
"0",
",",
"k",
")",
"->",
"co",
",",
"mesh_vert",
"(",
"vm",
",",
"i",
",",
"0",
",",
"k",
"+",
"1",
")",
"->",
"co",
")",
";",
"frac",
"[",
"k",
"+",
"1",
"]",
"=",
"total",
";",
"}",
"if",
"(",
"total",
">",
"0.0f",
")",
"{",
"for",
"(",
"k",
"=",
"1",
";",
"k",
"<=",
"ns",
";",
"k",
"++",
")",
"{",
"frac",
"[",
"k",
"]",
"/=",
"total",
";",
"}",
"}",
"else",
"{",
"frac",
"[",
"ns",
"]",
"=",
"1.0f",
";",
"}",
"}"
] | Fill frac with fractions of way along ring 0 for vertex i, for use with interp_range function | [
"Fill",
"frac",
"with",
"fractions",
"of",
"way",
"along",
"ring",
"0",
"for",
"vertex",
"i",
"for",
"use",
"with",
"interp_range",
"function"
] | [] | [
{
"param": "vm",
"type": "VMesh"
},
{
"param": "frac",
"type": "float"
},
{
"param": "i",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "vm",
"type": "VMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "frac",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "i",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | fill_profile_fracs | void | static void fill_profile_fracs(BevelParams *bp, BoundVert *bndv, float *frac, int ns)
{
int k;
float co[3], nextco[3];
float total = 0.0f;
frac[0] = 0.0f;
copy_v3_v3(co, bndv->nv.co);
for (k = 0; k < ns; k++) {
get_profile_point(bp, &bndv->profile, k + 1, ns, nextco);
total += len_v3v3(co, nextco);
frac[k + 1] = total;
copy_v3_v3(co, nextco);
}
if (total > 0.0f) {
for (k = 1; k <= ns; k++) {
frac[k] /= total;
}
}
else {
frac[ns] = 1.0f;
}
} | /* Like fill_vmesh_fracs but want fractions for profile points of bndv, with ns segments */ | Like fill_vmesh_fracs but want fractions for profile points of bndv, with ns segments | [
"Like",
"fill_vmesh_fracs",
"but",
"want",
"fractions",
"for",
"profile",
"points",
"of",
"bndv",
"with",
"ns",
"segments"
] | static void fill_profile_fracs(BevelParams *bp, BoundVert *bndv, float *frac, int ns)
{
int k;
float co[3], nextco[3];
float total = 0.0f;
frac[0] = 0.0f;
copy_v3_v3(co, bndv->nv.co);
for (k = 0; k < ns; k++) {
get_profile_point(bp, &bndv->profile, k + 1, ns, nextco);
total += len_v3v3(co, nextco);
frac[k + 1] = total;
copy_v3_v3(co, nextco);
}
if (total > 0.0f) {
for (k = 1; k <= ns; k++) {
frac[k] /= total;
}
}
else {
frac[ns] = 1.0f;
}
} | [
"static",
"void",
"fill_profile_fracs",
"(",
"BevelParams",
"*",
"bp",
",",
"BoundVert",
"*",
"bndv",
",",
"float",
"*",
"frac",
",",
"int",
"ns",
")",
"{",
"int",
"k",
";",
"float",
"co",
"[",
"3",
"]",
",",
"nextco",
"[",
"3",
"]",
";",
"float",
"total",
"=",
"0.0f",
";",
"frac",
"[",
"0",
"]",
"=",
"0.0f",
";",
"copy_v3_v3",
"(",
"co",
",",
"bndv",
"->",
"nv",
".",
"co",
")",
";",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<",
"ns",
";",
"k",
"++",
")",
"{",
"get_profile_point",
"(",
"bp",
",",
"&",
"bndv",
"->",
"profile",
",",
"k",
"+",
"1",
",",
"ns",
",",
"nextco",
")",
";",
"total",
"+=",
"len_v3v3",
"(",
"co",
",",
"nextco",
")",
";",
"frac",
"[",
"k",
"+",
"1",
"]",
"=",
"total",
";",
"copy_v3_v3",
"(",
"co",
",",
"nextco",
")",
";",
"}",
"if",
"(",
"total",
">",
"0.0f",
")",
"{",
"for",
"(",
"k",
"=",
"1",
";",
"k",
"<=",
"ns",
";",
"k",
"++",
")",
"{",
"frac",
"[",
"k",
"]",
"/=",
"total",
";",
"}",
"}",
"else",
"{",
"frac",
"[",
"ns",
"]",
"=",
"1.0f",
";",
"}",
"}"
] | Like fill_vmesh_fracs but want fractions for profile points of bndv, with ns segments | [
"Like",
"fill_vmesh_fracs",
"but",
"want",
"fractions",
"for",
"profile",
"points",
"of",
"bndv",
"with",
"ns",
"segments"
] | [] | [
{
"param": "bp",
"type": "BevelParams"
},
{
"param": "bndv",
"type": "BoundVert"
},
{
"param": "frac",
"type": "float"
},
{
"param": "ns",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bp",
"type": "BevelParams",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bndv",
"type": "BoundVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "frac",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ns",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | interp_vmesh | VMesh | static VMesh *interp_vmesh(BevelParams *bp, VMesh *vm0, int nseg)
{
int n, ns0, nseg2, odd, i, j, k, j0, k0, k0prev, j0inc, k0inc;
float *prev_frac, *frac, *new_frac, *prev_new_frac;
float f, restj, restk, restkprev;
float quad[4][3], co[3], center[3];
VMesh *vm1;
BoundVert *bndv;
n = vm0->count;
ns0 = vm0->seg;
nseg2 = nseg / 2;
odd = nseg % 2;
vm1 = new_adj_vmesh(bp->mem_arena, n, nseg, vm0->boundstart);
prev_frac = BLI_array_alloca(prev_frac, (ns0 + 1));
frac = BLI_array_alloca(frac, (ns0 + 1));
new_frac = BLI_array_alloca(new_frac, (nseg + 1));
prev_new_frac = BLI_array_alloca(prev_new_frac, (nseg + 1));
fill_vmesh_fracs(vm0, prev_frac, n - 1);
bndv = vm0->boundstart;
fill_profile_fracs(bp, bndv->prev, prev_new_frac, nseg);
for (i = 0; i < n; i++) {
fill_vmesh_fracs(vm0, frac, i);
fill_profile_fracs(bp, bndv, new_frac, nseg);
for (j = 0; j <= nseg2 - 1 + odd; j++) {
for (k = 0; k <= nseg2; k++) {
f = new_frac[k];
k0 = interp_range(frac, ns0, f, &restk);
f = prev_new_frac[nseg - j];
k0prev = interp_range(prev_frac, ns0, f, &restkprev);
j0 = ns0 - k0prev;
restj = -restkprev;
if (restj > -BEVEL_EPSILON) {
restj = 0.0f;
}
else {
j0 = j0 - 1;
restj = 1.0f + restj;
}
/* Use bilinear interpolation within the source quad; could be smarter here */
if (restj < BEVEL_EPSILON && restk < BEVEL_EPSILON) {
copy_v3_v3(co, mesh_vert_canon(vm0, i, j0, k0)->co);
}
else {
j0inc = (restj < BEVEL_EPSILON || j0 == ns0) ? 0 : 1;
k0inc = (restk < BEVEL_EPSILON || k0 == ns0) ? 0 : 1;
copy_v3_v3(quad[0], mesh_vert_canon(vm0, i, j0, k0)->co);
copy_v3_v3(quad[1], mesh_vert_canon(vm0, i, j0, k0 + k0inc)->co);
copy_v3_v3(quad[2], mesh_vert_canon(vm0, i, j0 + j0inc, k0 + k0inc)->co);
copy_v3_v3(quad[3], mesh_vert_canon(vm0, i, j0 + j0inc, k0)->co);
interp_bilinear_quad_v3(quad, restk, restj, co);
}
copy_v3_v3(mesh_vert(vm1, i, j, k)->co, co);
}
}
bndv = bndv->next;
memcpy(prev_frac, frac, (ns0 + 1) * sizeof(float));
memcpy(prev_new_frac, new_frac, (nseg + 1) * sizeof(float));
}
if (!odd) {
vmesh_center(vm0, center);
copy_v3_v3(mesh_vert(vm1, 0, nseg2, nseg2)->co, center);
}
vmesh_copy_equiv_verts(vm1);
return vm1;
} | /* Interpolate given vmesh to make one with target nseg border vertices on the profiles */ | Interpolate given vmesh to make one with target nseg border vertices on the profiles | [
"Interpolate",
"given",
"vmesh",
"to",
"make",
"one",
"with",
"target",
"nseg",
"border",
"vertices",
"on",
"the",
"profiles"
] | static VMesh *interp_vmesh(BevelParams *bp, VMesh *vm0, int nseg)
{
int n, ns0, nseg2, odd, i, j, k, j0, k0, k0prev, j0inc, k0inc;
float *prev_frac, *frac, *new_frac, *prev_new_frac;
float f, restj, restk, restkprev;
float quad[4][3], co[3], center[3];
VMesh *vm1;
BoundVert *bndv;
n = vm0->count;
ns0 = vm0->seg;
nseg2 = nseg / 2;
odd = nseg % 2;
vm1 = new_adj_vmesh(bp->mem_arena, n, nseg, vm0->boundstart);
prev_frac = BLI_array_alloca(prev_frac, (ns0 + 1));
frac = BLI_array_alloca(frac, (ns0 + 1));
new_frac = BLI_array_alloca(new_frac, (nseg + 1));
prev_new_frac = BLI_array_alloca(prev_new_frac, (nseg + 1));
fill_vmesh_fracs(vm0, prev_frac, n - 1);
bndv = vm0->boundstart;
fill_profile_fracs(bp, bndv->prev, prev_new_frac, nseg);
for (i = 0; i < n; i++) {
fill_vmesh_fracs(vm0, frac, i);
fill_profile_fracs(bp, bndv, new_frac, nseg);
for (j = 0; j <= nseg2 - 1 + odd; j++) {
for (k = 0; k <= nseg2; k++) {
f = new_frac[k];
k0 = interp_range(frac, ns0, f, &restk);
f = prev_new_frac[nseg - j];
k0prev = interp_range(prev_frac, ns0, f, &restkprev);
j0 = ns0 - k0prev;
restj = -restkprev;
if (restj > -BEVEL_EPSILON) {
restj = 0.0f;
}
else {
j0 = j0 - 1;
restj = 1.0f + restj;
}
if (restj < BEVEL_EPSILON && restk < BEVEL_EPSILON) {
copy_v3_v3(co, mesh_vert_canon(vm0, i, j0, k0)->co);
}
else {
j0inc = (restj < BEVEL_EPSILON || j0 == ns0) ? 0 : 1;
k0inc = (restk < BEVEL_EPSILON || k0 == ns0) ? 0 : 1;
copy_v3_v3(quad[0], mesh_vert_canon(vm0, i, j0, k0)->co);
copy_v3_v3(quad[1], mesh_vert_canon(vm0, i, j0, k0 + k0inc)->co);
copy_v3_v3(quad[2], mesh_vert_canon(vm0, i, j0 + j0inc, k0 + k0inc)->co);
copy_v3_v3(quad[3], mesh_vert_canon(vm0, i, j0 + j0inc, k0)->co);
interp_bilinear_quad_v3(quad, restk, restj, co);
}
copy_v3_v3(mesh_vert(vm1, i, j, k)->co, co);
}
}
bndv = bndv->next;
memcpy(prev_frac, frac, (ns0 + 1) * sizeof(float));
memcpy(prev_new_frac, new_frac, (nseg + 1) * sizeof(float));
}
if (!odd) {
vmesh_center(vm0, center);
copy_v3_v3(mesh_vert(vm1, 0, nseg2, nseg2)->co, center);
}
vmesh_copy_equiv_verts(vm1);
return vm1;
} | [
"static",
"VMesh",
"*",
"interp_vmesh",
"(",
"BevelParams",
"*",
"bp",
",",
"VMesh",
"*",
"vm0",
",",
"int",
"nseg",
")",
"{",
"int",
"n",
",",
"ns0",
",",
"nseg2",
",",
"odd",
",",
"i",
",",
"j",
",",
"k",
",",
"j0",
",",
"k0",
",",
"k0prev",
",",
"j0inc",
",",
"k0inc",
";",
"float",
"*",
"prev_frac",
",",
"*",
"frac",
",",
"*",
"new_frac",
",",
"*",
"prev_new_frac",
";",
"float",
"f",
",",
"restj",
",",
"restk",
",",
"restkprev",
";",
"float",
"quad",
"[",
"4",
"]",
"[",
"3",
"]",
",",
"co",
"[",
"3",
"]",
",",
"center",
"[",
"3",
"]",
";",
"VMesh",
"*",
"vm1",
";",
"BoundVert",
"*",
"bndv",
";",
"n",
"=",
"vm0",
"->",
"count",
";",
"ns0",
"=",
"vm0",
"->",
"seg",
";",
"nseg2",
"=",
"nseg",
"/",
"2",
";",
"odd",
"=",
"nseg",
"%",
"2",
";",
"vm1",
"=",
"new_adj_vmesh",
"(",
"bp",
"->",
"mem_arena",
",",
"n",
",",
"nseg",
",",
"vm0",
"->",
"boundstart",
")",
";",
"prev_frac",
"=",
"BLI_array_alloca",
"(",
"prev_frac",
",",
"(",
"ns0",
"+",
"1",
")",
")",
";",
"frac",
"=",
"BLI_array_alloca",
"(",
"frac",
",",
"(",
"ns0",
"+",
"1",
")",
")",
";",
"new_frac",
"=",
"BLI_array_alloca",
"(",
"new_frac",
",",
"(",
"nseg",
"+",
"1",
")",
")",
";",
"prev_new_frac",
"=",
"BLI_array_alloca",
"(",
"prev_new_frac",
",",
"(",
"nseg",
"+",
"1",
")",
")",
";",
"fill_vmesh_fracs",
"(",
"vm0",
",",
"prev_frac",
",",
"n",
"-",
"1",
")",
";",
"bndv",
"=",
"vm0",
"->",
"boundstart",
";",
"fill_profile_fracs",
"(",
"bp",
",",
"bndv",
"->",
"prev",
",",
"prev_new_frac",
",",
"nseg",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"fill_vmesh_fracs",
"(",
"vm0",
",",
"frac",
",",
"i",
")",
";",
"fill_profile_fracs",
"(",
"bp",
",",
"bndv",
",",
"new_frac",
",",
"nseg",
")",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<=",
"nseg2",
"-",
"1",
"+",
"odd",
";",
"j",
"++",
")",
"{",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<=",
"nseg2",
";",
"k",
"++",
")",
"{",
"f",
"=",
"new_frac",
"[",
"k",
"]",
";",
"k0",
"=",
"interp_range",
"(",
"frac",
",",
"ns0",
",",
"f",
",",
"&",
"restk",
")",
";",
"f",
"=",
"prev_new_frac",
"[",
"nseg",
"-",
"j",
"]",
";",
"k0prev",
"=",
"interp_range",
"(",
"prev_frac",
",",
"ns0",
",",
"f",
",",
"&",
"restkprev",
")",
";",
"j0",
"=",
"ns0",
"-",
"k0prev",
";",
"restj",
"=",
"-",
"restkprev",
";",
"if",
"(",
"restj",
">",
"-",
"BEVEL_EPSILON",
")",
"{",
"restj",
"=",
"0.0f",
";",
"}",
"else",
"{",
"j0",
"=",
"j0",
"-",
"1",
";",
"restj",
"=",
"1.0f",
"+",
"restj",
";",
"}",
"if",
"(",
"restj",
"<",
"BEVEL_EPSILON",
"&&",
"restk",
"<",
"BEVEL_EPSILON",
")",
"{",
"copy_v3_v3",
"(",
"co",
",",
"mesh_vert_canon",
"(",
"vm0",
",",
"i",
",",
"j0",
",",
"k0",
")",
"->",
"co",
")",
";",
"}",
"else",
"{",
"j0inc",
"=",
"(",
"restj",
"<",
"BEVEL_EPSILON",
"||",
"j0",
"==",
"ns0",
")",
"?",
"0",
":",
"1",
";",
"k0inc",
"=",
"(",
"restk",
"<",
"BEVEL_EPSILON",
"||",
"k0",
"==",
"ns0",
")",
"?",
"0",
":",
"1",
";",
"copy_v3_v3",
"(",
"quad",
"[",
"0",
"]",
",",
"mesh_vert_canon",
"(",
"vm0",
",",
"i",
",",
"j0",
",",
"k0",
")",
"->",
"co",
")",
";",
"copy_v3_v3",
"(",
"quad",
"[",
"1",
"]",
",",
"mesh_vert_canon",
"(",
"vm0",
",",
"i",
",",
"j0",
",",
"k0",
"+",
"k0inc",
")",
"->",
"co",
")",
";",
"copy_v3_v3",
"(",
"quad",
"[",
"2",
"]",
",",
"mesh_vert_canon",
"(",
"vm0",
",",
"i",
",",
"j0",
"+",
"j0inc",
",",
"k0",
"+",
"k0inc",
")",
"->",
"co",
")",
";",
"copy_v3_v3",
"(",
"quad",
"[",
"3",
"]",
",",
"mesh_vert_canon",
"(",
"vm0",
",",
"i",
",",
"j0",
"+",
"j0inc",
",",
"k0",
")",
"->",
"co",
")",
";",
"interp_bilinear_quad_v3",
"(",
"quad",
",",
"restk",
",",
"restj",
",",
"co",
")",
";",
"}",
"copy_v3_v3",
"(",
"mesh_vert",
"(",
"vm1",
",",
"i",
",",
"j",
",",
"k",
")",
"->",
"co",
",",
"co",
")",
";",
"}",
"}",
"bndv",
"=",
"bndv",
"->",
"next",
";",
"memcpy",
"(",
"prev_frac",
",",
"frac",
",",
"(",
"ns0",
"+",
"1",
")",
"*",
"sizeof",
"(",
"float",
")",
")",
";",
"memcpy",
"(",
"prev_new_frac",
",",
"new_frac",
",",
"(",
"nseg",
"+",
"1",
")",
"*",
"sizeof",
"(",
"float",
")",
")",
";",
"}",
"if",
"(",
"!",
"odd",
")",
"{",
"vmesh_center",
"(",
"vm0",
",",
"center",
")",
";",
"copy_v3_v3",
"(",
"mesh_vert",
"(",
"vm1",
",",
"0",
",",
"nseg2",
",",
"nseg2",
")",
"->",
"co",
",",
"center",
")",
";",
"}",
"vmesh_copy_equiv_verts",
"(",
"vm1",
")",
";",
"return",
"vm1",
";",
"}"
] | Interpolate given vmesh to make one with target nseg border vertices on the profiles | [
"Interpolate",
"given",
"vmesh",
"to",
"make",
"one",
"with",
"target",
"nseg",
"border",
"vertices",
"on",
"the",
"profiles"
] | [
"/* Use bilinear interpolation within the source quad; could be smarter here */"
] | [
{
"param": "bp",
"type": "BevelParams"
},
{
"param": "vm0",
"type": "VMesh"
},
{
"param": "nseg",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bp",
"type": "BevelParams",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vm0",
"type": "VMesh",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nseg",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | make_cube_corner_square | VMesh | static VMesh *make_cube_corner_square(MemArena *mem_arena, int nseg)
{
VMesh *vm;
float co[3];
int i, j, k, ns2;
ns2 = nseg / 2;
vm = new_adj_vmesh(mem_arena, 3, nseg, NULL);
vm->count = 0; // reset, so following loop will end up with correct count
for (i = 0; i < 3; i++) {
zero_v3(co);
co[i] = 1.0f;
add_new_bound_vert(mem_arena, vm, co);
}
for (i = 0; i < 3; i++) {
for (j = 0; j <= ns2; j++) {
for (k = 0; k <= ns2; k++) {
if (!is_canon(vm, i, j, k)) {
continue;
}
co[i] = 1.0f;
co[(i + 1) % 3] = (float)k * 2.0f / (float)nseg;
co[(i + 2) % 3] = (float)j * 2.0f / (float)nseg;
copy_v3_v3(mesh_vert(vm, i, j, k)->co, co);
}
}
}
vmesh_copy_equiv_verts(vm);
return vm;
} | /* Special case for cube corner, when r is PRO_SQUARE_R, meaning straight sides */ | Special case for cube corner, when r is PRO_SQUARE_R, meaning straight sides | [
"Special",
"case",
"for",
"cube",
"corner",
"when",
"r",
"is",
"PRO_SQUARE_R",
"meaning",
"straight",
"sides"
] | static VMesh *make_cube_corner_square(MemArena *mem_arena, int nseg)
{
VMesh *vm;
float co[3];
int i, j, k, ns2;
ns2 = nseg / 2;
vm = new_adj_vmesh(mem_arena, 3, nseg, NULL);
vm->count = 0;
for (i = 0; i < 3; i++) {
zero_v3(co);
co[i] = 1.0f;
add_new_bound_vert(mem_arena, vm, co);
}
for (i = 0; i < 3; i++) {
for (j = 0; j <= ns2; j++) {
for (k = 0; k <= ns2; k++) {
if (!is_canon(vm, i, j, k)) {
continue;
}
co[i] = 1.0f;
co[(i + 1) % 3] = (float)k * 2.0f / (float)nseg;
co[(i + 2) % 3] = (float)j * 2.0f / (float)nseg;
copy_v3_v3(mesh_vert(vm, i, j, k)->co, co);
}
}
}
vmesh_copy_equiv_verts(vm);
return vm;
} | [
"static",
"VMesh",
"*",
"make_cube_corner_square",
"(",
"MemArena",
"*",
"mem_arena",
",",
"int",
"nseg",
")",
"{",
"VMesh",
"*",
"vm",
";",
"float",
"co",
"[",
"3",
"]",
";",
"int",
"i",
",",
"j",
",",
"k",
",",
"ns2",
";",
"ns2",
"=",
"nseg",
"/",
"2",
";",
"vm",
"=",
"new_adj_vmesh",
"(",
"mem_arena",
",",
"3",
",",
"nseg",
",",
"NULL",
")",
";",
"vm",
"->",
"count",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"zero_v3",
"(",
"co",
")",
";",
"co",
"[",
"i",
"]",
"=",
"1.0f",
";",
"add_new_bound_vert",
"(",
"mem_arena",
",",
"vm",
",",
"co",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<=",
"ns2",
";",
"j",
"++",
")",
"{",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<=",
"ns2",
";",
"k",
"++",
")",
"{",
"if",
"(",
"!",
"is_canon",
"(",
"vm",
",",
"i",
",",
"j",
",",
"k",
")",
")",
"{",
"continue",
";",
"}",
"co",
"[",
"i",
"]",
"=",
"1.0f",
";",
"co",
"[",
"(",
"i",
"+",
"1",
")",
"%",
"3",
"]",
"=",
"(",
"float",
")",
"k",
"*",
"2.0f",
"/",
"(",
"float",
")",
"nseg",
";",
"co",
"[",
"(",
"i",
"+",
"2",
")",
"%",
"3",
"]",
"=",
"(",
"float",
")",
"j",
"*",
"2.0f",
"/",
"(",
"float",
")",
"nseg",
";",
"copy_v3_v3",
"(",
"mesh_vert",
"(",
"vm",
",",
"i",
",",
"j",
",",
"k",
")",
"->",
"co",
",",
"co",
")",
";",
"}",
"}",
"}",
"vmesh_copy_equiv_verts",
"(",
"vm",
")",
";",
"return",
"vm",
";",
"}"
] | Special case for cube corner, when r is PRO_SQUARE_R, meaning straight sides | [
"Special",
"case",
"for",
"cube",
"corner",
"when",
"r",
"is",
"PRO_SQUARE_R",
"meaning",
"straight",
"sides"
] | [
"// reset, so following loop will end up with correct count"
] | [
{
"param": "mem_arena",
"type": "MemArena"
},
{
"param": "nseg",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mem_arena",
"type": "MemArena",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nseg",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | make_cube_corner_square_in | VMesh | static VMesh *make_cube_corner_square_in(MemArena *mem_arena, int nseg)
{
VMesh *vm;
float co[3];
float b;
int i, k, ns2, odd;
ns2 = nseg / 2;
odd = nseg % 2;
vm = new_adj_vmesh(mem_arena, 3, nseg, NULL);
vm->count = 0; // reset, so following loop will end up with correct count
for (i = 0; i < 3; i++) {
zero_v3(co);
co[i] = 1.0f;
add_new_bound_vert(mem_arena, vm, co);
}
if (odd) {
b = 2.0f / (2.0f * (float)ns2 + (float)M_SQRT2);
}
else {
b = 2.0f / (float)nseg;
}
for (i = 0; i < 3; i++) {
for (k = 0; k <= ns2; k++) {
co[i] = 1.0f - (float)k * b;
co[(i + 1) % 3] = 0.0f;
co[(i + 2) % 3] = 0.0f;
copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co);
co[(i + 1) % 3] = 1.0f - (float)k * b;
co[(i + 2) % 3] = 0.0f;
co[i] = 0.0f;
copy_v3_v3(mesh_vert(vm, i, 0, nseg - k)->co, co);
}
}
return vm;
} | /* Special case for cube corner, when r is PRO_SQUARE_IN_R, meaning inward
* straight sides.
* We mostly don't want a VMesh at all for this case -- just a three-way weld
* with a triangle in the middle for odd nseg */ | Special case for cube corner, when r is PRO_SQUARE_IN_R, meaning inward
straight sides.
We mostly don't want a VMesh at all for this case -- just a three-way weld
with a triangle in the middle for odd nseg | [
"Special",
"case",
"for",
"cube",
"corner",
"when",
"r",
"is",
"PRO_SQUARE_IN_R",
"meaning",
"inward",
"straight",
"sides",
".",
"We",
"mostly",
"don",
"'",
"t",
"want",
"a",
"VMesh",
"at",
"all",
"for",
"this",
"case",
"--",
"just",
"a",
"three",
"-",
"way",
"weld",
"with",
"a",
"triangle",
"in",
"the",
"middle",
"for",
"odd",
"nseg"
] | static VMesh *make_cube_corner_square_in(MemArena *mem_arena, int nseg)
{
VMesh *vm;
float co[3];
float b;
int i, k, ns2, odd;
ns2 = nseg / 2;
odd = nseg % 2;
vm = new_adj_vmesh(mem_arena, 3, nseg, NULL);
vm->count = 0;
for (i = 0; i < 3; i++) {
zero_v3(co);
co[i] = 1.0f;
add_new_bound_vert(mem_arena, vm, co);
}
if (odd) {
b = 2.0f / (2.0f * (float)ns2 + (float)M_SQRT2);
}
else {
b = 2.0f / (float)nseg;
}
for (i = 0; i < 3; i++) {
for (k = 0; k <= ns2; k++) {
co[i] = 1.0f - (float)k * b;
co[(i + 1) % 3] = 0.0f;
co[(i + 2) % 3] = 0.0f;
copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co);
co[(i + 1) % 3] = 1.0f - (float)k * b;
co[(i + 2) % 3] = 0.0f;
co[i] = 0.0f;
copy_v3_v3(mesh_vert(vm, i, 0, nseg - k)->co, co);
}
}
return vm;
} | [
"static",
"VMesh",
"*",
"make_cube_corner_square_in",
"(",
"MemArena",
"*",
"mem_arena",
",",
"int",
"nseg",
")",
"{",
"VMesh",
"*",
"vm",
";",
"float",
"co",
"[",
"3",
"]",
";",
"float",
"b",
";",
"int",
"i",
",",
"k",
",",
"ns2",
",",
"odd",
";",
"ns2",
"=",
"nseg",
"/",
"2",
";",
"odd",
"=",
"nseg",
"%",
"2",
";",
"vm",
"=",
"new_adj_vmesh",
"(",
"mem_arena",
",",
"3",
",",
"nseg",
",",
"NULL",
")",
";",
"vm",
"->",
"count",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"zero_v3",
"(",
"co",
")",
";",
"co",
"[",
"i",
"]",
"=",
"1.0f",
";",
"add_new_bound_vert",
"(",
"mem_arena",
",",
"vm",
",",
"co",
")",
";",
"}",
"if",
"(",
"odd",
")",
"{",
"b",
"=",
"2.0f",
"/",
"(",
"2.0f",
"*",
"(",
"float",
")",
"ns2",
"+",
"(",
"float",
")",
"M_SQRT2",
")",
";",
"}",
"else",
"{",
"b",
"=",
"2.0f",
"/",
"(",
"float",
")",
"nseg",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<=",
"ns2",
";",
"k",
"++",
")",
"{",
"co",
"[",
"i",
"]",
"=",
"1.0f",
"-",
"(",
"float",
")",
"k",
"*",
"b",
";",
"co",
"[",
"(",
"i",
"+",
"1",
")",
"%",
"3",
"]",
"=",
"0.0f",
";",
"co",
"[",
"(",
"i",
"+",
"2",
")",
"%",
"3",
"]",
"=",
"0.0f",
";",
"copy_v3_v3",
"(",
"mesh_vert",
"(",
"vm",
",",
"i",
",",
"0",
",",
"k",
")",
"->",
"co",
",",
"co",
")",
";",
"co",
"[",
"(",
"i",
"+",
"1",
")",
"%",
"3",
"]",
"=",
"1.0f",
"-",
"(",
"float",
")",
"k",
"*",
"b",
";",
"co",
"[",
"(",
"i",
"+",
"2",
")",
"%",
"3",
"]",
"=",
"0.0f",
";",
"co",
"[",
"i",
"]",
"=",
"0.0f",
";",
"copy_v3_v3",
"(",
"mesh_vert",
"(",
"vm",
",",
"i",
",",
"0",
",",
"nseg",
"-",
"k",
")",
"->",
"co",
",",
"co",
")",
";",
"}",
"}",
"return",
"vm",
";",
"}"
] | Special case for cube corner, when r is PRO_SQUARE_IN_R, meaning inward
straight sides. | [
"Special",
"case",
"for",
"cube",
"corner",
"when",
"r",
"is",
"PRO_SQUARE_IN_R",
"meaning",
"inward",
"straight",
"sides",
"."
] | [
"// reset, so following loop will end up with correct count"
] | [
{
"param": "mem_arena",
"type": "MemArena"
},
{
"param": "nseg",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mem_arena",
"type": "MemArena",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nseg",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | snap_to_pipe_profile | void | static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3])
{
float va[3], vb[3], edir[3], va0[3], vb0[3], vmid0[3];
float plane[4], m[4][4], minv[4][4], p[3], snap[3];
Profile *pro = &vpipe->profile;
EdgeHalf *e = vpipe->ebev;
copy_v3_v3(va, pro->coa);
copy_v3_v3(vb, pro->cob);
sub_v3_v3v3(edir, e->e->v1->co, e->e->v2->co);
plane_from_point_normal_v3(plane, co, edir);
closest_to_plane_v3(va0, plane, va);
closest_to_plane_v3(vb0, plane, vb);
closest_to_plane_v3(vmid0, plane, pro->midco);
if (make_unit_square_map(va0, vmid0, vb0, m)) {
/* Transform co and project it onto superellipse */
if (!invert_m4_m4(minv, m)) {
/* shouldn't happen */
BLI_assert(!"failed inverse during pipe profile snap");
return;
}
mul_v3_m4v3(p, minv, co);
snap_to_superellipsoid(p, pro->super_r, midline);
mul_v3_m4v3(snap, m, p);
copy_v3_v3(co, snap);
}
else {
/* planar case: just snap to line va0--vb0 */
closest_to_line_segment_v3(p, co, va0, vb0);
copy_v3_v3(co, p);
}
} | /* Snap co to the closest point on the profile for vpipe projected onto the plane
* containing co with normal in the direction of edge vpipe->ebev.
* For the square profiles, need to decide whether to snap to just one plane
* or to the midpoint of the profile; do so if midline is true. */ | Snap co to the closest point on the profile for vpipe projected onto the plane
containing co with normal in the direction of edge vpipe->ebev.
For the square profiles, need to decide whether to snap to just one plane
or to the midpoint of the profile; do so if midline is true. | [
"Snap",
"co",
"to",
"the",
"closest",
"point",
"on",
"the",
"profile",
"for",
"vpipe",
"projected",
"onto",
"the",
"plane",
"containing",
"co",
"with",
"normal",
"in",
"the",
"direction",
"of",
"edge",
"vpipe",
"-",
">",
"ebev",
".",
"For",
"the",
"square",
"profiles",
"need",
"to",
"decide",
"whether",
"to",
"snap",
"to",
"just",
"one",
"plane",
"or",
"to",
"the",
"midpoint",
"of",
"the",
"profile",
";",
"do",
"so",
"if",
"midline",
"is",
"true",
"."
] | static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3])
{
float va[3], vb[3], edir[3], va0[3], vb0[3], vmid0[3];
float plane[4], m[4][4], minv[4][4], p[3], snap[3];
Profile *pro = &vpipe->profile;
EdgeHalf *e = vpipe->ebev;
copy_v3_v3(va, pro->coa);
copy_v3_v3(vb, pro->cob);
sub_v3_v3v3(edir, e->e->v1->co, e->e->v2->co);
plane_from_point_normal_v3(plane, co, edir);
closest_to_plane_v3(va0, plane, va);
closest_to_plane_v3(vb0, plane, vb);
closest_to_plane_v3(vmid0, plane, pro->midco);
if (make_unit_square_map(va0, vmid0, vb0, m)) {
if (!invert_m4_m4(minv, m)) {
BLI_assert(!"failed inverse during pipe profile snap");
return;
}
mul_v3_m4v3(p, minv, co);
snap_to_superellipsoid(p, pro->super_r, midline);
mul_v3_m4v3(snap, m, p);
copy_v3_v3(co, snap);
}
else {
closest_to_line_segment_v3(p, co, va0, vb0);
copy_v3_v3(co, p);
}
} | [
"static",
"void",
"snap_to_pipe_profile",
"(",
"BoundVert",
"*",
"vpipe",
",",
"bool",
"midline",
",",
"float",
"co",
"[",
"3",
"]",
")",
"{",
"float",
"va",
"[",
"3",
"]",
",",
"vb",
"[",
"3",
"]",
",",
"edir",
"[",
"3",
"]",
",",
"va0",
"[",
"3",
"]",
",",
"vb0",
"[",
"3",
"]",
",",
"vmid0",
"[",
"3",
"]",
";",
"float",
"plane",
"[",
"4",
"]",
",",
"m",
"[",
"4",
"]",
"[",
"4",
"]",
",",
"minv",
"[",
"4",
"]",
"[",
"4",
"]",
",",
"p",
"[",
"3",
"]",
",",
"snap",
"[",
"3",
"]",
";",
"Profile",
"*",
"pro",
"=",
"&",
"vpipe",
"->",
"profile",
";",
"EdgeHalf",
"*",
"e",
"=",
"vpipe",
"->",
"ebev",
";",
"copy_v3_v3",
"(",
"va",
",",
"pro",
"->",
"coa",
")",
";",
"copy_v3_v3",
"(",
"vb",
",",
"pro",
"->",
"cob",
")",
";",
"sub_v3_v3v3",
"(",
"edir",
",",
"e",
"->",
"e",
"->",
"v1",
"->",
"co",
",",
"e",
"->",
"e",
"->",
"v2",
"->",
"co",
")",
";",
"plane_from_point_normal_v3",
"(",
"plane",
",",
"co",
",",
"edir",
")",
";",
"closest_to_plane_v3",
"(",
"va0",
",",
"plane",
",",
"va",
")",
";",
"closest_to_plane_v3",
"(",
"vb0",
",",
"plane",
",",
"vb",
")",
";",
"closest_to_plane_v3",
"(",
"vmid0",
",",
"plane",
",",
"pro",
"->",
"midco",
")",
";",
"if",
"(",
"make_unit_square_map",
"(",
"va0",
",",
"vmid0",
",",
"vb0",
",",
"m",
")",
")",
"{",
"if",
"(",
"!",
"invert_m4_m4",
"(",
"minv",
",",
"m",
")",
")",
"{",
"BLI_assert",
"(",
"!",
"\"",
"\"",
")",
";",
"return",
";",
"}",
"mul_v3_m4v3",
"(",
"p",
",",
"minv",
",",
"co",
")",
";",
"snap_to_superellipsoid",
"(",
"p",
",",
"pro",
"->",
"super_r",
",",
"midline",
")",
";",
"mul_v3_m4v3",
"(",
"snap",
",",
"m",
",",
"p",
")",
";",
"copy_v3_v3",
"(",
"co",
",",
"snap",
")",
";",
"}",
"else",
"{",
"closest_to_line_segment_v3",
"(",
"p",
",",
"co",
",",
"va0",
",",
"vb0",
")",
";",
"copy_v3_v3",
"(",
"co",
",",
"p",
")",
";",
"}",
"}"
] | Snap co to the closest point on the profile for vpipe projected onto the plane
containing co with normal in the direction of edge vpipe->ebev. | [
"Snap",
"co",
"to",
"the",
"closest",
"point",
"on",
"the",
"profile",
"for",
"vpipe",
"projected",
"onto",
"the",
"plane",
"containing",
"co",
"with",
"normal",
"in",
"the",
"direction",
"of",
"edge",
"vpipe",
"-",
">",
"ebev",
"."
] | [
"/* Transform co and project it onto superellipse */",
"/* shouldn't happen */",
"/* planar case: just snap to line va0--vb0 */"
] | [
{
"param": "vpipe",
"type": "BoundVert"
},
{
"param": "midline",
"type": "bool"
},
{
"param": "co",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "vpipe",
"type": "BoundVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "midline",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "co",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | pipe_adj_vmesh | VMesh | static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe)
{
int i, j, k, n, ns, ns2, ipipe1, ipipe2;
VMesh *vm;
bool even, midline;
vm = adj_vmesh(bp, bv);
/* Now snap all interior coordinates to be on the epipe profile */
n = bv->vmesh->count;
ns = bv->vmesh->seg;
ns2 = ns / 2;
even = (ns % 2) == 0;
ipipe1 = vpipe->index;
ipipe2 = vpipe->next->next->index;
for (i = 0; i < n; i++) {
for (j = 1; j <= ns2; j++) {
for (k = 0; k <= ns2; k++) {
if (!is_canon(vm, i, j, k)) {
continue;
}
midline = even && k == ns2 && ((i == 0 && j == ns2) || (i == ipipe1 || i == ipipe2));
snap_to_pipe_profile(vpipe, midline, mesh_vert(vm, i, j, k)->co);
}
}
}
return vm;
} | /* See pipe_test for conditions that make 'pipe'; vpipe is the return value from that.
* We want to make an ADJ mesh but then snap the vertices to the profile in a plane
* perpendicular to the pipes.
* A tricky case is for the 'square' profiles and an even nseg: we want certain vertices
* to snap to the midline on the pipe, not just to one plane or the other. */ | See pipe_test for conditions that make 'pipe'; vpipe is the return value from that.
We want to make an ADJ mesh but then snap the vertices to the profile in a plane
perpendicular to the pipes.
A tricky case is for the 'square' profiles and an even nseg: we want certain vertices
to snap to the midline on the pipe, not just to one plane or the other. | [
"See",
"pipe_test",
"for",
"conditions",
"that",
"make",
"'",
"pipe",
"'",
";",
"vpipe",
"is",
"the",
"return",
"value",
"from",
"that",
".",
"We",
"want",
"to",
"make",
"an",
"ADJ",
"mesh",
"but",
"then",
"snap",
"the",
"vertices",
"to",
"the",
"profile",
"in",
"a",
"plane",
"perpendicular",
"to",
"the",
"pipes",
".",
"A",
"tricky",
"case",
"is",
"for",
"the",
"'",
"square",
"'",
"profiles",
"and",
"an",
"even",
"nseg",
":",
"we",
"want",
"certain",
"vertices",
"to",
"snap",
"to",
"the",
"midline",
"on",
"the",
"pipe",
"not",
"just",
"to",
"one",
"plane",
"or",
"the",
"other",
"."
] | static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe)
{
int i, j, k, n, ns, ns2, ipipe1, ipipe2;
VMesh *vm;
bool even, midline;
vm = adj_vmesh(bp, bv);
n = bv->vmesh->count;
ns = bv->vmesh->seg;
ns2 = ns / 2;
even = (ns % 2) == 0;
ipipe1 = vpipe->index;
ipipe2 = vpipe->next->next->index;
for (i = 0; i < n; i++) {
for (j = 1; j <= ns2; j++) {
for (k = 0; k <= ns2; k++) {
if (!is_canon(vm, i, j, k)) {
continue;
}
midline = even && k == ns2 && ((i == 0 && j == ns2) || (i == ipipe1 || i == ipipe2));
snap_to_pipe_profile(vpipe, midline, mesh_vert(vm, i, j, k)->co);
}
}
}
return vm;
} | [
"static",
"VMesh",
"*",
"pipe_adj_vmesh",
"(",
"BevelParams",
"*",
"bp",
",",
"BevVert",
"*",
"bv",
",",
"BoundVert",
"*",
"vpipe",
")",
"{",
"int",
"i",
",",
"j",
",",
"k",
",",
"n",
",",
"ns",
",",
"ns2",
",",
"ipipe1",
",",
"ipipe2",
";",
"VMesh",
"*",
"vm",
";",
"bool",
"even",
",",
"midline",
";",
"vm",
"=",
"adj_vmesh",
"(",
"bp",
",",
"bv",
")",
";",
"n",
"=",
"bv",
"->",
"vmesh",
"->",
"count",
";",
"ns",
"=",
"bv",
"->",
"vmesh",
"->",
"seg",
";",
"ns2",
"=",
"ns",
"/",
"2",
";",
"even",
"=",
"(",
"ns",
"%",
"2",
")",
"==",
"0",
";",
"ipipe1",
"=",
"vpipe",
"->",
"index",
";",
"ipipe2",
"=",
"vpipe",
"->",
"next",
"->",
"next",
"->",
"index",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"for",
"(",
"j",
"=",
"1",
";",
"j",
"<=",
"ns2",
";",
"j",
"++",
")",
"{",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<=",
"ns2",
";",
"k",
"++",
")",
"{",
"if",
"(",
"!",
"is_canon",
"(",
"vm",
",",
"i",
",",
"j",
",",
"k",
")",
")",
"{",
"continue",
";",
"}",
"midline",
"=",
"even",
"&&",
"k",
"==",
"ns2",
"&&",
"(",
"(",
"i",
"==",
"0",
"&&",
"j",
"==",
"ns2",
")",
"||",
"(",
"i",
"==",
"ipipe1",
"||",
"i",
"==",
"ipipe2",
")",
")",
";",
"snap_to_pipe_profile",
"(",
"vpipe",
",",
"midline",
",",
"mesh_vert",
"(",
"vm",
",",
"i",
",",
"j",
",",
"k",
")",
"->",
"co",
")",
";",
"}",
"}",
"}",
"return",
"vm",
";",
"}"
] | See pipe_test for conditions that make 'pipe'; vpipe is the return value from that. | [
"See",
"pipe_test",
"for",
"conditions",
"that",
"make",
"'",
"pipe",
"'",
";",
"vpipe",
"is",
"the",
"return",
"value",
"from",
"that",
"."
] | [
"/* Now snap all interior coordinates to be on the epipe profile */"
] | [
{
"param": "bp",
"type": "BevelParams"
},
{
"param": "bv",
"type": "BevVert"
},
{
"param": "vpipe",
"type": "BoundVert"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bp",
"type": "BevelParams",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bv",
"type": "BevVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vpipe",
"type": "BoundVert",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
797e2ca864e674d30732f6f1e8ff98ecac74b2ed | DemonRem/blender | source/blender/bmesh/tools/bmesh_bevel.c | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | C | snap_face_dist_squared | float | static float snap_face_dist_squared(float *co, BMFace *f, BMEdge **r_snap_e, float *r_snap_co)
{
BMIter iter;
BMEdge *beste = NULL;
float d2, beste_d2;
BMEdge *e;
float closest[3];
beste_d2 = 1e20;
BM_ITER_ELEM (e, &iter, f, BM_EDGES_OF_FACE) {
closest_to_line_segment_v3(closest, co, e->v1->co, e->v2->co);
d2 = len_squared_v3v3(closest, co);
if (d2 < beste_d2) {
beste_d2 = d2;
beste = e;
copy_v3_v3(r_snap_co, closest);
}
}
*r_snap_e = beste;
return beste_d2;
} | /* Snap co to the closest edge of face f. Return the edge in *r_snap_e,
* the coordinates of snap point in r_ snap_co,
* and the distance squared to the snap point as function return */ | Snap co to the closest edge of face f. Return the edge in *r_snap_e,
the coordinates of snap point in r_ snap_co,
and the distance squared to the snap point as function return | [
"Snap",
"co",
"to",
"the",
"closest",
"edge",
"of",
"face",
"f",
".",
"Return",
"the",
"edge",
"in",
"*",
"r_snap_e",
"the",
"coordinates",
"of",
"snap",
"point",
"in",
"r_",
"snap_co",
"and",
"the",
"distance",
"squared",
"to",
"the",
"snap",
"point",
"as",
"function",
"return"
] | static float snap_face_dist_squared(float *co, BMFace *f, BMEdge **r_snap_e, float *r_snap_co)
{
BMIter iter;
BMEdge *beste = NULL;
float d2, beste_d2;
BMEdge *e;
float closest[3];
beste_d2 = 1e20;
BM_ITER_ELEM (e, &iter, f, BM_EDGES_OF_FACE) {
closest_to_line_segment_v3(closest, co, e->v1->co, e->v2->co);
d2 = len_squared_v3v3(closest, co);
if (d2 < beste_d2) {
beste_d2 = d2;
beste = e;
copy_v3_v3(r_snap_co, closest);
}
}
*r_snap_e = beste;
return beste_d2;
} | [
"static",
"float",
"snap_face_dist_squared",
"(",
"float",
"*",
"co",
",",
"BMFace",
"*",
"f",
",",
"BMEdge",
"*",
"*",
"r_snap_e",
",",
"float",
"*",
"r_snap_co",
")",
"{",
"BMIter",
"iter",
";",
"BMEdge",
"*",
"beste",
"=",
"NULL",
";",
"float",
"d2",
",",
"beste_d2",
";",
"BMEdge",
"*",
"e",
";",
"float",
"closest",
"[",
"3",
"]",
";",
"beste_d2",
"=",
"1e20",
";",
"BM_ITER_ELEM",
"(",
"e",
",",
"&",
"iter",
",",
"f",
",",
"BM_EDGES_OF_FACE",
")",
"",
"{",
"closest_to_line_segment_v3",
"(",
"closest",
",",
"co",
",",
"e",
"->",
"v1",
"->",
"co",
",",
"e",
"->",
"v2",
"->",
"co",
")",
";",
"d2",
"=",
"len_squared_v3v3",
"(",
"closest",
",",
"co",
")",
";",
"if",
"(",
"d2",
"<",
"beste_d2",
")",
"{",
"beste_d2",
"=",
"d2",
";",
"beste",
"=",
"e",
";",
"copy_v3_v3",
"(",
"r_snap_co",
",",
"closest",
")",
";",
"}",
"}",
"*",
"r_snap_e",
"=",
"beste",
";",
"return",
"beste_d2",
";",
"}"
] | Snap co to the closest edge of face f. Return the edge in *r_snap_e,
the coordinates of snap point in r_ snap_co,
and the distance squared to the snap point as function return | [
"Snap",
"co",
"to",
"the",
"closest",
"edge",
"of",
"face",
"f",
".",
"Return",
"the",
"edge",
"in",
"*",
"r_snap_e",
"the",
"coordinates",
"of",
"snap",
"point",
"in",
"r_",
"snap_co",
"and",
"the",
"distance",
"squared",
"to",
"the",
"snap",
"point",
"as",
"function",
"return"
] | [] | [
{
"param": "co",
"type": "float"
},
{
"param": "f",
"type": "BMFace"
},
{
"param": "r_snap_e",
"type": "BMEdge"
},
{
"param": "r_snap_co",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "co",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "f",
"type": "BMFace",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r_snap_e",
"type": "BMEdge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r_snap_co",
"type": "float",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
Subsets and Splits