Hi,
In the continuation of previous post, here is some short videos (2-4mn each) of two modifiers I’ve coded in order to learn how all this is working:
- A random modifier:
Randomize a mesh in various ways: the video
- A fan modifier:
Kind of mix between spin/screw/array
The principles in this video and some other examples in this one.
I hope this site is appropriate proposing that…
I have also two technical questions: about adding a new C/C++ project in the solution and about inverting faces.
-
Adding a new C/C++ library:
The question is simple: how to do that? I’ve tried, simply adding a project in Visual Studio, but visibly, this is not the good way… I’ve found no information about that.
Can someone lead me to a documentation or give me the principles to do it? -
Inverting faces
For that I’ve simply coded the following:
static void swap_mloops(MLoop *l1, MLoop *l2)
{
int e1 = l1->e;
int v1 = l1->v;
l1->e = l2->e;
l1->v = l2->v;
l2->e = e1;
l2->v = v1;
}
void DM_invert_faces(DerivedMesh *derivedMesh, int start_poly_index, int poly_count)
{
MPoly *poly = CDDM_get_polys(derivedMesh);
MLoop *loop = CDDM_get_loops(derivedMesh);
poly = poly + start_poly_index;
for (int p = 0; p < poly_count;p++, poly++)
{
MLoop *loopstart = loop + poly->loopstart;
for (int l1 = 0, l2 = poly->totloop - 1; l1 < l2;l1++, l2--)
{
swap_mloops(loopstart + l1, loopstart + l2);
}
}
}
But I really don’t know if it is the good approach (even as it seems to work), as I’ve seen other code parts in Blender which are much more complicated for doing that. So… where am I wrong in this code?
Thanks by advance.