Skip to content

Commit d220967

Browse files
committed
Removed usage of G3_USING_UNITY preprocessor definition, and added an assembly reference to UnityEngine.dll
1 parent 7982934 commit d220967

28 files changed

+552
-144
lines changed

.idea/.idea.geometry3Sharp.dir/.idea/contentModel.xml

Lines changed: 358 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.geometry3Sharp.dir/.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.geometry3Sharp.dir/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.geometry3Sharp.dir/.idea/projectSettingsUpdater.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.geometry3Sharp.dir/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.geometry3Sharp.dir/.idea/workspace.xml

Lines changed: 153 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.geometry3Sharp.dir/riderModule.iml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Open-Source (Boost-license) C# library for geometric computing.
44

5-
geometry3Sharp is compatible with Unity. Set the G3_USING_UNITY Scripting Define and you will have transparent interop between g3 and Unity vector types (*see details at the very bottom of this README*). Although the library is written for C# 4.5, if you are using the .NET 3.5 Unity runtime, it will still work, just with a few missing features.
5+
geometry3Sharp is compatible with Unity.
66

77
Currently there is a small amount of unsafe code, however this code is only used in a few fast-buffer-copy routines, which can be deleted if you need a safe version (eg for Unity web player).
88

@@ -381,10 +381,8 @@ Several tutorials for using g3Sharp have been posted on the Gradientspace blog:
381381
# Unity Interop
382382

383383
geometry3Sharp supports transparent conversion with Unity types.
384-
To enable this, define **G3_USING_UNITY** in your Unity project, by adding this
385-
string to the **Scripting Define Symbols** box in the **Player Settings**.
386384

387-
Once enabled, code like this will work transparently:
385+
Code like this will work transparently:
388386

389387
~~~~
390388
Vector3 unityVec;

color/Colorb.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
22

3-
#if G3_USING_UNITY
43
using UnityEngine;
5-
#endif
64

75
namespace g3
86
{
@@ -33,7 +31,6 @@ public byte this[int key]
3331
}
3432

3533

36-
#if G3_USING_UNITY
3734
public static implicit operator Colorb(UnityEngine.Color32 c)
3835
{
3936
return new Colorb(c.r, c.g, c.b, c.a);
@@ -42,7 +39,6 @@ public static implicit operator Color32(Colorb c)
4239
{
4340
return new Color32(c.r, c.g, c.b, c.a);
4441
}
45-
#endif
4642

4743
}
4844
}

color/Colorf.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
using System.Collections.Generic;
33
using System.Text;
44

5-
#if G3_USING_UNITY
65
using UnityEngine;
7-
#endif
86

97
namespace g3
108
{
@@ -244,7 +242,6 @@ public static implicit operator Colorf(Vector3f c)
244242

245243

246244

247-
#if G3_USING_UNITY
248245
public static implicit operator Colorf(UnityEngine.Color c)
249246
{
250247
return new Colorf(c.r, c.g, c.b, c.a);
@@ -258,7 +255,6 @@ public static implicit operator Color32(Colorf c)
258255
Colorb cb = c.ToBytes();
259256
return new Color32(cb.r, cb.g, cb.b, cb.a);
260257
}
261-
#endif
262258

263259
}
264260
}

core/BufferUtil.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,7 @@ static public byte[] ToBytes(double[] array)
513513
static public byte[] CompressZLib(byte[] buffer, bool bFast)
514514
{
515515
MemoryStream ms = new MemoryStream();
516-
#if G3_USING_UNITY && (NET_2_0 || NET_2_0_SUBSET)
517-
DeflateStream zip = new DeflateStream(ms, CompressionMode.Compress);
518-
#else
519516
DeflateStream zip = new DeflateStream(ms, (bFast) ? CompressionLevel.Fastest : CompressionLevel.Optimal, true);
520-
#endif
521517
zip.Write(buffer, 0, buffer.Length);
522518
zip.Close();
523519
ms.Position = 0;

core/Util.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,7 @@ public static string MakeVec3FormatString(int i0, int i1, int i2, int nPrecision
186186

187187
static public string ToSecMilli(TimeSpan t)
188188
{
189-
#if G3_USING_UNITY
190-
return string.Format("{0}", t.TotalSeconds);
191-
#else
192189
return string.Format("{0:F5}", t.TotalSeconds);
193-
#endif
194190
}
195191

196192

core/gParallel.cs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
using System.Text;
55
using System.Threading;
66

7-
#if !(NET_2_0 || NET_2_0_SUBSET)
87
using System.Threading.Tasks;
9-
#endif
108

119
namespace g3
1210
{
@@ -20,11 +18,7 @@ public static void ForEach_Sequential<T>(IEnumerable<T> source, Action<T> body)
2018
}
2119
public static void ForEach<T>( IEnumerable<T> source, Action<T> body )
2220
{
23-
#if G3_USING_UNITY && (NET_2_0 || NET_2_0_SUBSET)
24-
for_each<T>(source, body);
25-
#else
2621
Parallel.ForEach<T>(source, body);
27-
#endif
2822
}
2923

3024

@@ -274,37 +268,6 @@ public int Count {
274268

275269

276270

277-
#if G3_USING_UNITY && (NET_2_0 || NET_2_0_SUBSET)
278-
279-
/*
280-
* .NET 3.5 (default in Unity) does not have SpinLock object, which we
281-
* are using in a few places. So provide a wrapper around Monitor.
282-
* Note that this is class and SpinLock is a struct, so this may cause
283-
* disasters, but at least things build...
284-
*/
285-
public class SpinLock
286-
{
287-
object o;
288-
public SpinLock()
289-
{
290-
o = new object();
291-
}
292-
293-
public void Enter(ref bool entered)
294-
{
295-
Monitor.Enter(o);
296-
entered = true;
297-
}
298-
299-
public void Exit()
300-
{
301-
Monitor.Exit(o);
302-
}
303-
304-
}
305-
306-
307-
#endif
308271

309272

310273
}

geometry3Sharp.asmdef

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "geometry3Sharp",
2+
"name": "com.gradientspace.geometry3sharp",
33
"references": [],
44
"optionalUnityReferences": [],
55
"includePlatforms": [],

geometry3Sharp.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
<Reference Include="System.Data" />
4444
<Reference Include="System.Net.Http" />
4545
<Reference Include="System.Xml" />
46+
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
47+
<HintPath>C:\Program Files\Unity\Hub\Editor\2019.2.10f1\Editor\Data\Managed\UnityEngine.dll</HintPath>
48+
</Reference>
4649
</ItemGroup>
4750
<ItemGroup>
4851
<Compile Include="approximation\BiArcFit2.cs" />
@@ -345,9 +348,6 @@
345348
<Compile Include="solvers\CholeskyDecomposition.cs" />
346349
<Compile Include="spatial\Bitmap2.cs" />
347350
</ItemGroup>
348-
<ItemGroup>
349-
<Folder Include="interfaces\" />
350-
</ItemGroup>
351351
<ItemGroup>
352352
<None Include=".gitignore" />
353353
<None Include="LICENSE" />

0 commit comments

Comments
 (0)