Bug with recast generator + meshes with negative scale

Hey – quick note, if you try to use the recast generator on meshes which have negative scales (our artists use this a lot to generate mirrored variants of meshes/rooms), the generator doesn’t work right. Fixing it is pretty simple, something like this in Voxelize.CollectMeshes:

`        Vector3 scale = filter.transform.lossyScale;
        float scaleParity = 1;
	if (scale.x < 0) scaleParity *= -1;
	if (scale.y < 0) scaleParity *= -1;
	if (scale.z < 0) scaleParity *= -1;
		
	if (scaleParity < 0)
	{
		// Swap two indices to change winding order.
		for (int q = 0; q < ts.Length; q += 3) {
			int tmp = ts[q + 0];
			ts[q + 0] = ts[q + 1];
		        ts[q + 1] = tmp;
		}
	}`

Hi

Thanks for the bug report and fix. Added to todo list.

Bump! This is still an issue as of today’s 3.8 release.

1 Like

Hi

Thanks for bumping the thread. I had forgotten about this.
I have added the fix to my dev version. Though I modified it a bit to make it slightly more stable and generic (used the full matrix instead of the lossy scale).

I will be uploading a new version pretty soon.

1 Like

Just uploaded 3.8.1 which fixes this bug.

1 Like