Skip to content

Commit 8cd86c7

Browse files
author
Christian Ohle
committed
release seperation
1 parent ceac1c2 commit 8cd86c7

File tree

7 files changed

+43
-57
lines changed

7 files changed

+43
-57
lines changed

Project.sln

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csgtest", "csgtest\csgtest.
1616
{EDEEBD18-521A-4CDB-BDB5-D2143D00CEFF} = {EDEEBD18-521A-4CDB-BDB5-D2143D00CEFF}
1717
EndProjectSection
1818
EndProject
19-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bin", "bin", "{59E52018-3128-4454-91C5-B89C0D9C716F}"
20-
ProjectSection(SolutionItems) = preProject
21-
bin\cdx32.dll = bin\cdx32.dll
22-
bin\cdx64.dll = bin\cdx64.dll
23-
bin\csg32.dll = bin\csg32.dll
24-
bin\csg3mf.exe = bin\csg3mf.exe
25-
bin\csg64.dll = bin\csg64.dll
26-
EndProjectSection
27-
EndProject
28-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demos", "demos", "{BE1336B9-3BC7-4D40-ABE4-17105DB1EF47}"
29-
ProjectSection(SolutionItems) = preProject
30-
bin\demos\demo1.3mf = bin\demos\demo1.3mf
31-
bin\demos\demo2.3mf = bin\demos\demo2.3mf
32-
bin\demos\demo3.3mf = bin\demos\demo3.3mf
33-
bin\demos\primitives.3mf = bin\demos\primitives.3mf
34-
EndProjectSection
35-
EndProject
36-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "textures", "textures", "{F504DF33-21FF-44DA-B495-D422AA8CFA75}"
37-
ProjectSection(SolutionItems) = preProject
38-
bin\textures\bricks1.png = bin\textures\bricks1.png
39-
bin\textures\rooftiles1.png = bin\textures\rooftiles1.png
40-
bin\textures\wood1.png = bin\textures\wood1.png
41-
EndProjectSection
42-
EndProject
4319
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cdx", "cdx\cdx.vcxproj", "{74BE92FA-0EF3-4FB7-A522-ACAFE1D385CC}"
4420
ProjectSection(ProjectDependencies) = postProject
4521
{EDEEBD18-521A-4CDB-BDB5-D2143D00CEFF} = {EDEEBD18-521A-4CDB-BDB5-D2143D00CEFF}
@@ -100,10 +76,6 @@ Global
10076
GlobalSection(SolutionProperties) = preSolution
10177
HideSolutionNode = FALSE
10278
EndGlobalSection
103-
GlobalSection(NestedProjects) = preSolution
104-
{BE1336B9-3BC7-4D40-ABE4-17105DB1EF47} = {59E52018-3128-4454-91C5-B89C0D9C716F}
105-
{F504DF33-21FF-44DA-B495-D422AA8CFA75} = {59E52018-3128-4454-91C5-B89C0D9C716F}
106-
EndGlobalSection
10779
GlobalSection(ExtensibilityGlobals) = postSolution
10880
SolutionGuid = {7FC8D76C-00FC-4ADC-B7E2-BF6AA82F7091}
10981
EndGlobalSection

bin/cdx32.dll

0 Bytes
Binary file not shown.

bin/cdx64.dll

0 Bytes
Binary file not shown.

bin/csg3mf.exe

512 Bytes
Binary file not shown.

cdx/Factory.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ void CView::EndVertices(UINT nv, UINT mode)
396396

397397
void CView::Pick(const short* pt)
398398
{
399-
if (!swapchain.p) return;
400-
XMFLOAT2 pc(pt[0], pt[1]); iover = -1;
399+
iover = -1; if (!swapchain.p) return;
400+
XMFLOAT2 pc(pt[0], pt[1]);
401401
if (!rtvtex1.p) initpixel();
402402
auto vp = viewport; vp.TopLeftX = -pc.x; vp.TopLeftY = -pc.y;
403403
context->RSSetViewports(1, &vp); //pixelscale = 0;
@@ -439,15 +439,15 @@ void CView::Pick(const short* pt)
439439
if (ppc)
440440
{
441441
auto& nodes = scene.p->nodes;
442-
auto m = XMMatrixInverse(0, nodes.p[iover = ppc - 1]->gettrans(scene.p) * mm[MM_PLANE]);
443-
vv[VV_OVERPOS] = XMVector3TransformCoord(pickp, m);
442+
auto m = XMMatrixInverse(0, nodes.p[iover = ppc - 1]->gettrans(scene.p) * mm[MM_VIEWPROJ]);
443+
vv[VV_OVERPOS] = XMVector3TransformCoord(pickp, m);
444444
mm[MM_PLANE] = mm[MM_VIEWPROJ];
445445
}
446446

447-
if (isnan(vv[VV_OVERPOS].m128_f32[0]))
448-
{
449-
iover = -1; //todo: check
450-
}
447+
//if (isnan(vv[VV_OVERPOS].m128_f32[0]))
448+
//{
449+
// iover = -1; //todo: check
450+
//}
451451
}
452452

453453
void CView::setproject()

csg3mf/CSGInterface.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ public struct Rational : IEquatable<Rational>
159159
[FieldOffset(0)] readonly int t;
160160
[FieldOffset(4)] readonly int i;
161161
[FieldOffset(8)] readonly IVector p;
162-
public override string ToString() => p.GetString(i);
163-
public string ToString(int digits, int fl = 3) => p.GetString(i, digits, fl);
162+
public override string ToString() => p != null ? p.GetString(i) : "NaN";
163+
public string ToString(int digits, int fl = 3) => p !=null ? p.GetString(i, digits, fl) : "NaN";
164164
public static Rational Parse(string s)
165165
{
166166
var p = ctor(1); Variant v; v.vt = (ushort)VarType.String | (1 << 8);

csg3mf/Script.cs

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static Expression<Func<object, object[]>> Compile(Type @this, string code
3535
stack = new Stack { Expression.Parameter(typeof(object), "this") }; stack.@this = Expression.Parameter(@this, "this");
3636
if (map != null) stack.dict = new Dictionary<ParameterExpression, int>();
3737
stack.npub = 1; a.Parse(null, null, null, 0x08 | 0x04);
38-
var t1 = a.Parse(/*Expression.Label(typeof(void), "return")*/null, null, null, 0x01);
38+
var t1 = a.Parse(null, null, null, 0x01);
3939
var t2 = Expression.Lambda<Func<object, object[]>>(t1, ".ctor", stack.Take(1)); return t2;
4040
}
4141
catch { var e = (Script*)ptr; LastError = ((int)(e->s - (char*)(ptr + 32)), e->n); throw; }
@@ -44,11 +44,15 @@ public static Expression<Func<object, object[]>> Compile(Type @this, string code
4444
public static (int i, int n) LastError { get; private set; }
4545
public override string ToString() => new string(s, 0, n);
4646
char* s; int n; static byte* ptr; static Stack stack;
47-
class Stack : List<ParameterExpression> { internal ParameterExpression @this; internal List<object> usings = new List<object>(); internal int nstats, nusings, npub; internal List<Expression> list = new List<Expression>(); internal Dictionary<ParameterExpression, int> dict; }
47+
class Stack : List<ParameterExpression> { internal ParameterExpression @this; internal List<object> usings = new List<object>(); internal int nstats, nusings, npub, xpos; internal List<Expression> list = new List<Expression>(); internal Dictionary<ParameterExpression, int> dict; }
4848
Expression Parse(LabelTarget @return, LabelTarget @break, LabelTarget @continue, int flags)
4949
{
5050
var list = stack.list; int stackab = (flags & 1) != 0 ? 1 : stack.Count, listab = list.Count; var ep = *(Script*)ptr;
51-
if ((flags & 0x01) != 0) { stack.Add(stack.@this); list.Add(Expression.Assign(stack.@this, Expression.Convert(stack[0], stack.@this.Type))); }
51+
if ((flags & 0x01) != 0)
52+
{
53+
stack.Add(stack.@this); list.Add(Expression.Assign(stack.@this, Expression.Convert(stack[0], stack.@this.Type)));
54+
if (dbg != null) { stack.xpos = stack.Count; stack.Add(Expression.Variable(typeof(Func<(int, object)[]>), "?")); stack.dict[stack[stack.xpos]] = -1; }
55+
}
5256
if (map != null && (flags & 0x02) != 0) { var s = this; for (s.n = 1; *s.s != '{'; s.s--) ; __map(s); }
5357
for (var c = this; c.n != 0;)
5458
{
@@ -87,7 +91,7 @@ Expression Parse(LabelTarget @return, LabelTarget @break, LabelTarget @continue,
8791
if (n.equals("switch"))
8892
{
8993
if ((flags & 0x08) != 0) continue;
90-
n = t.next(); n.trim(1, 1); var t1 = n.Parse(null);
94+
n = t.next(); n.trim(1, 1); __map(n); var t1 = n.Parse(null);
9195
n = t.next(); n.trim(1, 1); var t2 = stack.usings.Count; var t5 = (Expression)null;
9296
for (var ab = list.Count; n.n != 0;)
9397
{
@@ -118,10 +122,10 @@ Expression Parse(LabelTarget @return, LabelTarget @break, LabelTarget @continue,
118122
var t1 = t.Parse(t0); if (t0 == null) @return.GetType().GetField("_type", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(@return, t0 = t1.Type);
119123
list.Add(Expression.Return(@return, Convert(t1, t0))); continue;
120124
}
121-
if (t.n != 0) n.error("invalid type"); list.Add(Expression.Return(@return)); continue;
125+
if (t.n != 0) n.error("invalid type"); __map(n); list.Add(Expression.Return(@return)); continue;
122126
}
123-
if (n.equals("break")) { if ((flags & 0x08) != 0) continue; list.Add(Expression.Break(@break)); continue; }
124-
if (n.equals("continue")) { if ((flags & 0x08) != 0) continue; list.Add(Expression.Break(@continue)); continue; }
127+
if (n.equals("break")) { if ((flags & 0x08) != 0) continue; __map(n); list.Add(Expression.Break(@break)); continue; }
128+
if (n.equals("continue")) { if ((flags & 0x08) != 0) continue; __map(n); list.Add(Expression.Break(@continue)); continue; }
125129
if (n.equals("new")) { if ((flags & 0x08) != 0) continue; list.Add(a.Parse(null)); continue; }
126130
var @public = false; if (n.equals("public")) { a = t; @public = true; }
127131
n = a; t = n.gettype(); if (t.n == 0) { if ((flags & 0x08) != 0) continue; __map(a); list.Add(a.Parse(null)); continue; }
@@ -151,18 +155,14 @@ Expression Parse(LabelTarget @return, LabelTarget @break, LabelTarget @continue,
151155
if (map != null) { var u = n; u.n = (int)(v.s - n.s) + v.n; __map(u); }
152156
list.Add(Expression.Assign(e, Convert(r, e.Type)));
153157
}
154-
if (i == 0) { stack.Add(e); if (map != null) __map(n, e); }
158+
if (i == 0) { if (dbg != null && (flags & 0x01) != 0) stack.Insert(stack.xpos++, e); else stack.Add(e); if (map != null) __map(n, e); }
155159
}
156160
}
157161
*(Script*)ptr = ep;
158162
if ((flags & 0x04) != 0) return null;
159-
if (map != null && (flags & 0x02) != 0)
160-
{
161-
var s = this; for (s = this, s.s += s.n, s.n = 1; *s.s != '}'; s.s++) ; __map(s);
162-
//if (IntPtr.Size == 8) list.Add(__dbg(int.MaxValue)); //bypass RyuJIT SF bug
163-
}
163+
if (map != null && (flags & 0x02) != 0) { var s = this; for (s = this, s.s += s.n, s.n = 1; *s.s != '}'; s.s++) ; __map(s); }
164164
if ((flags & 0x02) != 0) list.Add(@return.Type != typeof(void) ? Expression.Label(@return, Expression.Default(@return.Type)) : Expression.Label(@return));
165-
if ((flags & 0x01) != 0) list.Add(Expression.NewArrayInit(typeof(object), stack.Take(stack.npub)));
165+
if ((flags & 0x01) != 0) { list.Add(Expression.NewArrayInit(typeof(object), stack.Take(stack.npub))); if (dbg != null) __dbg(); }
166166
if ((flags & 0x10) != 0) list.Add(Expression.Label(@break));
167167
var block = stack.Count != stackab || list.Count - listab > 1 ? Expression.Block(stack.Skip(stackab), list.Skip(listab)) : list.Count - listab == 1 ? list[listab] : Expression.Empty();
168168
list.RemoveRange(listab, list.Count - listab); stack.RemoveRange(stackab, stack.Count - stackab);
@@ -832,11 +832,20 @@ static Expression __dbg(int i)
832832
Expression.Call(t1, dbg.Method, t2, Expression.Default(typeof((int, object)[]))),
833833
Expression.Call(t1, dbg.Method, t2,
834834
Expression.NewArrayInit(typeof((int, object)),
835-
stack.Intersect(stack.dict.Keys).Where(p => !p.Type.IsSubclassOf(typeof(Delegate))).
835+
stack.Skip(stack.xpos).Intersect(stack.dict.Keys).//Where(p => !p.Type.IsSubclassOf(typeof(Delegate))).
836836
Select(p => Expression.New(__ctor ?? (__ctor = typeof((int, object)).GetConstructors()[0]),
837837
Expression.Constant(stack.dict[p]), Expression.Convert(p, typeof(object)))))
838838
));
839839
}
840+
static void __dbg()
841+
{
842+
var t1 = Expression.NewArrayInit(typeof((int, object)),
843+
stack.Intersect(stack.dict.Keys).Where(p => !p.Type.IsSubclassOf(typeof(Delegate))).
844+
Select(p => Expression.New(__ctor ?? (__ctor = typeof((int, object)).GetConstructors()[0]),
845+
Expression.Constant(stack.dict[p]), Expression.Convert(p, typeof(object)))));
846+
var t2 = Expression.Lambda<Func<(int, object)[]>>(t1, "?", null);
847+
stack.list.Insert(0, Expression.Assign(stack[stack.xpos], t2));
848+
}
840849
static ConstructorInfo __ctor;
841850
#endregion
842851
}
@@ -996,7 +1005,6 @@ protected override unsafe void OnPaint(PaintEventArgs e)
9961005
}
9971006
if (k != -1) TypeHelper.drawicon(e.Graphics, -2, LineOffset(LineFromPos(map[k].i)) + 1, 12);
9981007
}
999-
10001008
public override int OnCommand(int id, object test)
10011009
{
10021010
switch (id)
@@ -1031,6 +1039,10 @@ public override int OnCommand(int id, object test)
10311039
if (test != null) return 1;
10321040
return 1;
10331041
case 5020: return breakpoint(test);
1042+
//case 65301: //can close
1043+
// if (state != 7) return 0;
1044+
// if (test != null) return 1;
1045+
// MessageBox.Show("no!"); return 1;
10341046
}
10351047
return base.OnCommand(id, test);
10361048
}
@@ -1064,7 +1076,7 @@ void start(int st)
10641076
//xobject.GetMethod<Action>();
10651077
Script.bps = map.Where(p => p.v == 0x1A).Select(p => p.i).ToArray();
10661078
Script.dbg = DebugStep; (Script.map = map).Clear(); sp = null;
1067-
state = st; xobject.Code = EditText;
1079+
state = st; xobject.Code = EditText;
10681080
}
10691081
catch (Exception e)
10701082
{
@@ -1121,6 +1133,7 @@ bool DebugStep(int i, (int id, object p)[] stack)
11211133
ReadOnly = true; if (!Focused) { UIForm.ShowView(typeof(ScriptEditor), Parent.Tag, DockStyle.Left); }
11221134
m.v |= 0x20; map[i] = m; Select(m.i); UpdateSyntaxColors(); ScrollVisible(); this.stack = stack;//var ff = new StackTrace().GetFrames();
11231135
sp = &i; for (state = 7; state == 7;) { Native.WaitMessage(); Application.DoEvents(); Application.RaiseIdle(null); }
1136+
if (map.Count == 0) return false;
11241137
ReadOnly = false; this.stack = null; m = map[i]; m.v &= ~0x20; map[i] = m; UpdateSyntaxColors(); Invalidate(); Update();
11251138
MainFrame.Inval(); return true;
11261139
}
@@ -1142,7 +1155,8 @@ protected override void OnMouseMove(MouseEventArgs e)
11421155
if (lastpos == m.i) return; lastpos = m.i;
11431156
if (state == 7 && (m.v >> 8) != 0)
11441157
{
1145-
var v = stack.FirstOrDefault(p => p.id == m.v >> 8);
1158+
var g = ((Func<(int id, object p)[]>)(stack[0].p))();
1159+
var v = g.Concat(stack).FirstOrDefault(p => p.id == m.v >> 8);
11461160
if (v.id != 0)
11471161
{
11481162
EndToolTip(); EndFlyer(); //ToolTip(text.Substring(tpos.i, tpos.n) + " = " + p.ToString());
@@ -1270,7 +1284,7 @@ void EndFlyer()
12701284
{
12711285
if (flyer != null) { flyer.Dispose(); flyer = null; }
12721286
}
1273-
protected override void OnHandleDestroyed(EventArgs e) { map.Clear(); EndFlyer(); base.OnHandleDestroyed(e); }
1287+
protected override void OnHandleDestroyed(EventArgs e) { state = 0; map.Clear(); EndFlyer(); base.OnHandleDestroyed(e); }
12741288
protected override void OnScroll(ScrollEventArgs se) { EndFlyer(); base.OnScroll(se); }
12751289
protected override void OnMouseLeave(EventArgs e)
12761290
{

0 commit comments

Comments
 (0)