From 49f3570b8a72dccc6749e316167aa2f7b39ed010 Mon Sep 17 00:00:00 2001 From: Scott Santucci Date: Sat, 28 Oct 2023 22:25:34 -0400 Subject: [PATCH 1/2] Add support for line and triangle-fan mesh types to ddl --- ddl/Definitions.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ddl/Definitions.hs b/ddl/Definitions.hs index 4c3b026..eb676e6 100644 --- a/ddl/Definitions.hs +++ b/ddl/Definitions.hs @@ -448,7 +448,11 @@ mesh = do data_ "MeshPrimitive" $ do enum_ "P_Points" + enum_ "P_LineStrip" + enum_ "P_LineLoop" + enum_ "P_Lines" enum_ "P_TriangleStrip" + enum_ "P_TriangleFan" enum_ "P_Triangles" const_ "P_TriangleStripI" [Array Int32] const_ "P_TrianglesI" [Array Int32] From aa8a63f115b46fcce859c3c6400721ca0a1ac309 Mon Sep 17 00:00:00 2001 From: Scott Santucci Date: Sat, 28 Oct 2023 22:30:04 -0400 Subject: [PATCH 2/2] Add support for line and triangle-fan mesh types: generated code --- ddl/out/cpp/LambdaCube.Mesh.cpp | 26 ++++++++++++++++++- ddl/out/cpp/LambdaCube.Mesh.hpp | 6 ++++- ddl/out/cpp/LambdaCube.Mesh2.hpp | 6 ++++- ddl/out/csharp/LambdaCube.Mesh.cs | 22 +++++++++++++++- ddl/out/haskell/LambdaCube/Mesh.hs | 14 +++++++++- ddl/out/java/LambdaCube/Mesh/JSON.java | 18 ++++++++++++- .../java/LambdaCube/Mesh/MeshPrimitive.java | 6 ++++- ddl/out/purescript/LambdaCube/Mesh.purs | 14 +++++++++- ddl/out/swift/LambdaCube.Mesh.swift | 14 +++++++++- .../src-generated/LambdaCube/Mesh.hs | 14 +++++++++- 10 files changed, 130 insertions(+), 10 deletions(-) diff --git a/ddl/out/cpp/LambdaCube.Mesh.cpp b/ddl/out/cpp/LambdaCube.Mesh.cpp index ae47aa3..64455ed 100644 --- a/ddl/out/cpp/LambdaCube.Mesh.cpp +++ b/ddl/out/cpp/LambdaCube.Mesh.cpp @@ -1,5 +1,5 @@ // generated file, do not modify! -// 2016-11-11T11:17:03.517567000000Z +// 2023-10-27T02:34:24.280572454Z #include "LambdaCube.Mesh.hpp" template<> json toJSON>(std::shared_ptr &v) { @@ -141,9 +141,21 @@ template<> json toJSON>(std::shared_ptr std::shared_ptr fromJSON object [ "tag" .= ("P_Points" :: Text)] + P_LineStrip -> object [ "tag" .= ("P_LineStrip" :: Text)] + P_LineLoop -> object [ "tag" .= ("P_LineLoop" :: Text)] + P_Lines -> object [ "tag" .= ("P_Lines" :: Text)] P_TriangleStrip -> object [ "tag" .= ("P_TriangleStrip" :: Text)] + P_TriangleFan -> object [ "tag" .= ("P_TriangleFan" :: Text)] P_Triangles -> object [ "tag" .= ("P_Triangles" :: Text)] P_TriangleStripI arg0 -> object [ "tag" .= ("P_TriangleStripI" :: Text), "arg0" .= arg0] P_TrianglesI arg0 -> object [ "tag" .= ("P_TrianglesI" :: Text), "arg0" .= arg0] @@ -85,7 +93,11 @@ instance FromJSON MeshPrimitive where tag <- obj .: "tag" case tag :: Text of "P_Points" -> pure P_Points + "P_LineStrip" -> pure P_LineStrip + "P_LineLoop" -> pure P_LineLoop + "P_Lines" -> pure P_Lines "P_TriangleStrip" -> pure P_TriangleStrip + "P_TriangleFan" -> pure P_TriangleFan "P_Triangles" -> pure P_Triangles "P_TriangleStripI" -> P_TriangleStripI <$> obj .: "arg0" "P_TrianglesI" -> P_TrianglesI <$> obj .: "arg0" diff --git a/ddl/out/java/LambdaCube/Mesh/JSON.java b/ddl/out/java/LambdaCube/Mesh/JSON.java index a0c356e..b14e6e0 100644 --- a/ddl/out/java/LambdaCube/Mesh/JSON.java +++ b/ddl/out/java/LambdaCube/Mesh/JSON.java @@ -1,5 +1,5 @@ // generated file, do not modify! -// 2016-11-11T11:17:03.517567000000Z +// 2023-10-27T02:34:24.280572454Z package LambdaCube.Mesh; @@ -234,7 +234,11 @@ public static Object fromJSON(Type type, Object rawObj) throws JSONException, Ex MeshPrimitive.Tag tagType; switch (tag) { case "P_Points": tagType = MeshPrimitive.Tag.P_Points; break; + case "P_LineStrip": tagType = MeshPrimitive.Tag.P_LineStrip; break; + case "P_LineLoop": tagType = MeshPrimitive.Tag.P_LineLoop; break; + case "P_Lines": tagType = MeshPrimitive.Tag.P_Lines; break; case "P_TriangleStrip": tagType = MeshPrimitive.Tag.P_TriangleStrip; break; + case "P_TriangleFan": tagType = MeshPrimitive.Tag.P_TriangleFan; break; case "P_Triangles": tagType = MeshPrimitive.Tag.P_Triangles; break; case "P_TriangleStripI": { MeshPrimitive.P_TriangleStripI_ tv = new MeshPrimitive().new P_TriangleStripI_(); @@ -348,9 +352,21 @@ public static Object toJSON(Type type, Object rawObj) throws JSONException, Exce case P_Points: obj.put("tag", "P_Points"); break; + case P_LineStrip: + obj.put("tag", "P_LineStrip"); + break; + case P_LineLoop: + obj.put("tag", "P_LineLoop"); + break; + case P_Lines: + obj.put("tag", "P_Lines"); + break; case P_TriangleStrip: obj.put("tag", "P_TriangleStrip"); break; + case P_TriangleFan: + obj.put("tag", "P_TriangleFan"); + break; case P_Triangles: obj.put("tag", "P_Triangles"); break; diff --git a/ddl/out/java/LambdaCube/Mesh/MeshPrimitive.java b/ddl/out/java/LambdaCube/Mesh/MeshPrimitive.java index 0838178..f857642 100644 --- a/ddl/out/java/LambdaCube/Mesh/MeshPrimitive.java +++ b/ddl/out/java/LambdaCube/Mesh/MeshPrimitive.java @@ -1,5 +1,5 @@ // generated file, do not modify! -// 2016-11-11T11:17:03.517567000000Z +// 2023-10-27T02:34:24.280572454Z package LambdaCube.Mesh; @@ -11,7 +11,11 @@ public class MeshPrimitive { public enum Tag { P_Points, + P_LineStrip, + P_LineLoop, + P_Lines, P_TriangleStrip, + P_TriangleFan, P_Triangles, P_TriangleStripI, P_TrianglesI diff --git a/ddl/out/purescript/LambdaCube/Mesh.purs b/ddl/out/purescript/LambdaCube/Mesh.purs index b91c0f6..2b63606 100644 --- a/ddl/out/purescript/LambdaCube/Mesh.purs +++ b/ddl/out/purescript/LambdaCube/Mesh.purs @@ -1,5 +1,5 @@ -- generated file, do not modify! --- 2016-11-15T20:33:23.430512000000Z +-- 2023-10-27T02:34:24.280572454Z module LambdaCube.Mesh where import Prelude @@ -32,7 +32,11 @@ data MeshAttribute data MeshPrimitive = P_Points + | P_LineStrip + | P_LineLoop + | P_Lines | P_TriangleStrip + | P_TriangleFan | P_Triangles | P_TriangleStripI (Array Int32) | P_TrianglesI (Array Int32) @@ -76,7 +80,11 @@ instance decodeJsonMeshAttribute :: DecodeJson MeshAttribute where instance encodeJsonMeshPrimitive :: EncodeJson MeshPrimitive where encodeJson v = case v of P_Points -> "tag" := "P_Points" ~> jsonEmptyObject + P_LineStrip -> "tag" := "P_LineStrip" ~> jsonEmptyObject + P_LineLoop -> "tag" := "P_LineLoop" ~> jsonEmptyObject + P_Lines -> "tag" := "P_Lines" ~> jsonEmptyObject P_TriangleStrip -> "tag" := "P_TriangleStrip" ~> jsonEmptyObject + P_TriangleFan -> "tag" := "P_TriangleFan" ~> jsonEmptyObject P_Triangles -> "tag" := "P_Triangles" ~> jsonEmptyObject P_TriangleStripI arg0 -> "tag" := "P_TriangleStripI" ~> "arg0" := arg0 ~> jsonEmptyObject P_TrianglesI arg0 -> "tag" := "P_TrianglesI" ~> "arg0" := arg0 ~> jsonEmptyObject @@ -87,7 +95,11 @@ instance decodeJsonMeshPrimitive :: DecodeJson MeshPrimitive where tag <- obj .? "tag" case tag of "P_Points" -> pure P_Points + "P_LineStrip" -> pure P_LineStrip + "P_LineLoop" -> pure P_LineLoop + "P_Lines" -> pure P_Lines "P_TriangleStrip" -> pure P_TriangleStrip + "P_TriangleFan" -> pure P_TriangleFan "P_Triangles" -> pure P_Triangles "P_TriangleStripI" -> P_TriangleStripI <$> obj .? "arg0" "P_TrianglesI" -> P_TrianglesI <$> obj .? "arg0" diff --git a/ddl/out/swift/LambdaCube.Mesh.swift b/ddl/out/swift/LambdaCube.Mesh.swift index 8df6c2a..2d9bb58 100644 --- a/ddl/out/swift/LambdaCube.Mesh.swift +++ b/ddl/out/swift/LambdaCube.Mesh.swift @@ -1,5 +1,5 @@ // generated file, do not modify! -// 2016-11-11T11:17:03.517567000000Z +// 2023-10-27T02:34:24.280572454Z enum MeshAttribute { case A_Float(Array) @@ -15,7 +15,11 @@ enum MeshAttribute { enum MeshPrimitive { case P_Points + case P_LineStrip + case P_LineLoop + case P_Lines case P_TriangleStrip + case P_TriangleFan case P_Triangles case P_TriangleStripI(Array) case P_TrianglesI(Array) @@ -112,8 +116,16 @@ extension MeshPrimitive { switch self { case .P_Points: return [ "tag" : "P_Points"] + case .P_LineStrip: + return [ "tag" : "P_LineStrip"] + case .P_LineLoop: + return [ "tag" : "P_LineLoop"] + case .P_Lines: + return [ "tag" : "P_Lines"] case .P_TriangleStrip: return [ "tag" : "P_TriangleStrip"] + case .P_TriangleFan: + return [ "tag" : "P_TriangleFan"] case .P_Triangles: return [ "tag" : "P_Triangles"] case .P_TriangleStripI(let arg0): diff --git a/lambdacube-ir.haskell/src-generated/LambdaCube/Mesh.hs b/lambdacube-ir.haskell/src-generated/LambdaCube/Mesh.hs index 8d6db7a..5655975 100644 --- a/lambdacube-ir.haskell/src-generated/LambdaCube/Mesh.hs +++ b/lambdacube-ir.haskell/src-generated/LambdaCube/Mesh.hs @@ -1,5 +1,5 @@ -- generated file, do not modify! --- 2016-11-11T11:17:03.517567000000Z +-- 2023-10-27T02:34:24.280572454Z {-# LANGUAGE OverloadedStrings, RecordWildCards #-} module LambdaCube.Mesh where @@ -30,7 +30,11 @@ data MeshAttribute data MeshPrimitive = P_Points + | P_LineStrip + | P_LineLoop + | P_Lines | P_TriangleStrip + | P_TriangleFan | P_Triangles | P_TriangleStripI (Vector Int32) | P_TrianglesI (Vector Int32) @@ -75,7 +79,11 @@ instance FromJSON MeshAttribute where instance ToJSON MeshPrimitive where toJSON v = case v of P_Points -> object [ "tag" .= ("P_Points" :: Text)] + P_LineStrip -> object [ "tag" .= ("P_LineStrip" :: Text)] + P_LineLoop -> object [ "tag" .= ("P_LineLoop" :: Text)] + P_Lines -> object [ "tag" .= ("P_Lines" :: Text)] P_TriangleStrip -> object [ "tag" .= ("P_TriangleStrip" :: Text)] + P_TriangleFan -> object [ "tag" .= ("P_TriangleFan" :: Text)] P_Triangles -> object [ "tag" .= ("P_Triangles" :: Text)] P_TriangleStripI arg0 -> object [ "tag" .= ("P_TriangleStripI" :: Text), "arg0" .= arg0] P_TrianglesI arg0 -> object [ "tag" .= ("P_TrianglesI" :: Text), "arg0" .= arg0] @@ -85,7 +93,11 @@ instance FromJSON MeshPrimitive where tag <- obj .: "tag" case tag :: Text of "P_Points" -> pure P_Points + "P_LineStrip" -> pure P_LineStrip + "P_LineLoop" -> pure P_LineLoop + "P_Lines" -> pure P_Lines "P_TriangleStrip" -> pure P_TriangleStrip + "P_TriangleFan" -> pure P_TriangleFan "P_Triangles" -> pure P_Triangles "P_TriangleStripI" -> P_TriangleStripI <$> obj .: "arg0" "P_TrianglesI" -> P_TrianglesI <$> obj .: "arg0"