Skip to content

Commit

Permalink
torusGridSdf option to only have rows or cols
Browse files Browse the repository at this point in the history
close #1231
  • Loading branch information
t3kt committed May 24, 2024
1 parent ceb31af commit 4840807
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 19 deletions.
51 changes: 34 additions & 17 deletions src/operators/sdf/torusGridSdf.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ ReturnT thismap(CoordT p, ContextT ctx) {
float thCol;
float thRow;

int parts = int(THIS_Parts);

float dCols;
{
if (parts == THISTYPE_Parts_both || parts == THISTYPE_Parts_cols) {
pR(p.xz, shift.x * TAU);
pCol = p;
col = pModPolar(pCol.xz, cols);
Expand All @@ -61,7 +63,7 @@ ReturnT thismap(CoordT p, ContextT ctx) {
}

float dRows;
{
if (parts == THISTYPE_Parts_both || parts == THISTYPE_Parts_rows) {
qRow = vec2(length(p.xz) - rOuter, p.y);
pR(qRow, shift.y * TAU);
row = pModPolar(qRow, rows);
Expand All @@ -74,23 +76,38 @@ ReturnT thismap(CoordT p, ContextT ctx) {
qRow.x -= thOuter;
}

#ifdef THIS_HAS_INPUT_barThicknessField
thCol = inputOp_barThicknessField(p0, ctx);
#else
thCol = THIS_Barthickness;
#endif
dCols = fTorus(pCol.xzy, thCol, thOuter);
if (parts == THISTYPE_Parts_both || parts == THISTYPE_Parts_cols) {
#ifdef THIS_HAS_INPUT_barThicknessField
thCol = inputOp_barThicknessField(p0, ctx);
#else
thCol = THIS_Barthickness;
#endif
dCols = fTorus(pCol.xzy, thCol, thOuter);
}

#ifdef THIS_HAS_INPUT_barThicknessField
thRow = inputOp_barThicknessField(p0, ctx);
#else
thRow = THIS_Barthickness;
#endif
dRows = length(qRow) - thRow;
if (parts == THISTYPE_Parts_both || parts == THISTYPE_Parts_rows) {
#ifdef THIS_HAS_INPUT_barThicknessField
thRow = inputOp_barThicknessField(p0, ctx);
#else
thRow = THIS_Barthickness;
#endif
dRows = length(qRow) - thRow;
}

Sdf res1 = createSdf(dRows);
Sdf res2 = createSdf(dCols);
THIS_combine(res1, res2, p0, ctx);
Sdf res1;
switch (parts) {
case THISTYPE_Parts_both:
res1 = createSdf(dRows);
Sdf res2 = createSdf(dCols);
THIS_combine(res1, res2, p0, ctx);
break;
case THISTYPE_Parts_cols:
res1 = createSdf(dCols);
break;
case THISTYPE_Parts_rows:
res1 = createSdf(dRows);
break;
}

return res1;
}
Binary file modified src/operators/sdf/torusGridSdf.tox
Binary file not shown.
15 changes: 14 additions & 1 deletion src/operators/sdf/torusGridSdf.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
!rop
meta: !meta
opType: raytk.operators.sdf.torusGridSdf
opVersion: '3'
opVersion: '4'
opStatus: beta
opDef: !def
enable: true
Expand Down Expand Up @@ -87,3 +87,16 @@ elements:
Prepcodeplaceholder: MERGE_PREP();
Bodycodeplaceholder: MERGE_BODY();
Defaultinitcodeplaceholder: ''
- !opElement
name: codeSwitcher_Parts
elementType: codeSwitcher
params:
Elementroot: ''
Table: parts
Param: Parts
Autoupdateparams: true
Manageparamstates: true
Alwaysincludeallparams: false
Switchmode: constswitch
Indexexpr: ''
Placeholder: ''
1 change: 0 additions & 1 deletion src/operators/sdf/torusGridSdf_params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ names source handling readOnlyHandling conversion enable
Axis param constant 1
Radius param runtime macro op('radius_definition').numRows < 2
Thickness param runtime macro op('thickness_definition').numRows < 2
Rows Cols param runtime macro 1
Barthickness param runtime macro op('bar_thickness_definition').numRows < 2
Shift[1-2] param runtime macro 1
4 changes: 4 additions & 0 deletions src/operators/sdf/torusGridSdf_parts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name label code params
both Both Rows Cols Combine
rows Rows Only Rows
cols Columns Only Cols
Binary file modified tests/testCases/operators/sdf/torusGridSdf_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testCases/operators/sdf/torusGridSdf_test.tox
Binary file not shown.

0 comments on commit 4840807

Please sign in to comment.