diff --git a/nel/tools/build_gamedata/processes/rbank/2_build.py b/nel/tools/build_gamedata/processes/rbank/2_build.py index b38aea94b..b4c0ca674 100755 --- a/nel/tools/build_gamedata/processes/rbank/2_build.py +++ b/nel/tools/build_gamedata/processes/rbank/2_build.py @@ -55,6 +55,7 @@ printLog(log, "") # Build rbank bbox printLog(log, ">>> Build rbank bbox <<<") tempBbox = ExportBuildDirectory + "/" + RbankBboxBuildDirectory + "/temp.bbox" +rebuiltBbox = False if BuildIgBoxes == "": toolLogFail(log, BuildIgBoxesTool, ToolSuffix) else: @@ -70,6 +71,7 @@ else: else: printLog(log, "DETECT SKIP Shape->Bbox") if needUpdateIg or needUpdateShape: + rebuiltBbox = True printLog(log, "DETECT DECIDE UPDATE") cf = open("build_ig_boxes.cfg", "w") cf.write("\n") @@ -204,23 +206,35 @@ elif ExecTimeout == "": toolLogFail(log, ExecTimeoutTool, ToolSuffix) else: zonefiles = findFiles(log, ExportBuildDirectory + "/" + ZoneWeldBuildDirectory, "", ".zonew") + zonesToBuild = [] for zonefile in zonefiles: zone = os.path.basename(zonefile)[0:-len(".zonew")] lr1 = ExportBuildDirectory + "/" + RbankSmoothBuildDirectory + "/" + zone + ".lr" nearzones = subprocess.Popen([ GetNeighbors, zone ], stdout = subprocess.PIPE).communicate()[0].strip().split(" ") printLog(log, "ZONE " + zone + ": " + str(nearzones)) - zone_to_build = 0 + zoneToBuild = 0 for nearzone in nearzones: sourcePath = ExportBuildDirectory + "/" + ZoneWeldBuildDirectory + "/" + nearzone + ".zonew" if (os.path.isfile(sourcePath)): - if (needUpdate(log, sourcePath, lr1)): - zone_to_build = 1 + if (rebuiltBbox or needUpdate(log, sourcePath, lr1)): + zoneToBuild = 1 + zonesToBuild.append(os.path.basename(zonefile)) sourcePath = ExportBuildDirectory + "/" + ZoneWeldBuildDirectory + "/" + zone + ".zonew" - if zone_to_build: + if zoneToBuild: printLog(log, sourcePath + " -> " + lr1) - subprocess.call([ ExecTimeout, str(RbankBuildTesselTimeout), BuildRbank, "-c", "-P", "-g", os.path.basename(zonefile) ]) + # subprocess.call([ ExecTimeout, str(RbankBuildTesselTimeout), BuildRbank, "-c", "-P", "-g", os.path.basename(zonefile) ]) else: printLog(log, "SKIP " + lr1) + while len(zonesToBuild) > 0: + processCommand = [ ExecTimeout, str(RbankBuildTesselTimeout), BuildRbank, "-c", "-P", "-g" ] + processCommand.extend(zonesToBuild[:min(len(zonesToBuild), 64)]) + if len(zonesToBuild) > 64: + zonesToBuild = zonesToBuild[64:] + else: + zonesToBuild = [] + print processCommand + print len(processCommand) + subprocess.call(processCommand) printLog(log, "") printLog(log, ">>> Detect modifications to rebuild lr <<<") @@ -245,7 +259,7 @@ if needUpdateBboxRbank: else: printLog(log, "DETECT SKIP Lr->Rbank") -if needUpdateCmbLr or needUpdateCmbRbank or needUpdateLrRbank or needUpdateBboxRbank: +if rebuiltBbox or needUpdateCmbLr or needUpdateCmbRbank or needUpdateLrRbank or needUpdateBboxRbank: printLog(log, "DETECT DECIDE UPDATE") printLog(log, ">>> Build rbank process global <<<") # This generates temp lr files. TODO: Check if the LR changed? if BuildRbank == "": diff --git a/nel/tools/pacs/build_rbank/prim_checker.cpp b/nel/tools/pacs/build_rbank/prim_checker.cpp index e4c2b0b91..effd07bd7 100644 --- a/nel/tools/pacs/build_rbank/prim_checker.cpp +++ b/nel/tools/pacs/build_rbank/prim_checker.cpp @@ -336,13 +336,19 @@ void CPrimChecker::render(CPrimZone *zone, uint8 bits) */ void CPrimChecker::render(const CPolygon &poly, uint16 value) { + static const sint centerOffset = 20480; // zones are max 40960 + CPolygon polyOffset = poly; + for (ptrdiff_t i = 0; i < (ptrdiff_t)polyOffset.Vertices.size(); ++i) + // center to computeBorders range (-32k to 32k) + polyOffset.Vertices[i] += CVector(-centerOffset, centerOffset, 0); + list convex; // divide poly in convex polys - if (!poly.toConvexPolygons(convex, CMatrix::Identity)) + if (!polyOffset.toConvexPolygons(convex, CMatrix::Identity)) { convex.clear(); - CPolygon reverse = poly; + CPolygon reverse = polyOffset; std::reverse(reverse.Vertices.begin(), reverse.Vertices.end()); if (!reverse.toConvexPolygons(convex, CMatrix::Identity)) return; @@ -357,6 +363,7 @@ void CPrimChecker::render(const CPolygon &poly, uint16 value) sint ymin; convex2d.computeBorders(rasterized, ymin); + ymin -= centerOffset; // uncenter sint dy; for (dy=0; dy<(sint)rasterized.size(); ++dy) @@ -365,19 +372,19 @@ void CPrimChecker::render(const CPolygon &poly, uint16 value) for (x=rasterized[dy].first; x<=rasterized[dy].second; ++x) { - uint8 prevBits = _Grid.get((uint)x, (uint)(ymin+dy)); + uint8 prevBits = _Grid.get((uint)x + centerOffset, (uint)(ymin + dy)); // only set if there was not a water shape there or if previous was lower if ((prevBits & Water) != 0) { - uint16 prevWS = _Grid.index((uint)x, (uint)(ymin+dy)); + uint16 prevWS = _Grid.index((uint)x + centerOffset, (uint)(ymin + dy)); if (_WaterHeight[value] < _WaterHeight[prevWS]) continue; } - _Grid.index((uint)x, (uint)(ymin+dy), value); - _Grid.set((uint)x, (uint)(ymin+dy), Water); + _Grid.index((uint)x + centerOffset, (uint)(ymin + dy), value); + _Grid.set((uint)x + centerOffset, (uint)(ymin + dy), Water); } } } @@ -389,13 +396,19 @@ void CPrimChecker::render(const CPolygon &poly, uint16 value) */ void CPrimChecker::renderBits(const CPolygon &poly, uint8 bits) { + static const sint centerOffset = 20480; // zones are max 40960 + CPolygon polyOffset = poly; + for (ptrdiff_t i = 0; i < (ptrdiff_t)polyOffset.Vertices.size(); ++i) + // center to computeBorders range (-32k to 32k) + polyOffset.Vertices[i] += CVector(-centerOffset, centerOffset, 0); + list convex; // divide poly in convex polys - if (!poly.toConvexPolygons(convex, CMatrix::Identity)) + if (!polyOffset.toConvexPolygons(convex, CMatrix::Identity)) { convex.clear(); - CPolygon reverse = poly; + CPolygon reverse = polyOffset; std::reverse(reverse.Vertices.begin(), reverse.Vertices.end()); if (!reverse.toConvexPolygons(convex, CMatrix::Identity)) return; @@ -410,6 +423,7 @@ void CPrimChecker::renderBits(const CPolygon &poly, uint8 bits) sint ymin; convex2d.computeBorders(rasterized, ymin); + ymin -= centerOffset; // uncenter sint dy; for (dy=0; dy<(sint)rasterized.size(); ++dy) @@ -418,7 +432,7 @@ void CPrimChecker::renderBits(const CPolygon &poly, uint8 bits) for (x=rasterized[dy].first; x<=rasterized[dy].second; ++x) { - _Grid.set((uint)x, (uint)(ymin+dy), bits); + _Grid.set((uint)x + centerOffset, (uint)(ymin + dy), bits); } } }