[Bf-blender-cvs] [a5ba97e58c1] blender2.8: mesh_navmesh.c removal

Dalai Felinto noreply at git.blender.org
Wed Jun 27 11:40:36 CEST 2018


Commit: a5ba97e58c1f67c7ca6709a4377d015ed51961af
Author: Dalai Felinto
Date:   Wed Jun 27 11:40:16 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBa5ba97e58c1f67c7ca6709a4377d015ed51961af

mesh_navmesh.c removal

This was added back by mistake in a wrong merge
f1bc8991461fcda33eb34820bd3aa153f6122c5b.

===================================================================

D	source/blender/editors/mesh/mesh_navmesh.c

===================================================================

diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c
deleted file mode 100644
index 5cfb269cbc3..00000000000
--- a/source/blender/editors/mesh/mesh_navmesh.c
+++ /dev/null
@@ -1,732 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2011 by Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Benoit Bolsee,
- *                 Nick Samarin
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/mesh/mesh_navmesh.c
- *  \ingroup edmesh
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_scene_types.h"
-#include "DNA_object_types.h"
-#include "DNA_mesh_types.h"
-
-#include "BLI_listbase.h"
-#include "BLI_math_vector.h"
-#include "BLI_linklist.h"
-
-#include "BKE_library.h"
-#include "BKE_depsgraph.h"
-#include "BKE_context.h"
-#include "BKE_mesh.h"
-#include "BKE_scene.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_report.h"
-#include "BKE_editmesh.h"
-
-#include "ED_object.h"
-#include "ED_mesh.h"
-#include "ED_screen.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "recast-capi.h"
-
-#include "mesh_intern.h"  /* own include */
-
-
-static void createVertsTrisData(bContext *C, LinkNode *obs,
-                                int *nverts_r, float **verts_r, int *ntris_r, int **tris_r, unsigned int *r_lay)
-{
-	MVert *mvert;
-	int nfaces = 0, *tri, i, curnverts, basenverts, curnfaces;
-	MFace *mface;
-	float co[3], wco[3];
-	Object *ob;
-	LinkNode *oblink, *dmlink;
-	DerivedMesh *dm;
-	Scene *scene = CTX_data_scene(C);
-	LinkNodePair dms_pair = {NULL, NULL};
-
-	int nverts, ntris, *tris;
-	float *verts;
-
-	nverts = 0;
-	ntris = 0;
-
-	/* calculate number of verts and tris */
-	for (oblink = obs; oblink; oblink = oblink->next) {
-		ob = (Object *) oblink->link;
-		dm = mesh_create_derived_no_virtual(scene, ob, NULL, CD_MASK_MESH);
-		DM_ensure_tessface(dm);
-		BLI_linklist_append(&dms_pair, dm);
-
-		nverts += dm->getNumVerts(dm);
-		nfaces = dm->getNumTessFaces(dm);
-		ntris += nfaces;
-
-		/* resolve quad faces */
-		mface = dm->getTessFaceArray(dm);
-		for (i = 0; i < nfaces; i++) {
-			MFace *mf = &mface[i];
-			if (mf->v4)
-				ntris += 1;
-		}
-
-		*r_lay |= ob->lay;
-	}
-	LinkNode *dms = dms_pair.list;
-
-	/* create data */
-	verts = MEM_mallocN(sizeof(float) * 3 * nverts, "createVertsTrisData verts");
-	tris = MEM_mallocN(sizeof(int) * 3 * ntris, "createVertsTrisData faces");
-
-	basenverts = 0;
-	tri = tris;
-	for (oblink = obs, dmlink = dms; oblink && dmlink;
-	     oblink = oblink->next, dmlink = dmlink->next)
-	{
-		ob = (Object *) oblink->link;
-		dm = (DerivedMesh *) dmlink->link;
-
-		curnverts = dm->getNumVerts(dm);
-		mvert = dm->getVertArray(dm);
-
-		/* copy verts */
-		for (i = 0; i < curnverts; i++) {
-			MVert *v = &mvert[i];
-
-			copy_v3_v3(co, v->co);
-			mul_v3_m4v3(wco, ob->obmat, co);
-
-			verts[3 * (basenverts + i) + 0] = wco[0];
-			verts[3 * (basenverts + i) + 1] = wco[2];
-			verts[3 * (basenverts + i) + 2] = wco[1];
-		}
-
-		/* create tris */
-		curnfaces = dm->getNumTessFaces(dm);
-		mface = dm->getTessFaceArray(dm);
-
-		for (i = 0; i < curnfaces; i++) {
-			MFace *mf = &mface[i];
-
-			tri[0] = basenverts + mf->v1;
-			tri[1] = basenverts + mf->v3;
-			tri[2] = basenverts + mf->v2;
-			tri += 3;
-
-			if (mf->v4) {
-				tri[0] = basenverts + mf->v1;
-				tri[1] = basenverts + mf->v4;
-				tri[2] = basenverts + mf->v3;
-				tri += 3;
-			}
-		}
-
-		basenverts += curnverts;
-	}
-
-	/* release derived mesh */
-	for (dmlink = dms; dmlink; dmlink = dmlink->next) {
-		dm = (DerivedMesh *) dmlink->link;
-		dm->release(dm);
-	}
-
-	BLI_linklist_free(dms, NULL);
-
-	*nverts_r = nverts;
-	*verts_r = verts;
-	*ntris_r = ntris;
-	*tris_r = tris;
-}
-
-static bool buildNavMesh(const RecastData *recastParams, int nverts, float *verts, int ntris, int *tris,
-                         struct recast_polyMesh **pmesh, struct recast_polyMeshDetail **dmesh,
-                         ReportList *reports)
-{
-	float bmin[3], bmax[3];
-	struct recast_heightfield *solid;
-	unsigned char *triflags;
-	struct recast_compactHeightfield *chf;
-	struct recast_contourSet *cset;
-	int width, height, walkableHeight, walkableClimb, walkableRadius;
-	int minRegionArea, mergeRegionArea, maxEdgeLen;
-	float detailSampleDist, detailSampleMaxError;
-
-	recast_calcBounds(verts, nverts, bmin, bmax);
-
-	/* ** Step 1. Initialize build config ** */
-	walkableHeight = (int)ceilf(recastParams->agentheight / recastParams->cellheight);
-	walkableClimb = (int)floorf(recastParams->agentmaxclimb / recastParams->cellheight);
-	walkableRadius = (int)ceilf(recastParams->agentradius / recastParams->cellsize);
-	minRegionArea = (int)(recastParams->regionminsize * recastParams->regionminsize);
-	mergeRegionArea = (int)(recastParams->regionmergesize * recastParams->regionmergesize);
-	maxEdgeLen = (int)(recastParams->edgemaxlen / recastParams->cellsize);
-	detailSampleDist = recastParams->detailsampledist < 0.9f ? 0 :
-	                   recastParams->cellsize * recastParams->detailsampledist;
-	detailSampleMaxError = recastParams->cellheight * recastParams->detailsamplemaxerror;
-
-	/* Set the area where the navigation will be build. */
-	recast_calcGridSize(bmin, bmax, recastParams->cellsize, &width, &height);
-
-	/* zero dimensions cause zero alloc later on [#33758] */
-	if (width <= 0 || height <= 0) {
-		BKE_report(reports, RPT_ERROR, "Object has a width or height of zero");
-		return false;
-	}
-
-	/* ** Step 2: Rasterize input polygon soup ** */
-	/* Allocate voxel heightfield where we rasterize our input data to */
-	solid = recast_newHeightfield();
-
-	if (!recast_createHeightfield(solid, width, height, bmin, bmax, recastParams->cellsize, recastParams->cellheight)) {
-		recast_destroyHeightfield(solid);
-		BKE_report(reports, RPT_ERROR, "Failed to create height field");
-		return false;
-	}
-
-	/* Allocate array that can hold triangle flags */
-	triflags = MEM_callocN(sizeof(unsigned char) * ntris, "buildNavMesh triflags");
-
-	/* Find triangles which are walkable based on their slope and rasterize them */
-	recast_markWalkableTriangles(RAD2DEGF(recastParams->agentmaxslope), verts, nverts, tris, ntris, triflags);
-	recast_rasterizeTriangles(verts, nverts, tris, triflags, ntris, solid, 1);
-	MEM_freeN(triflags);
-
-	/* ** Step 3: Filter walkables surfaces ** */
-	recast_filterLowHangingWalkableObstacles(walkableClimb, solid);
-	recast_filterLedgeSpans(walkableHeight, walkableClimb, solid);
-	recast_filterWalkableLowHeightSpans(walkableHeight, solid);
-
-	/* ** Step 4: Partition walkable surface to simple regions ** */
-
-	chf = recast_newCompactHeightfield();
-	if (!recast_buildCompactHeightfield(walkableHeight, walkableClimb, solid, chf)) {
-		recast_destroyHeightfield(solid);
-		recast_destroyCompactHeightfield(chf);
-
-		BKE_report(reports, RPT_ERROR, "Failed to create compact height field");
-		return false;
-	}
-
-	recast_destroyHeightfield(solid);
-	solid = NULL;
-
-	if (!recast_erodeWalkableArea(walkableRadius, chf)) {
-		recast_destroyCompactHeightfield(chf);
-
-		BKE_report(reports, RPT_ERROR, "Failed to erode walkable area");
-		return false;
-	}
-
-	if (recastParams->partitioning == RC_PARTITION_WATERSHED) {
-		/* Prepare for region partitioning, by calculating distance field along the walkable surface */
-		if (!recast_buildDistanceField(chf)) {
-			recast_destroyCompactHeightfield(chf);
-
-			BKE_report(reports, RPT_ERROR, "Failed to build distance field");
-			return false;
-		}
-
-		/* Partition the walkable surface into simple regions without holes */
-		if (!recast_buildRegions(chf, 0, minRegionArea, mergeRegionArea)) {
-			recast_destroyCompactHeightfield(chf);
-
-			BKE_report(reports, RPT_ERROR, "Failed to build watershed regions");
-			return false;
-		}
-	}
-	else if (recastParams->partitioning == RC_PARTITION_MONOTONE) {
-		/* Partition the walkable surface into simple regions without holes */
-		/* Monotone partitioning does not need distancefield. */
-		if (!recast_buildRegionsMonotone(chf, 0, minRegionArea, mergeRegionArea)) {
-			recast_destroyCompactHeightfield(chf);
-
-			BKE_report(reports, RPT_ERROR, "Failed to build monotone regions");
-			return false;
-		}
-	}
-	else { /* RC_PARTITION_LAYERS */
-		/* Partition the walkable surface into simple regions without holes */
-		if (!recast_buildLayerRegions(chf, 0, minRegionArea)) {
-			recast_destroyCompactHeightfield(chf);
-
-			BKE_report(reports, RPT_ERROR, "Failed to build layer regions");
-			return false;
-		}
-	}
-
-	/* ** Step 5: Trace and simplify region contours ** */
-	/* Create contours */
-	cset = recast_newContourSet();
-
-	if (!recast_buildContours(chf, recastParams->edgemaxerror, maxEdgeLen, cset, RECAST_CONTOUR_TESS_WALL_EDGES)) {
-		recast_destroyCompactHeightfield(chf);
-		recast_destroyContourSet(cset);
-
-		BKE_report(reports, RPT_ERROR, "Failed to build contours");
-		return false;
-	}
-
-	/* ** Step 6: Build polygons mesh from contours ** */
-	*pmesh = recast_newPolyMesh();
-	if (!recast_buildPolyMesh(cset, recastParams->vertsperpoly, *pmesh)) {
-		recast_destroyCompactHeightfield(chf);
-		recast_destroyContourSet(cset);
-		recast_destroyPolyMesh(*pmesh);
-
-		BKE_report(reports, RPT_ERROR, "Failed to build poly mesh");
-		return false;
-	}
-
-
-	/* ** Step 7: Create detail mesh which allows to access approximate height on each polygon ** */
-
-	*dmes

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list