From e7647f5ca777ae4f9a2d63821e13f29a0543a8b4 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 12 Aug 2022 20:12:35 -0400 Subject: [PATCH] fix decompile --- bsputil/decompile.cpp | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/bsputil/decompile.cpp b/bsputil/decompile.cpp index 0a132211..8d815a4c 100644 --- a/bsputil/decompile.cpp +++ b/bsputil/decompile.cpp @@ -292,11 +292,27 @@ public: } decomp_brush_face_t(std::optional &&windingToTakeOwnership, const mface_t *face) - : winding(windingToTakeOwnership), original_face(face) + : winding(std::move(windingToTakeOwnership)), original_face(face) { buildInwardFacingEdgePlanes(); } + // FIXME + decomp_brush_face_t(const decomp_brush_face_t &face) : + winding(face.winding ? decltype(winding)(face.winding->clone()) : std::nullopt), + original_face(face.original_face), + inwardFacingEdgePlanes(face.inwardFacingEdgePlanes) + { + } + + decomp_brush_face_t &operator=(const decomp_brush_face_t ©) + { + winding = copy.winding ? decltype(winding)(copy.winding->clone()) : std::nullopt; + original_face = copy.original_face; + inwardFacingEdgePlanes = copy.inwardFacingEdgePlanes; + return *this; + } + public: /** * Returns the { front, back } after the clip. @@ -376,6 +392,22 @@ struct decomp_brush_side_t { } + // FIXME + decomp_brush_side_t(const decomp_brush_side_t ©) : + faces(copy.faces), + plane(copy.plane), + winding(copy.winding.clone()) + { + } + + decomp_brush_side_t &operator=(const decomp_brush_side_t ©) + { + faces = copy.faces; + plane = copy.plane; + winding = copy.winding.clone(); + return *this; + } + /** * Construct a new side with no faces on it, with the given outward-facing plane */ @@ -617,7 +649,7 @@ static decomp_brush_t BuildInitialBrush_Q2( continue; auto side = decomp_brush_side_t(bsp, task, plane); - side.winding = *winding; + side.winding = std::move(*winding); sides.emplace_back(side); } @@ -801,11 +833,11 @@ static compiled_brush_t DecompileLeafTask( } } - for (const decomp_brush_t &finalBrush : finalBrushes) { - for (const auto &finalSide : finalBrush.sides) { + for (decomp_brush_t &finalBrush : finalBrushes) { + for (auto &finalSide : finalBrush.sides) { compiled_brush_side_t &side = brush.sides.emplace_back(); side.plane = finalSide.plane; - side.winding = finalSide.winding; + side.winding = std::move(finalSide.winding); side.source = finalSide.plane.source; if (brush.contents.native == 0) {