Proposal / feedback on modifiers

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.

The build system is using cmake, which will in turn generate a visual studio solution for you, you shouldn’t make any changes to the visual studio solution, since next time cmake runs (which is pretty much every time you build) it’ll blow away any changes and write a new set of solution files.

if you look at the folder structure and contents of it’s CMakelists.txt in source\blender\blenfont it should give you a pretty good idea on how to add a small library to blender.

@LazyDodo, thanks. Yes I’ve looked a lot at these CMakelists files, but I was not able to understand them really.

Adding a new file in an existing project is ok, but for a new lib, I’ve not found… any more concrete hints about it?

https://cmake.org/cmake-tutorial/ this might help?

@LazyDodo, thanks. I’ve finally found it.

What I’ve missed before was the CMakeLists.txt in “xxx\blender\source\blender” which contains lines like:

add_subdirectory(mylib)