Daily update on 20251015-002614 by Nitload Youmu. Additional Message : Organize files of numerial math.

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-10-15 00:26:15 +08:00
parent c5eaf250ab
commit e283490525
50 changed files with 1319 additions and 1520 deletions
@@ -32,6 +32,7 @@ using StgSharp.Geometries;
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -1,36 +1,34 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ButtonGroup.cs" // file="ButtonGroup"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Geometries; using StgSharp.Geometries;
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -77,16 +75,16 @@ namespace StgSharp.Controls
get => buttonList; get => buttonList;
} }
public void AddButton( TriggerButton button ) public void AddButton(TriggerButton button)
{ {
buttonList.Add( button ); buttonList.Add(button);
} }
public abstract void Confirm(); public abstract void Confirm();
public IEnumerator<PlainGeometryMesh> GetEnumerator() public IEnumerator<PlainGeometryMesh> GetEnumerator()
{ {
foreach( TriggerButton item in buttonList ) { foreach (TriggerButton item in buttonList) {
yield return item.Single(); yield return item.Single();
} }
} }
@@ -94,10 +92,10 @@ namespace StgSharp.Controls
public void MoveDown() public void MoveDown()
{ {
TriggerButton button = current; TriggerButton button = current;
while( ( button.Down != null ) && button.Down.IsDisabled ) { while ((button.Down != null) && button.Down.IsDisabled) {
button = button.Right; button = button.Right;
} }
if( current == button ) { if (current == button) {
return; return;
} }
current.DeHighlight(); current.DeHighlight();
@@ -108,10 +106,10 @@ namespace StgSharp.Controls
public void MoveLeft() public void MoveLeft()
{ {
TriggerButton button = current; TriggerButton button = current;
while( ( button.Left != null ) && button.Left.IsDisabled ) { while ((button.Left != null) && button.Left.IsDisabled) {
button = button.Left; button = button.Left;
} }
if( current == button ) { if (current == button) {
return; return;
} }
current.DeHighlight(); current.DeHighlight();
@@ -122,10 +120,10 @@ namespace StgSharp.Controls
public void MoveRight() public void MoveRight()
{ {
TriggerButton button = current; TriggerButton button = current;
while( ( button.Right != null ) && button.Right.IsDisabled ) { while ((button.Right != null) && button.Right.IsDisabled) {
button = button.Right; button = button.Right;
} }
if( current == button ) { if (current == button) {
return; return;
} }
current.DeHighlight(); current.DeHighlight();
@@ -136,10 +134,10 @@ namespace StgSharp.Controls
public void MoveUp() public void MoveUp()
{ {
TriggerButton button = current; TriggerButton button = current;
while( ( button.Up != null ) && button.Up.IsDisabled ) { while ((button.Up != null) && button.Up.IsDisabled) {
button = button.Right; button = button.Right;
} }
if( current == button ) { if (current == button) {
return; return;
} }
current.DeHighlight(); current.DeHighlight();
@@ -1,36 +1,34 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="CharacterIndexImage.cs" // file="CharacterIndexImage"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Geometries; using StgSharp.Geometries;
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections; using System.Collections;
@@ -55,12 +53,12 @@ namespace StgSharp.Controls
int length, int length,
char defaultChar, char defaultChar,
PlainGeometryMesh tittleMesh, PlainGeometryMesh tittleMesh,
IEnumerable<(char, PlainGeometryMesh)> indexEnumeration ) IEnumerable<(char, PlainGeometryMesh)> indexEnumeration)
{ {
this.length = length; this.length = length;
displayIndex = new char[length]; displayIndex = new char[length];
_tittleMesh = tittleMesh; _tittleMesh = tittleMesh;
texIndex = indexEnumeration.ToDictionary( item => item.Item1, item => item.Item2 ); texIndex = indexEnumeration.ToDictionary(item => item.Item1, item => item.Item2);
} }
public bool IsEntity public bool IsEntity
@@ -85,15 +83,16 @@ namespace StgSharp.Controls
set => throw new NotImplementedException(); set => throw new NotImplementedException();
} }
public void Display( string message ) public void Display(string message)
{ {
if( string.IsNullOrEmpty( message ) ) { if (string.IsNullOrEmpty(message)) {
message = string.Empty; message = string.Empty;
} }
string result = ( message.Length >= length ) ? string result = (message.Length >= length) ?
message.Substring( message.Length - displayIndex.Length ) : message.PadLeft( message.Substring(message.Length - displayIndex.Length) :
length, defaultChar ); message.PadLeft(
length, defaultChar);
displayIndex = result.ToCharArray(); displayIndex = result.ToCharArray();
} }
@@ -101,8 +100,8 @@ namespace StgSharp.Controls
public IEnumerator<PlainGeometryMesh> GetEnumerator() public IEnumerator<PlainGeometryMesh> GetEnumerator()
{ {
yield return _tittleMesh; yield return _tittleMesh;
foreach( char item in displayIndex ) { foreach (char item in displayIndex) {
yield return texIndex[ item ]; yield return texIndex[item];
} }
} }
@@ -1,36 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ControllingIntem.cs" // file="ControllingIntem"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Geometries; using StgSharp.Geometries;
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Mathematics; using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections; using System.Collections;
@@ -1,37 +1,35 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="DecorationBox.cs" // file="DecorationBox"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Controls; using StgSharp.Controls;
using StgSharp.Geometries; using StgSharp.Geometries;
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -44,10 +42,10 @@ namespace StgSharp.Controls
private PlainGeometryMesh renderMesh; private PlainGeometryMesh renderMesh;
public DecorationBox( Rectangle bound, Image texture, Vec2[] texCoord ) public DecorationBox(Rectangle bound, Image texture, Vec2[] texCoord)
{ {
renderMesh = new PlainGeometryMesh( renderMesh = new PlainGeometryMesh(
BoundingBox, new TextureProvider( texture, texCoord ) ); BoundingBox, new TextureProvider(texture, texCoord));
} }
public bool IsEntity => true; public bool IsEntity => true;
@@ -1,37 +1,35 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="MarkingLable.cs" // file="MarkingLable"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Controls; using StgSharp.Controls;
using StgSharp.Geometries; using StgSharp.Geometries;
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using StgSharp.Timing; using StgSharp.Timing;
using System; using System;
@@ -50,7 +48,7 @@ namespace StgSharp.Controls
private Vec2 _currentPosition, _movementVec; private Vec2 _currentPosition, _movementVec;
public MarkingLabel( PlainGeometryMesh marker, TimeFunction movement ) public MarkingLabel(PlainGeometryMesh marker, TimeFunction movement)
{ {
this.marker = marker; this.marker = marker;
_movement = movement; _movement = movement;
@@ -72,16 +70,16 @@ namespace StgSharp.Controls
yield return marker; yield return marker;
} }
public void Move( Vec2 movement ) public void Move(Vec2 movement)
{ {
if( !_movement.IsComplete ) { if (!_movement.IsComplete) {
Position = _currentPosition + ( _movement.Calculate() * _movementVec ); Position = _currentPosition + (_movement.Calculate() * _movementVec);
} }
} }
public void MoveTo( Vec2 target ) public void MoveTo(Vec2 target)
{ {
Move( target - Position ); Move(target - Position);
} }
} }
@@ -1,37 +1,35 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="TriggerButton.cs" // file="TriggerButton"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Controls; using StgSharp.Controls;
using StgSharp.Geometries; using StgSharp.Geometries;
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -40,10 +38,7 @@ using System.Text;
namespace StgSharp.Controls namespace StgSharp.Controls
{ {
public delegate void RenderButtonTextureCallback( public delegate void RenderButtonTextureCallback(ButtonStatus status, float beginTime, in TextureProvider texture);
ButtonStatus status,
float beginTime,
in TextureProvider texture );
public enum ButtonStatus public enum ButtonStatus
{ {
@@ -55,12 +50,12 @@ namespace StgSharp.Controls
Confirm = 0b1000, Confirm = 0b1000,
DisableToEnable = Disable | Enable, DisableToEnable = Disable | Enable,
EnableToDisable = -( Enable | DisableToEnable ), EnableToDisable = -(Enable | DisableToEnable),
EnableToHighlight = Enable | Highlight, EnableToHighlight = Enable | Highlight,
HighlightToEnable = -( Enable | Highlight ), HighlightToEnable = -(Enable | Highlight),
HighlightToDisable = -( Highlight | Disable ), HighlightToDisable = -(Highlight | Disable),
} }
@@ -106,7 +101,7 @@ namespace StgSharp.Controls
{ {
add add
{ {
if( _renderButton == null ) if (_renderButton == null)
{ {
_renderButton = value; _renderButton = value;
} else } else
@@ -116,7 +111,7 @@ namespace StgSharp.Controls
} }
remove remove
{ {
if( _renderButton != null ) { if (_renderButton != null) {
_renderButton -= value; _renderButton -= value;
} }
} }
@@ -130,7 +125,7 @@ namespace StgSharp.Controls
public ReadOnlySpan<Vec4> TextureBox public ReadOnlySpan<Vec4> TextureBox
{ {
get => MemoryMarshal.Cast<Vec2, Vec4>( _texture.TextureCoordinate ); get => MemoryMarshal.Cast<Vec2, Vec4>(_texture.TextureCoordinate);
} }
public Rectangle BoundingBox { get; set; } public Rectangle BoundingBox { get; set; }
@@ -155,7 +150,7 @@ namespace StgSharp.Controls
public void DeHighlight() public void DeHighlight()
{ {
if( CurrentStatus == ButtonStatus.Highlight ) { if (CurrentStatus == ButtonStatus.Highlight) {
CurrentStatus = ButtonStatus.HighlightToEnable; CurrentStatus = ButtonStatus.HighlightToEnable;
} }
} }
@@ -168,48 +163,48 @@ namespace StgSharp.Controls
ButtonStatus.Highlight => ButtonStatus.HighlightToDisable, ButtonStatus.Highlight => ButtonStatus.HighlightToDisable,
_ => CurrentStatus, _ => CurrentStatus,
}; };
if( disableCallback != null ) { if (disableCallback != null) {
disableCallback(); disableCallback();
} }
} }
public void Enable() public void Enable()
{ {
if( CurrentStatus == ButtonStatus.Disable ) if (CurrentStatus == ButtonStatus.Disable)
{ {
CurrentStatus = ButtonStatus.DisableToEnable; CurrentStatus = ButtonStatus.DisableToEnable;
} else } else
{ {
return; return;
} }
if( enableCallback != null ) { if (enableCallback != null) {
enableCallback(); enableCallback();
} }
} }
public IEnumerator<PlainGeometryMesh> GetEnumerator() public IEnumerator<PlainGeometryMesh> GetEnumerator()
{ {
_renderButton( CurrentStatus, _statusBeginTime, in _texture ); _renderButton(CurrentStatus, _statusBeginTime, in _texture);
yield return new PlainGeometryMesh( this.BoundingBox, _texture ); yield return new PlainGeometryMesh(this.BoundingBox, _texture);
} }
public void Highlight() public void Highlight()
{ {
if( CurrentStatus == ButtonStatus.Enable ) if (CurrentStatus == ButtonStatus.Enable)
{ {
CurrentStatus |= ButtonStatus.EnableToHighlight; CurrentStatus |= ButtonStatus.EnableToHighlight;
} else } else
{ {
return; return;
} }
if( confirmCallback != null ) { if (confirmCallback != null) {
confirmCallback(); confirmCallback();
} }
} }
internal void Init( ButtonStatus status ) internal void Init(ButtonStatus status)
{ {
if( CurrentStatus == ButtonStatus.Error ) { if (CurrentStatus == ButtonStatus.Error) {
CurrentStatus = status; CurrentStatus = status;
} }
} }
+1
View File
@@ -30,6 +30,7 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
using StgSharp.Geometries; using StgSharp.Geometries;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
+25 -27
View File
@@ -1,35 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Launcher.cs" // file="Launcher"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Entities; using StgSharp.Entities;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
namespace StgSharp namespace StgSharp
{ {
+18 -22
View File
@@ -1,30 +1,27 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Platform.cs" // file="Platform"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -88,7 +85,6 @@ namespace StgSharp
} }
InternalIO.InitIntrinsicContext(); InternalIO.InitIntrinsicContext();
MatrixParallel.Init();
} }
public static void LogError(Exception ex) public static void LogError(Exception ex)
@@ -1,40 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="CoordinationBase.cs" // file="CoordinationBase"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software. using StgSharp.Mathematics.Graphic;
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Mathematics;
using System; using System.Runtime.CompilerServices;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometries namespace StgSharp.Geometries
{ {
@@ -45,7 +38,7 @@ namespace StgSharp.Geometries
private CoordinationBase localCoordination; private CoordinationBase localCoordination;
private Matrix44 coordMat; private Matrix44 coordMat;
public CoordinationBase( CoordinationBase localCoordination ) public CoordinationBase(CoordinationBase localCoordination)
{ {
this.localCoordination = localCoordination; this.localCoordination = localCoordination;
coordMat = new Matrix44(); coordMat = new Matrix44();
@@ -53,30 +46,31 @@ namespace StgSharp.Geometries
public virtual Point LocalOrigin public virtual Point LocalOrigin
{ {
get => new Point( coordMat.colum3.XYZ ); get => new Point(coordMat.column3.XYZ);
internal set => coordMat.colum3.XYZ = value.Coord; internal set => coordMat.column3.XYZ = value.Coord;
} }
public virtual Vec3 LocalX public virtual Vec3 LocalX
{ {
get => coordMat.colum0.XYZ; get => coordMat.column0.XYZ;
internal set => coordMat.colum0.XYZ = value; internal set => coordMat.column0.XYZ = value;
} }
public virtual Vec3 LocalY public virtual Vec3 LocalY
{ {
get => coordMat.colum1.XYZ; get => coordMat.column1.XYZ;
internal set => coordMat.colum1.XYZ = value; internal set => coordMat.column1.XYZ = value;
} }
public virtual Vec3 LocalZ public virtual Vec3 LocalZ
{ {
get => coordMat.colum2.XYZ; get => coordMat.column2.XYZ;
set => coordMat.colum2.XYZ = value; set => coordMat.column2.XYZ = value;
} }
protected ref Matrix44 CoordMat protected ref Matrix44 CoordMat
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => ref coordMat; get => ref coordMat;
} }
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="PlainCoordinate.cs" // file="PlainCoordinate"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -40,22 +38,20 @@ namespace StgSharp.Geometries
public class PlainCoordinate : CoordinationBase public class PlainCoordinate : CoordinationBase
{ {
private static PlainCoordinate statndardPlainCoordination = new PlainCoordinate( public PlainCoordinate(CoordinationBase local, Point origin, Vec3 xAxis, Vec3 yAxis)
null, new Point( 0, 0, 0 ), new Vec3( 1, 0, 0 ), new Vec3( 0, 1, 0 ) ); : base(local)
public PlainCoordinate( CoordinationBase local, Point origin, Vec3 xAxis, Vec3 yAxis )
: base( local )
{ {
CoordMat = Matrix44.Unit; CoordMat = Matrix44.Unit;
CoordMat.colum0 = new Vec4( xAxis, 0 ); CoordMat.column0 = new Vec4(xAxis, 0);
CoordMat.colum1 = new Vec4( yAxis, 0 ); CoordMat.column1 = new Vec4(yAxis, 0);
CoordMat.colum2 = new Vec4( Linear.Normalize( Vec3.Cross( xAxis, yAxis ) ), 0 ); CoordMat.column2 = new Vec4(Linear.Normalize(Vec3.Cross(xAxis, yAxis)), 0);
LocalOrigin = origin; LocalOrigin = origin;
} }
public static PlainCoordinate StandardPlainCoordination => statndardPlainCoordination; public static PlainCoordinate StandardPlainCoordination { get; } = new(
null, new Point(0, 0, 0), new Vec3(1, 0, 0), new Vec3(0, 1, 0));
} }
} }
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="SpaceCoordinate.cs" // file="SpaceCoordinate"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -39,13 +37,8 @@ namespace StgSharp.Geometries
public class SpaceCoordinate : CoordinationBase public class SpaceCoordinate : CoordinationBase
{ {
public SpaceCoordinate( public SpaceCoordinate(CoordinationBase localCoordination, Point origin, Vec3 xAxis, Vec3 yAxis, Vec3 zAxis)
CoordinationBase localCoordination, : base(localCoordination) { }
Point origin,
Vec3 xAxis,
Vec3 yAxis,
Vec3 zAxis )
: base( localCoordination ) { }
} }
} }
@@ -1,46 +1,40 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="GeometryOperation.cs" // file="GeometryOperation"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software. using StgSharp.Mathematics.Graphic;
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Mathematics;
using StgSharp.Timing; using StgSharp.Timing;
using System; using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Geometries namespace StgSharp.Geometries
{ {
[UnmanagedFunctionPointer( CallingConvention.Cdecl )] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate Vec3 GeometryMotionDelegate( TimeSpanProvider timeSource, out float rotation ); public delegate Vec3 GeometryMotionDelegate(TimeSpanProvider timeSource, out float rotation);
public class GeometryMotion public class GeometryMotion
{ {
@@ -54,25 +48,25 @@ namespace StgSharp.Geometries
public unsafe GeometryMotion( public unsafe GeometryMotion(
bool isIncreament, bool isIncreament,
TimeSpanProvider timeSource, TimeSpanProvider timeSource,
GeometryMotionDelegate motionDelegate ) GeometryMotionDelegate motionDelegate)
{ {
isIncrementMode = isIncreament; isIncrementMode = isIncreament;
time = timeSource; time = timeSource;
if( motionDelegate == null ) if (motionDelegate == null)
{ {
handle = ( IntPtr )( delegate*<TimeSpanProvider, out float, Vec3> )&defaultMotion; handle = (IntPtr)(delegate*<TimeSpanProvider, out float, Vec3>)&defaultMotion;
movement = defaultMotion; movement = defaultMotion;
} else if( motionDelegate.Method.IsStatic ) } else if (motionDelegate.Method.IsStatic)
{ {
sourceIsStatic = true; sourceIsStatic = true;
handle = Marshal.GetFunctionPointerForDelegate( motionDelegate ); handle = Marshal.GetFunctionPointerForDelegate(motionDelegate);
movement = motionDelegate; movement = motionDelegate;
} else } else
{ {
movement = motionDelegate; movement = motionDelegate;
} }
//sourceIsStatic = false; // sourceIsStatic = false;
} }
public bool IsIncrement public bool IsIncrement
@@ -82,23 +76,23 @@ namespace StgSharp.Geometries
public static GeometryMotion DefaultMotion public static GeometryMotion DefaultMotion
{ {
get => new GeometryMotion( true, null, null ); get => new GeometryMotion(true, null, null);
} }
public unsafe void RunMotion( ref Vec3 coord, ref float rotation ) public unsafe void RunMotion(ref Vec3 coord, ref float rotation)
{ {
float rot; float rot;
Vec3 vec; Vec3 vec;
if( sourceIsStatic ) if (sourceIsStatic)
{ {
vec = ( ( delegate* unmanaged[Cdecl]<TimeSpanProvider, out float, Vec3> )handle )( vec = ((delegate* unmanaged[Cdecl]<TimeSpanProvider, out float, Vec3>)handle)(
time, out rot ); time, out rot);
} else } else
{ {
vec = movement( time, out rot ); vec = movement(time, out rot);
} }
if( isIncrementMode ) if (isIncrementMode)
{ {
coord += vec; coord += vec;
rotation += rot; rotation += rot;
@@ -109,7 +103,7 @@ namespace StgSharp.Geometries
} }
} }
private static Vec3 defaultMotion( TimeSpanProvider provider, out float rotation ) private static Vec3 defaultMotion(TimeSpanProvider provider, out float rotation)
{ {
rotation = 0; rotation = 0;
return Vec3.Zero; return Vec3.Zero;
+27 -26
View File
@@ -1,34 +1,35 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="IGeometry.cs" // file="IGeometry.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -42,7 +43,7 @@ namespace StgSharp.Geometries
public interface IGeometry public interface IGeometry
{ {
public Point this[ int index ] { get; set; } public Point this[int index] { get; set; }
#pragma warning disable CA1819 #pragma warning disable CA1819
public Vec4[] VertexStream public Vec4[] VertexStream
+21 -26
View File
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="IInstancing.cs" // file="IInstancing"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -52,8 +50,7 @@ namespace StgSharp.Geometries
BufferId] = temp; BufferId] = temp;
} } } }
public float Scale { get { return GlobalBuffer.ScalingList[BufferId]; } set { GlobalBuffer.ScalingList[ public float Scale { get { return GlobalBuffer.ScalingList[BufferId]; } set { GlobalBuffer.ScalingList[BufferId] = value; } }
BufferId] = value; } }
public GeometryMotion Motion { get; set; } public GeometryMotion Motion { get; set; }
@@ -63,9 +60,7 @@ namespace StgSharp.Geometries
public Vec3 CenterPositionGlobal { get; internal set; } public Vec3 CenterPositionGlobal { get; internal set; }
public Vec3 Coord { get { return GlobalBuffer.CoordAndRotationList[BufferId].XYZ; } set { GlobalBuffer.CoordAndRotationList[ public Vec3 Coord { get { return GlobalBuffer.CoordAndRotationList[BufferId].XYZ; } set { GlobalBuffer.CoordAndRotationList[BufferId] = new Vec4(value.reg); } }
BufferId] = new Vec4(
value.reg); } }
public void Move() public void Move()
{ {
+25 -27
View File
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="IInstancingBuffer.cs" // file="IInstancingBuffer"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="GeometryOperation.cs" // file="GeometryOperation"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@@ -37,10 +35,10 @@ namespace StgSharp.Geometries
public static unsafe class GeometryOperation public static unsafe class GeometryOperation
{ {
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec3 DefaultMotion( int tick ) public static Vec3 DefaultMotion(int tick)
{ {
return default( Vec3 ); return default(Vec3);
} }
} }
@@ -1,34 +1,35 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="IPlainEntity.cs" // file="IPlainEntity.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -43,7 +44,7 @@ namespace StgSharp.Geometries
public Vec2 CenterPosition { get; set; } public Vec2 CenterPosition { get; set; }
public bool CollideWith( IPlainEntity entity ); public bool CollideWith(IPlainEntity entity);
} }
@@ -52,12 +53,12 @@ namespace StgSharp.Geometries
private PlainGeometry _shape; private PlainGeometry _shape;
public PlainEntity( PlainGeometry shape ) public PlainEntity(PlainGeometry shape)
{ {
_shape = shape; _shape = shape;
} }
bool IPlainEntity.CollideWith( IPlainEntity entity ) bool IPlainEntity.CollideWith(IPlainEntity entity)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ParticleOnPlain.cs" // file="ParticleOnPlain"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -43,14 +41,14 @@ namespace StgSharp.Geometries
public class ParticleOnPlain : IInstancing, IPlainEntity public class ParticleOnPlain : IInstancing, IPlainEntity
{ {
public ParticleOnPlain( PlainInstancingBuffer<ParticleOnPlain> buffer ) public ParticleOnPlain(PlainInstancingBuffer<ParticleOnPlain> buffer)
{ {
if( buffer == null ) { if (buffer == null) {
throw new ArgumentNullException( paramName: nameof( buffer ) ); throw new ArgumentNullException(paramName:nameof(buffer));
} }
GlobalBuffer = buffer; GlobalBuffer = buffer;
BufferId = buffer.CreateInstanceID(); BufferId = buffer.CreateInstanceID();
( ( IInstancingBuffer )buffer ).InstanceList.Add( this ); ((IInstancingBuffer)buffer).InstanceList.Add(this);
} }
public GeometryMotion Motion { get; set; } public GeometryMotion Motion { get; set; }
@@ -61,14 +59,14 @@ namespace StgSharp.Geometries
Vec3 IInstancing.CenterPositionGlobal { get; set; } Vec3 IInstancing.CenterPositionGlobal { get; set; }
bool IPlainEntity.CollideWith( IPlainEntity entity ) bool IPlainEntity.CollideWith(IPlainEntity entity)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
Vec2 IPlainEntity.CenterPosition Vec2 IPlainEntity.CenterPosition
{ {
get => GlobalBuffer.CoordAndRotationList[ BufferId ].XY; get => GlobalBuffer.CoordAndRotationList[BufferId].XY;
set => throw new NotImplementedException(); set => throw new NotImplementedException();
} }
@@ -1,35 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="PlainGeometry.cs" // file="PlainGeometry"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
@@ -45,15 +43,15 @@ namespace StgSharp.Geometries
protected Vec4[] vertexMat; protected Vec4[] vertexMat;
internal CoordinationBase coordinate; internal CoordinationBase coordinate;
internal PlainGeometry( CoordinationBase coordination ) internal PlainGeometry(CoordinationBase coordination)
{ {
coordinate = coordination; coordinate = coordination;
} }
public Point this[ int index ] public Point this[int index]
{ {
get => new Point( vertexMat[ index ] ); get => new Point(vertexMat[index]);
set => vertexMat[ index ].vec = value.coordVec; set => vertexMat[index].vec = value.coordVec;
} }
public int VertexCount => this.vertexMat.Length; public int VertexCount => this.vertexMat.Length;
@@ -1,34 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="PlainInstancingBuffer.cs" // file="PlainInstancingBuffer"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using StgSharp.Mathematics.Numeric;
using System; using System;
using System.Collections; using System.Collections;
@@ -38,19 +37,20 @@ using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace StgSharp.Geometries namespace StgSharp.Geometries
{ {
public class PlainInstancingBuffer<T> : IDisposable, IEnumerable<T>, IInstancingBuffer public class PlainInstancingBuffer<T> : IDisposable, IEnumerable<T>, IInstancingBuffer where T: IInstancing
where T: IInstancing
{ {
private bool disposedValue; private bool disposedValue;
private CoordinatePlain globalCorrdinnate; private CoordinatePlain globalCoordinate;
private List<Vec4> coordList; private List<Vec4> coordList;
private List<IInstancing> instanceList; private List<IInstancing> instanceList;
private List<float> scalingList; private List<float> scalingList;
@@ -58,9 +58,9 @@ namespace StgSharp.Geometries
public PlainInstancingBuffer() public PlainInstancingBuffer()
{ {
coordList = new List<Vec4>( capacity: 100 ); coordList = new List<Vec4>(capacity:100);
instanceList = new List<IInstancing>( capacity: 100 ); instanceList = new List<IInstancing>(capacity:100);
scalingList = new List<float>( capacity: 100 ); scalingList = new List<float>(capacity:100);
coordArray = Array.Empty<Vec4>(); coordArray = Array.Empty<Vec4>();
scaleArray = Array.Empty<float>(); scaleArray = Array.Empty<float>();
mutex = new Mutex(); mutex = new Mutex();
@@ -68,125 +68,96 @@ namespace StgSharp.Geometries
public List<IInstancing> InstanceList public List<IInstancing> InstanceList
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => instanceList; get => instanceList;
} }
public List<Vec4> CoordAndRotationList public List<Vec4> CoordAndRotationList
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => coordList; get => coordList;
} }
public List<float> ScalingList public List<float> ScalingList
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => scalingList; get => scalingList;
} }
public Span<Vec4> CoordAndRotationSpan public Span<Vec4> CoordAndRotationSpan
{ {
get [MethodImpl(MethodImplOptions.AggressiveInlining)]
{ get => CollectionsMarshal.AsSpan(coordList);
if( coordArray.Length != coordList.Capacity )
{
FieldInfo fieldInfo = typeof( List<Vec4> ).
GetField( "_items", BindingFlags.NonPublic | BindingFlags.Instance );
if( fieldInfo == null )
{
#pragma warning disable CA1065
#pragma warning disable CA2201
throw new NullReferenceException();
#pragma warning restore CA2201
#pragma warning restore CA1065
}
coordArray = ( Vec4[] )fieldInfo.GetValue( coordList );
}
return new Span<Vec4>( coordArray, 0, coordList.Count );
}
} }
public Span<float> ScalingSpan public Span<float> ScalingSpan
{ {
get [MethodImpl(MethodImplOptions.AggressiveInlining)]
{ get => CollectionsMarshal.AsSpan(scalingList);
if( scaleArray.Length != coordList.Capacity )
{
FieldInfo fieldInfo = typeof( List<float> ).
GetField( "_items", BindingFlags.NonPublic | BindingFlags.Instance );
if( fieldInfo == null )
{
#pragma warning disable CA1065
#pragma warning disable CA2201
throw new NullReferenceException();
#pragma warning restore CA2201
#pragma warning restore CA1065
}
scaleArray = ( float[] )fieldInfo.GetValue( scalingList );
}
return new Span<float>( scaleArray, 0, coordList.Count );
}
} }
public int CreateInstanceID() public int CreateInstanceID()
{ {
mutex.WaitOne(); mutex.WaitOne();
int ret = instanceList.Count; int ret = instanceList.Count;
coordList.Add( new Vec4() ); coordList.Add(new Vec4());
scalingList.Add( 0 ); scalingList.Add(0);
mutex.ReleaseMutex(); mutex.ReleaseMutex();
return ret; return ret;
} }
// ~PlainInstancingBuffer() // ~PlainInstancingBuffer()
// { // {
// Dispose(disposing: false); // Dispose(disposing: false);
// } // }
public void Dispose() public void Dispose()
{ {
Dispose( disposing: true ); Dispose(disposing:true);
GC.SuppressFinalize( this ); GC.SuppressFinalize(this);
} }
public IEnumerator<T> GetEnumerator() public IEnumerator<T> GetEnumerator()
{ {
foreach( IInstancing item in instanceList ) { foreach (IInstancing item in instanceList) {
yield return ( T )item; yield return (T)item;
} }
} }
public void Remove( T instance ) public void Remove(T instance)
{ {
mutex.WaitOne(); mutex.WaitOne();
if( instance.GlobalBuffer != this ) { if (instance.GlobalBuffer != this) {
throw new ArgumentException( throw new ArgumentException(
message: "instance does not belong to current Particle Buffer", message:"instance does not belong to current Particle Buffer",
paramName: nameof( instance ) ); paramName:nameof(instance));
} }
int index = instance.BufferId; int index = instance.BufferId;
IInstancing temp = instanceList[ instanceList.Count - 1 ]; IInstancing temp = instanceList[^1];
instanceList[ instance.BufferId ] = temp; instanceList[instance.BufferId] = temp;
temp.BufferId = instance.BufferId; temp.BufferId = instance.BufferId;
coordList[ instance.BufferId ] = coordList[ coordList.Count - 1 ]; coordList[instance.BufferId] = coordList[^1];
scalingList[ instance.BufferId ] = scalingList[ scalingList.Count - 1 ]; scalingList[instance.BufferId] = scalingList[^1];
instanceList.RemoveAt( instanceList.Count - 1 ); instanceList.RemoveAt(instanceList.Count - 1);
coordList.RemoveAt( coordList.Count - 1 ); coordList.RemoveAt(coordList.Count - 1);
scalingList.RemoveAt( scalingList.Count - 1 ); scalingList.RemoveAt(scalingList.Count - 1);
mutex.ReleaseMutex(); mutex.ReleaseMutex();
} }
public void UpdateAllParticles() public void UpdateAllParticles()
{ {
foreach( IInstancing particle in instanceList ) { foreach (IInstancing particle in instanceList) {
particle.Move(); particle.Move();
} }
} }
protected virtual void Dispose( bool disposing ) protected virtual void Dispose(bool disposing)
{ {
if( !disposedValue ) if (!disposedValue)
{ {
if( disposing ) { if (disposing) {
mutex.Dispose(); mutex.Dispose();
} }
@@ -199,8 +170,8 @@ namespace StgSharp.Geometries
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
foreach( IInstancing item in instanceList ) { foreach (IInstancing item in instanceList) {
yield return ( T )item; yield return (T)item;
} }
} }
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Parallelogram.cs" // file="Parallelogram"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
@@ -38,22 +36,14 @@ namespace StgSharp.Geometries
{ {
internal readonly Func<int, Vec3> movCenterOperation = internal readonly Func<int, Vec3> movCenterOperation =
new Func<int, Vec3>( GeometryOperation.DefaultMotion ); new Func<int, Vec3>(GeometryOperation.DefaultMotion);
internal Point center; internal Point center;
public Parallelogram( public Parallelogram(float v0x, float v0y, float v1x, float v1y, float v2x, float v2y, float v3x, float v3y)
float v0x, : base(v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y)
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
: base( v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y )
{ {
#if DEBUG #if DEBUG
if( this[ 0 ].Coord + this[ 2 ].Coord != this[ 1 ].Coord + this[ 3 ].Coord ) if( this[ 0 ].Coord + this[ 2 ].Coord != this[ 1 ].Coord + this[ 3 ].Coord )
{ {
InternalIO.InternalWriteLog( InternalIO.InternalWriteLog(
@@ -72,10 +62,10 @@ namespace StgSharp.Geometries
float v2x, float v2x,
float v2y, float v2y,
float v3x, float v3x,
float v3y ) float v3y)
: base( coordination, v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y ) : base(coordination, v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y)
{ {
#if DEBUG #if DEBUG
if( this[ 0 ].Coord + this[ 2 ].Coord != this[ 1 ].Coord + this[ 3 ].Coord ) if( this[ 0 ].Coord + this[ 2 ].Coord != this[ 1 ].Coord + this[ 3 ].Coord )
{ {
InternalIO.InternalWriteLog( InternalIO.InternalWriteLog(
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Plain.cs" // file="Plain"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System.Numerics; using System.Numerics;
@@ -44,40 +42,40 @@ namespace StgSharp.Geometries
internal Vec3 vec1; internal Vec3 vec1;
internal Vec3 vec2; internal Vec3 vec2;
public Plain( Vec3 o, Vec3 v1, Vec3 v2 ) public Plain(Vec3 o, Vec3 v1, Vec3 v2)
{ {
this._origin = o; this._origin = o;
this.vec1 = v1 - ( v2 * ( v1.Y / v2.Y ) ); //xz this.vec1 = v1 - (v2 * (v1.Y / v2.Y)); //xz
this.vec2 = v2 - ( vec1 * ( v2.X / v1.X ) ); //yz this.vec2 = v2 - (vec1 * (v2.X / v1.X)); //yz
//|_origin|-k1*|vec1|-k2*|vec2| --> plainParameter.Z; // |_origin|-k1*|vec1|-k2*|vec2| --> plainParameter.Z;
plainParameter.Z = _origin.Z - ( vec1.Z * ( _origin.X / vec1.X ) ) - ( vec2.Z * ( _origin.Y / vec2.Y ) ); plainParameter.Z = _origin.Z - (vec1.Z * (_origin.X / vec1.X)) - (vec2.Z * (_origin.Y / vec2.Y));
//plainParameter.Z -> plainParameter.X, plainParameter.Y // plainParameter.Z -> plainParameter.X, plainParameter.Y
plainParameter.X = vec1.X * ( vec1.Z / plainParameter.Z ); plainParameter.X = vec1.X * (vec1.Z / plainParameter.Z);
plainParameter.Y = vec2.Y * ( vec2.Z / plainParameter.Z ); plainParameter.Y = vec2.Y * (vec2.Z / plainParameter.Z);
plainParameter.X = 1 / plainParameter.X; plainParameter.X = 1 / plainParameter.X;
plainParameter.Y = 1 / plainParameter.Y; plainParameter.Y = 1 / plainParameter.Y;
plainParameter.Z = 1 / plainParameter.Z; plainParameter.Z = 1 / plainParameter.Z;
} }
public Plain( Point p1, Point p2, Point p3 ) public Plain(Point p1, Point p2, Point p3)
{ {
Vec3 origin = p1.Coord; Vec3 origin = p1.Coord;
Vec3 v1 = p2.Coord - origin; Vec3 v1 = p2.Coord - origin;
Vec3 v2 = p3.Coord - origin; Vec3 v2 = p3.Coord - origin;
vec1 = v1 - ( v2 * ( v1.Y / v2.Y ) ); //xz vec1 = v1 - (v2 * (v1.Y / v2.Y)); //xz
vec2 = v2 - ( vec1 * ( v2.X / v1.X ) ); //yz vec2 = v2 - (vec1 * (v2.X / v1.X)); //yz
//|_origin|-k1*|vec1|-k2*|vec2| --> plainParameter.Z; // |_origin|-k1*|vec1|-k2*|vec2| --> plainParameter.Z;
plainParameter.Z = origin.Z - ( vec1.Z * ( origin.X / vec1.X ) ) - ( vec2.Z * ( origin.Y / vec2.Y ) ); plainParameter.Z = origin.Z - (vec1.Z * (origin.X / vec1.X)) - (vec2.Z * (origin.Y / vec2.Y));
//plainParameter.Z --> plainParameter.X, plainParameter.Y // plainParameter.Z --> plainParameter.X, plainParameter.Y
plainParameter.X = vec1.X * ( vec1.Z / plainParameter.Z ); plainParameter.X = vec1.X * (vec1.Z / plainParameter.Z);
plainParameter.Y = vec2.Y * ( vec2.Z / plainParameter.Z ); plainParameter.Y = vec2.Y * (vec2.Z / plainParameter.Z);
plainParameter.X = 1 / plainParameter.X; plainParameter.X = 1 / plainParameter.X;
plainParameter.Y = 1 / plainParameter.Y; plainParameter.Y = 1 / plainParameter.Y;
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Polygon4.cs" // file="Polygon4"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Numerics; using System.Numerics;
@@ -38,30 +36,30 @@ namespace StgSharp.Geometries
public class Polygon4 : PlainGeometry public class Polygon4 : PlainGeometry
{ {
protected static int[] Indices = [0, 1, 2, 0, 2, 3]; protected static int[] Indices = [ 0, 1, 2, 0, 2, 3 ];
internal Polygon4() internal Polygon4()
: base( PlainCoordinate.StandardPlainCoordination ) : base(PlainCoordinate.StandardPlainCoordination)
{ {
vertexMat = new Vec4[4]; vertexMat = new Vec4[4];
} }
internal Polygon4( Vec4[] rawCoord ) internal Polygon4(Vec4[] rawCoord)
: base( PlainCoordinate.StandardPlainCoordination ) : base(PlainCoordinate.StandardPlainCoordination)
{ {
if( rawCoord.Length != 4 ) { if (rawCoord.Length != 4) {
throw new ArgumentOutOfRangeException( nameof( rawCoord ) ); throw new ArgumentOutOfRangeException(nameof(rawCoord));
} }
vertexMat = rawCoord; vertexMat = rawCoord;
} }
public Polygon4( Point topLeft, Point topRight, Point bottomRight, Point bottomLeft ) public Polygon4(Point topLeft, Point topRight, Point bottomRight, Point bottomLeft)
: base( PlainCoordinate.StandardPlainCoordination ) : base(PlainCoordinate.StandardPlainCoordination)
{ {
this[ 0 ] = topLeft; this[0] = topLeft;
this[ 1 ] = topRight; this[1] = topRight;
this[ 2 ] = bottomRight; this[2] = bottomRight;
this[ 3 ] = bottomLeft; this[3] = bottomLeft;
} }
public Polygon4( public Polygon4(
@@ -70,32 +68,24 @@ namespace StgSharp.Geometries
Point topLeft, Point topLeft,
Point topRight, Point topRight,
Point bottomRight, Point bottomRight,
Point bottomLeft ) Point bottomLeft)
: base( coordinate ) : base(coordinate)
{ {
this[ 0 ] = topLeft; this[0] = topLeft;
this[ 1 ] = topRight; this[1] = topRight;
this[ 2 ] = bottomRight; this[2] = bottomRight;
this[ 3 ] = bottomLeft; this[3] = bottomLeft;
} }
public Polygon4( public Polygon4(float v0x, float v0y, float v1x, float v1y, float v2x, float v2y, float v3x, float v3y)
float v0x, : base(PlainCoordinate.StandardPlainCoordination)
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
: base( PlainCoordinate.StandardPlainCoordination )
{ {
vertexMat = new Vec4[4]; vertexMat = new Vec4[4];
this[ 0 ] = new Point( v0x, v0y, 0 ); this[0] = new Point(v0x, v0y, 0);
this[ 1 ] = new Point( v1x, v1y, 0 ); this[1] = new Point(v1x, v1y, 0);
this[ 2 ] = new Point( v2x, v2y, 0 ); this[2] = new Point(v2x, v2y, 0);
this[ 3 ] = new Point( v3x, v3y, 0 ); this[3] = new Point(v3x, v3y, 0);
} }
public Polygon4( public Polygon4(
@@ -107,15 +97,15 @@ namespace StgSharp.Geometries
float v2x, float v2x,
float v2y, float v2y,
float v3x, float v3x,
float v3y ) float v3y)
: base( coordination ) : base(coordination)
{ {
vertexMat = new Vec4[4]; vertexMat = new Vec4[4];
this[ 0 ] = new Point( v0x, v0y, 0 ); this[0] = new Point(v0x, v0y, 0);
this[ 1 ] = new Point( v1x, v1y, 0 ); this[1] = new Point(v1x, v1y, 0);
this[ 2 ] = new Point( v2x, v2y, 0 ); this[2] = new Point(v2x, v2y, 0);
this[ 3 ] = new Point( v3x, v3y, 0 ); this[3] = new Point(v3x, v3y, 0);
} }
public override ReadOnlySpan<int> VertexIndices => Indices; public override ReadOnlySpan<int> VertexIndices => Indices;
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Polygon5.cs" // file="Polygon5"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Numerics; using System.Numerics;
@@ -38,10 +36,10 @@ namespace StgSharp.Geometries
public unsafe class Polygon5 : PlainGeometry public unsafe class Polygon5 : PlainGeometry
{ {
internal static int[] Indices = [0, 1, 2, 0, 2, 3, 0, 3, 4]; internal static int[] Indices = [ 0, 1, 2, 0, 2, 3, 0, 3, 4 ];
public unsafe Polygon5() public unsafe Polygon5()
: base( PlainCoordinate.StandardPlainCoordination ) : base(PlainCoordinate.StandardPlainCoordination)
{ {
vertexMat = new Vec4[5]; vertexMat = new Vec4[5];
} }
@@ -56,15 +54,15 @@ namespace StgSharp.Geometries
float v3x, float v3x,
float v3y, float v3y,
float v4x, float v4x,
float v4y ) float v4y)
: base( PlainCoordinate.StandardPlainCoordination ) : base(PlainCoordinate.StandardPlainCoordination)
{ {
vertexMat = new Vec4[5]; vertexMat = new Vec4[5];
this[ 0 ] = new Point( v0x, v0y, 0 ); this[0] = new Point(v0x, v0y, 0);
this[ 1 ] = new Point( v1x, v1y, 0 ); this[1] = new Point(v1x, v1y, 0);
this[ 2 ] = new Point( v2x, v2y, 0 ); this[2] = new Point(v2x, v2y, 0);
this[ 3 ] = new Point( v3x, v3y, 0 ); this[3] = new Point(v3x, v3y, 0);
this[ 4 ] = new Point( v4x, v4y, 0 ); this[4] = new Point(v4x, v4y, 0);
} }
public Polygon5( public Polygon5(
@@ -78,15 +76,15 @@ namespace StgSharp.Geometries
float v3x, float v3x,
float v3y, float v3y,
float v4x, float v4x,
float v4y ) float v4y)
: base( coordination ) : base(coordination)
{ {
vertexMat = new Vec4[5]; vertexMat = new Vec4[5];
this[ 0 ] = new Point( v0x, v0y, 0 ); this[0] = new Point(v0x, v0y, 0);
this[ 1 ] = new Point( v1x, v1y, 0 ); this[1] = new Point(v1x, v1y, 0);
this[ 2 ] = new Point( v2x, v2y, 0 ); this[2] = new Point(v2x, v2y, 0);
this[ 3 ] = new Point( v3x, v3y, 0 ); this[3] = new Point(v3x, v3y, 0);
this[ 4 ] = new Point( v4x, v4y, 0 ); this[4] = new Point(v4x, v4y, 0);
} }
public override ReadOnlySpan<int> VertexIndices => Indices; public override ReadOnlySpan<int> VertexIndices => Indices;
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Polygon6.cs" // file="Polygon6"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Numerics; using System.Numerics;
@@ -38,7 +36,7 @@ namespace StgSharp.Geometries
public class Polygon6 : PlainGeometry public class Polygon6 : PlainGeometry
{ {
internal static int[] Indices = [0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5]; internal static int[] Indices = [ 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5 ];
public Polygon6() public Polygon6()
: base(PlainCoordinate.StandardPlainCoordination) : base(PlainCoordinate.StandardPlainCoordination)
@@ -1,34 +1,35 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Rectangle.cs" // file="Rectangle.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Numerics; using System.Numerics;
@@ -38,18 +39,10 @@ namespace StgSharp.Geometries
public class Rectangle : Parallelogram public class Rectangle : Parallelogram
{ {
public Rectangle( public Rectangle(float v0x, float v0y, float v1x, float v1y, float v2x, float v2y, float v3x, float v3y)
float v0x, : base(v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y)
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
: base( v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y )
{ {
#if DEBUG #if DEBUG
Vec2 side0 = ( this[ 0 ].Coord - this[ 1 ].Coord ).XY; Vec2 side0 = ( this[ 0 ].Coord - this[ 1 ].Coord ).XY;
Vec2 side1 = ( this[ 2 ].Coord - this[ 1 ].Coord ).XY; Vec2 side1 = ( this[ 2 ].Coord - this[ 1 ].Coord ).XY;
if( side0.Cross( side1 ) == 0 ) { if( side0.Cross( side1 ) == 0 ) {
@@ -67,10 +60,10 @@ namespace StgSharp.Geometries
float v2x, float v2x,
float v2y, float v2y,
float v3x, float v3x,
float v3y ) float v3y)
: base( coordination, v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y ) : base(coordination, v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y)
{ {
#if DEBUG #if DEBUG
Vec2 side0 = ( this[ 0 ].Coord - this[ 1 ].Coord ).XY; Vec2 side0 = ( this[ 0 ].Coord - this[ 1 ].Coord ).XY;
Vec2 side1 = ( this[ 2 ].Coord - this[ 1 ].Coord ).XY; Vec2 side1 = ( this[ 2 ].Coord - this[ 1 ].Coord ).XY;
if( side0.Cross( side1 ) == 0 ) { if( side0.Cross( side1 ) == 0 ) {
@@ -88,9 +81,9 @@ namespace StgSharp.Geometries
/// <returns> /// <returns>
/// ///
/// </returns> /// </returns>
public virtual Vec3 MovCenter( uint tick ) public virtual Vec3 MovCenter(uint tick)
{ {
return default( Vec3 ); return default(Vec3);
} }
} }
@@ -1,35 +1,36 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Triangle.cs" // file="Triangle.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Numerics; using System.Numerics;
@@ -39,55 +40,44 @@ namespace StgSharp.Geometries
public unsafe class Triangle : PlainGeometry public unsafe class Triangle : PlainGeometry
{ {
internal static int[] Indices = [0, 1, 2]; internal static int[] Indices = [ 0, 1, 2 ];
public Triangle() public Triangle()
: base( PlainCoordinate.StandardPlainCoordination ) : base(PlainCoordinate.StandardPlainCoordination)
{ {
vertexMat = new Vec4[3]; vertexMat = new Vec4[3];
} }
public Triangle( Point vertex01, Point vertex02, Point vertex03 ) public Triangle(Point vertex01, Point vertex02, Point vertex03)
: base( PlainCoordinate.StandardPlainCoordination ) : base(PlainCoordinate.StandardPlainCoordination)
{ {
this[ 0 ] = vertex01; this[0] = vertex01;
this[ 1 ] = vertex02; this[1] = vertex02;
this[ 2 ] = vertex03; this[2] = vertex03;
} }
public Triangle( public Triangle(PlainCoordinate coordination, Point vertex01, Point vertex02, Point vertex03)
PlainCoordinate coordination, : base(coordination)
Point vertex01,
Point vertex02,
Point vertex03 )
: base( coordination )
{ {
this[ 0 ] = vertex01; this[0] = vertex01;
this[ 1 ] = vertex02; this[1] = vertex02;
this[ 2 ] = vertex03; this[2] = vertex03;
} }
public Triangle( float v0x, float v0y, float v1x, float v1y, float v2x, float v2y ) public Triangle(float v0x, float v0y, float v1x, float v1y, float v2x, float v2y)
: base( PlainCoordinate.StandardPlainCoordination ) : base(PlainCoordinate.StandardPlainCoordination)
{ {
this[ 0 ] = new Point( v0x, v0y, 0 ); this[0] = new Point(v0x, v0y, 0);
this[ 1 ] = new Point( v1x, v1y, 0 ); this[1] = new Point(v1x, v1y, 0);
this[ 2 ] = new Point( v2x, v2y, 0 ); this[2] = new Point(v2x, v2y, 0);
} }
public Triangle( public Triangle(PlainCoordinate coordination, float v0x, float v0y, float v1x, float v1y, float v2x, float v2y)
PlainCoordinate coordination, : base(coordination)
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y )
: base( coordination )
{ {
this[ 0 ] = new Point( v0x, v0y, 0 ); this[0] = new Point(v0x, v0y, 0);
this[ 1 ] = new Point( v1x, v1y, 0 ); this[1] = new Point(v1x, v1y, 0);
this[ 2 ] = new Point( v2x, v2y, 0 ); this[2] = new Point(v2x, v2y, 0);
} }
public override ReadOnlySpan<int> VertexIndices => Indices; public override ReadOnlySpan<int> VertexIndices => Indices;
+19 -21
View File
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Point.cs" // file="Point"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -1,40 +1,38 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="TriangulatedSurface.cs" // file="TriangulatedSurface"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.HighPerformance; using StgSharp.HighPerformance;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.HighPrecision; using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Intrinsics; using System.Runtime.Intrinsics;
using System.Text; using System.Text;
@@ -61,6 +59,7 @@ namespace StgSharp.Geometries
/**/ /**/
public IEnumerable<List<int>> SideIndicesEnumeratble public IEnumerable<List<int>> SideIndicesEnumeratble
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _sideIndices ; get => _sideIndices ;
} }
@@ -78,11 +77,13 @@ namespace StgSharp.Geometries
public Span<Vec3> VertexSpan public Span<Vec3> VertexSpan
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => CollectionsMarshal.AsSpan(_vertices); get => CollectionsMarshal.AsSpan(_vertices);
} }
public Span<int> TriangleIndicesSpan public Span<int> TriangleIndicesSpan
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => CollectionsMarshal.AsSpan(_triangleIndices); get => CollectionsMarshal.AsSpan(_triangleIndices);
} }
@@ -93,13 +94,13 @@ namespace StgSharp.Geometries
_triangleIndices.Add(v2); _triangleIndices.Add(v2);
_triangleIndices.Add(v3); _triangleIndices.Add(v3);
if (!(_sides.Remove((v1,v2)) || _sides.Remove((v2, v1)))) { if (!(_sides.Remove((v1,v2)) || _sides.Remove((v2, v1)))) {
_sides.Add((v1, v2)); _ = _sides.Add((v1, v2));
} }
if (!(_sides.Remove((v2, v3)) || _sides.Remove((v3, v2)))) { if (!(_sides.Remove((v2, v3)) || _sides.Remove((v3, v2)))) {
_sides.Add((v2, v3)); _ = _sides.Add((v2, v3));
} }
if (!(_sides.Remove((v3, v1)) || _sides.Remove((v1, v3)))) { if (!(_sides.Remove((v3, v1)) || _sides.Remove((v1, v3)))) {
_sides.Add((v3, v1)); _ = _sides.Add((v3, v1));
} }
} }
@@ -119,7 +120,7 @@ namespace StgSharp.Geometries
_vertices.TrimExcess(); _vertices.TrimExcess();
Dictionary<int, int> side_dictionary = _sides.ToDictionary(x => x.begin, x => x.end); Dictionary<int, int> side_dictionary = _sides.ToDictionary(x => x.begin, x => x.end);
int begin = side_dictionary.First().Key; int begin = side_dictionary.First().Key;
List<int> sideLoop = new List<int>(begin); List<int> sideLoop = new(begin);
_sideIndices.Add(sideLoop); _sideIndices.Add(sideLoop);
while (side_dictionary.Count > 0) while (side_dictionary.Count > 0)
{ {
+25 -28
View File
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="VBO.cs" // file="VBO"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Numeric;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -79,11 +77,11 @@ namespace StgSharp.Graphics.OpenGL
/// <param _label="usage"> /// <param _label="usage">
/// How OpenGL use these _data, defined by <see cref="BufferUsage" /> /// How OpenGL use these _data, defined by <see cref="BufferUsage" />
/// </param> /// </param>
public void WriteMatrixData<T>(int index, T bufferData, BufferUsage usage) public void WriteMatrixData<T>(int index, ref IMatrix<T> bufferData, BufferUsage usage)
where T: unmanaged, IMatrix<T> where T: unmanaged, INumber<T>
{ {
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]); GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
GL.SetBufferData(BufferType.ArrayBuffer, bufferData, usage); GL.SetBufferData(BufferType.ArrayBuffer, bufferData.AsSpan(), usage);
} }
/// <summary> /// <summary>
@@ -101,8 +99,7 @@ namespace StgSharp.Graphics.OpenGL
/// <param _label="usage"> /// <param _label="usage">
/// How OpenGL use these _data, defined by <see cref="BufferUsage" /> /// How OpenGL use these _data, defined by <see cref="BufferUsage" />
/// </param> /// </param>
public void WriteScalerData<T>(int index, T[] bufferArray, BufferUsage usage) public void WriteScalerData<T>(int index, T[] bufferArray, BufferUsage usage) where T: unmanaged, INumber<T>
where T: unmanaged, INumber<T>
{ {
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]); GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
GL.SetBufferData(BufferType.ArrayBuffer, bufferArray, usage); GL.SetBufferData(BufferType.ArrayBuffer, bufferArray, usage);
@@ -146,7 +143,7 @@ namespace StgSharp.Graphics.OpenGL
/// How OpenGL use these data, defined by <see cref="BufferUsage" /> /// How OpenGL use these data, defined by <see cref="BufferUsage" />
/// </param> /// </param>
public void WriteVectorData<T>(int index, ReadOnlySpan<T> vectorSpan, BufferUsage usage) public void WriteVectorData<T>(int index, ReadOnlySpan<T> vectorSpan, BufferUsage usage)
where T: unmanaged, IFixedVector<T> where T: unmanaged, IUnmanagedVector<T>
{ {
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]); GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
GL.SetBufferVectorData(BufferType.ArrayBuffer, vectorSpan, usage); GL.SetBufferVectorData(BufferType.ArrayBuffer, vectorSpan, usage);
@@ -168,7 +165,7 @@ namespace StgSharp.Graphics.OpenGL
/// How OpenGL use these _data, defined by <see cref="BufferUsage" /> /// How OpenGL use these _data, defined by <see cref="BufferUsage" />
/// </param> /// </param>
public void WriteVectorData<T>(int index, T[] vectorArray, BufferUsage usage) public void WriteVectorData<T>(int index, T[] vectorArray, BufferUsage usage)
where T: unmanaged, IFixedVector<T> where T: unmanaged, IUnmanagedVector<T>
{ {
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]); GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
GL.SetBufferVectorData(BufferType.ArrayBuffer, vectorArray, usage); GL.SetBufferVectorData(BufferType.ArrayBuffer, vectorArray, usage);
+41 -84
View File
@@ -1,36 +1,34 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="glFunction.cs" // file="glFunction"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Internal; using StgSharp.Internal;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Numeric;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@@ -62,9 +60,7 @@ namespace StgSharp.Graphics.OpenGL
unusedTextureImageUintInitilizing = new Lazy<ConcurrentQueue<TextureUnit>>( unusedTextureImageUintInitilizing = new Lazy<ConcurrentQueue<TextureUnit>>(
InitializeUnusedTextureImageUint); InitializeUnusedTextureImageUint);
_attachmentColorRange = new Lazy<int>( _attachmentColorRange = new Lazy<int>(
() => { () => { return GetMaskInteger((uint)glConst.MAX_COLOR_ATTACHMENTS); });
return GetMaskInteger((uint)glConst.MAX_COLOR_ATTACHMENTS);
});
} }
public int AttachmentColorRange public int AttachmentColorRange
@@ -126,7 +122,7 @@ namespace StgSharp.Graphics.OpenGL
/// <summary> /// <summary>
/// Bind a frame BufferHandle to a frame BufferHandle target Same function as <see /// Bind a frame BufferHandle to a frame BufferHandle target Same function as <see
/// href="https://docs._gl/gl3/glBindFramebuffer"> glBindFramebuffer </see>. /// href="https://docs._gl/gl3/glBindFramebuffer">glBindFramebuffer</see>.
/// </summary> /// </summary>
/// <param _label="target"> /// <param _label="target">
/// The frame BufferHandle target of the binding operation. /// The frame BufferHandle target of the binding operation.
@@ -202,9 +198,7 @@ namespace StgSharp.Graphics.OpenGL
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void CombineFrameBufferRenderBuffer( public void CombineFrameBufferRenderBuffer(FrameBufferAttachment attachment, GlHandle rboHandle)
FrameBufferAttachment attachment,
GlHandle rboHandle)
{ {
Context.glFramebufferRenderbuffer( Context.glFramebufferRenderbuffer(
glConst.FRAMEBUFFER, (uint)attachment, glConst.RENDERBUFFER, rboHandle.Value); glConst.FRAMEBUFFER, (uint)attachment, glConst.RENDERBUFFER, rboHandle.Value);
@@ -279,9 +273,8 @@ namespace StgSharp.Graphics.OpenGL
/// <summary> /// <summary>
/// Delete a render BufferHandle object Very simlilar function as <see /// Delete a render BufferHandle object Very simlilar function as <see
/// href="https://docs.gl/gl3/glDeleteRenderbuffers"> glDeleteRenderbuffers </see>. The /// href="https://docs.gl/gl3/glDeleteRenderbuffers">glDeleteRenderbuffers</see>. The only
/// only deifference is that this mehtod can only delete one renderbuffer at the same /// deifference is that this mehtod can only delete one renderbuffer at the same time.
/// time.
/// </summary> /// </summary>
/// <param _label="bufferHandle"> /// <param _label="bufferHandle">
/// Handle to BufferHandle to delete. /// Handle to BufferHandle to delete.
@@ -336,12 +329,7 @@ namespace StgSharp.Graphics.OpenGL
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void DrawElementsInstanced( public void DrawElementsInstanced(GeometryType mode, uint count, TypeCode type, IntPtr ptr, uint amount)
GeometryType mode,
uint count,
TypeCode type,
IntPtr ptr,
uint amount)
{ {
uint a; uint a;
switch (type) switch (type)
@@ -458,8 +446,7 @@ namespace StgSharp.Graphics.OpenGL
{ {
IntPtr sptr = IntPtr.Zero; IntPtr sptr = IntPtr.Zero;
if (InternalIO.glCheckShaderStatus(ref Context, s.handle[index].Value, key, if (InternalIO.glCheckShaderStatus(ref Context, s.handle[index].Value, key,
ref sptr) == ref sptr) == 0) {
0) {
return Marshal.PtrToStringAnsi(sptr); return Marshal.PtrToStringAnsi(sptr);
} }
return string.Empty; return string.Empty;
@@ -484,11 +471,7 @@ namespace StgSharp.Graphics.OpenGL
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void GetTextureLevelProperty( public void GetTextureLevelProperty(uint textureTypeMask, int level, uint propertyMask, out int propertyValue)
uint textureTypeMask,
int level,
uint propertyMask,
out int propertyValue)
{ {
fixed (int* iptr = &propertyValue) { fixed (int* iptr = &propertyValue) {
Context.glGetTexLevelParameteriv(textureTypeMask, level, propertyMask, iptr); Context.glGetTexLevelParameteriv(textureTypeMask, level, propertyMask, iptr);
@@ -563,8 +546,7 @@ namespace StgSharp.Graphics.OpenGL
{ {
fixed (byte* bptr = stream) { fixed (byte* bptr = stream) {
Context.glReadPixels( Context.glReadPixels(
beginPosition.X, beginPosition.Y, size.width, size.height, (uint)format, beginPosition.X, beginPosition.Y, size.width, size.height, (uint)format, (uint)dataType, bptr);
(uint)dataType, bptr);
} }
} }
@@ -580,15 +562,14 @@ namespace StgSharp.Graphics.OpenGL
} }
fixed (byte* bptr = pixels) { fixed (byte* bptr = pixels) {
Context.glReadPixels( Context.glReadPixels(
beginPosition.X, beginPosition.Y, i.Width, i.Height, (uint)format, beginPosition.X, beginPosition.Y, i.Width, i.Height, (uint)format, (uint)dataType, bptr);
(uint)dataType, bptr);
} }
i.PixelUpdateCount++; i.PixelUpdateCount++;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void SetBufferData<T>(BufferType bufferType, T bufferData, BufferUsage usage) public unsafe void SetBufferData<T>(BufferType bufferType, T bufferData, BufferUsage usage)
where T: unmanaged where T: unmanaged,INumber<T>
{ {
int size = Marshal.SizeOf<T>(); int size = Marshal.SizeOf<T>();
#pragma warning disable CS8500 #pragma warning disable CS8500
@@ -598,10 +579,7 @@ namespace StgSharp.Graphics.OpenGL
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void SetBufferData<T>( public unsafe void SetBufferData<T>(BufferType bufferType, T[] bufferArray, BufferUsage usage)
BufferType bufferType,
T[] bufferArray,
BufferUsage usage)
where T: unmanaged,INumber<T> where T: unmanaged,INumber<T>
{ {
int size = bufferArray.Length * Marshal.SizeOf(typeof(T)); int size = bufferArray.Length * Marshal.SizeOf(typeof(T));
@@ -618,10 +596,7 @@ namespace StgSharp.Graphics.OpenGL
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void SetBufferData<T>( public unsafe void SetBufferData<T>(BufferType bufferType, ReadOnlySpan<T> bufferSpan, BufferUsage usage)
BufferType bufferType,
ReadOnlySpan<T> bufferSpan,
BufferUsage usage)
where T: unmanaged,INumber<T> where T: unmanaged,INumber<T>
{ {
int size = bufferSpan.Length * Marshal.SizeOf(typeof(T)); int size = bufferSpan.Length * Marshal.SizeOf(typeof(T));
@@ -638,10 +613,7 @@ namespace StgSharp.Graphics.OpenGL
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void SetBufferData<T>( public unsafe void SetBufferData<T>(BufferType bufferType, Span<T> bufferArray, BufferUsage usage)
BufferType bufferType,
Span<T> bufferArray,
BufferUsage usage)
where T: unmanaged, INumber<T> where T: unmanaged, INumber<T>
{ {
int size = bufferArray.Length * Marshal.SizeOf(typeof(T)); int size = bufferArray.Length * Marshal.SizeOf(typeof(T));
@@ -659,11 +631,8 @@ namespace StgSharp.Graphics.OpenGL
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void SetBufferVectorData<T>( public unsafe void SetBufferVectorData<T>(BufferType bufferType, ReadOnlySpan<T> bufferSpan, BufferUsage usage)
BufferType bufferType, where T: unmanaged, IUnmanagedVector<T>
ReadOnlySpan<T> bufferSpan,
BufferUsage usage)
where T: unmanaged, IFixedVector<T>
{ {
int size = bufferSpan.Length * Marshal.SizeOf(typeof(T)); int size = bufferSpan.Length * Marshal.SizeOf(typeof(T));
#pragma warning disable CS8500 #pragma warning disable CS8500
@@ -676,11 +645,8 @@ namespace StgSharp.Graphics.OpenGL
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void SetBufferVectorData<T>( public unsafe void SetBufferVectorData<T>(BufferType bufferType, T[] bufferArray, BufferUsage usage)
BufferType bufferType, where T: unmanaged, IUnmanagedVector<T>
T[] bufferArray,
BufferUsage usage)
where T: unmanaged, IFixedVector<T>
{ {
int size = bufferArray.Length * Marshal.SizeOf(typeof(T)); int size = bufferArray.Length * Marshal.SizeOf(typeof(T));
if (bufferArray == null) { if (bufferArray == null) {
@@ -714,17 +680,10 @@ namespace StgSharp.Graphics.OpenGL
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetVertexAttribute( public void SetVertexAttribute(uint index, int size, TypeCode t, bool normalized, uint stride, int pointer)
uint index,
int size,
TypeCode t,
bool normalized,
uint stride,
int pointer)
{ {
uint type = InternalIO.GLtype[t]; uint type = InternalIO.GLtype[t];
Context.glVertexAttribPointer( Context.glVertexAttribPointer(index, size, type, normalized ? 1 : 0, stride, (void*)pointer);
index, size, type, normalized ? 1 : 0, stride, (void*)pointer);
Context.glEnableVertexAttribArray(index); Context.glEnableVertexAttribArray(index);
} }
@@ -745,8 +704,7 @@ namespace StgSharp.Graphics.OpenGL
{ {
T* ptr = ((pixels == null) || (pixels.Length == 0)) ? (T*)IntPtr.Zero : tptr; T* ptr = ((pixels == null) || (pixels.Length == 0)) ? (T*)IntPtr.Zero : tptr;
Context.glTexImage2D( Context.glTexImage2D(
(uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel, (uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel, (uint)type, tptr);
(uint)type, tptr);
} }
#pragma warning restore CS8500 #pragma warning restore CS8500
} }
@@ -767,8 +725,7 @@ namespace StgSharp.Graphics.OpenGL
fixed (T* tptr = pixelSpan) fixed (T* tptr = pixelSpan)
{ {
Context.glTexImage2D( Context.glTexImage2D(
(uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel, (uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel, (uint)type, tptr);
(uint)type, tptr);
} }
#pragma warning restore CS8500 #pragma warning restore CS8500
} }
@@ -1,34 +1,32 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="glRenderStream.cs" // file="glRenderStream"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using StgSharp.Threading; using StgSharp.Threading;
using System; using System;
@@ -137,9 +135,7 @@ namespace StgSharp.Graphics.OpenGL
CustomizeDeinit(); CustomizeDeinit();
} }
protected sealed override Uniform<Matrix44> NativeCameraUniform( protected sealed override Uniform<Matrix44> NativeCameraUniform(ShaderProgram source, string name)
ShaderProgram source,
string name)
{ {
NativeCamera.GainAllUniforms(source, name); NativeCamera.GainAllUniforms(source, name);
return NativeCamera.convertedUniform; return NativeCamera.convertedUniform;
@@ -155,10 +151,7 @@ namespace StgSharp.Graphics.OpenGL
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
protected sealed override void NativeCameraViewTarget( protected sealed override void NativeCameraViewTarget(Vec3 position, Vec3 direction, Vec3 up)
Vec3 position,
Vec3 direction,
Vec3 up)
{ {
NativeCamera.SetViewDirection(position, direction, up); NativeCamera.SetViewDirection(position, direction, up);
} }
+19 -21
View File
@@ -1,35 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="PlainGeometryMesh.cs" // file="PlainGeometryMesh"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Geometries; using StgSharp.Geometries;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
+27 -24
View File
@@ -1,36 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="RenderStream.cs" // file="RenderStream"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Graphics.OpenGL; using StgSharp.Graphics.OpenGL;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using StgSharp.MVVM; using StgSharp.MVVM;
using StgSharp.Timing; using StgSharp.Timing;
@@ -56,6 +53,7 @@ namespace StgSharp.Graphics
public (int width, int height) Size public (int width, int height) Size
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => (Width, Height); get => (Width, Height);
} }
@@ -63,6 +61,7 @@ namespace StgSharp.Graphics
public int Height public int Height
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => primeArgs.Height; get => primeArgs.Height;
} }
@@ -90,6 +89,7 @@ namespace StgSharp.Graphics
internal IntPtr CanvasHandle internal IntPtr CanvasHandle
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => primeArgs.ViewPortHandle; get => primeArgs.ViewPortHandle;
} }
@@ -107,21 +107,25 @@ namespace StgSharp.Graphics
protected float FramePassed protected float FramePassed
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _timeProvider.CurrentSpan; get => _timeProvider.CurrentSpan;
} }
protected int PassedFrames protected int PassedFrames
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _timeProvider.CurrentSpan; get => _timeProvider.CurrentSpan;
} }
protected float TimePassed protected float TimePassed
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _timeProvider.CurrentSecond; get => _timeProvider.CurrentSecond;
} }
protected TimeSpanProvider TimeProvider protected TimeSpanProvider TimeProvider
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _timeProvider; get => _timeProvider;
} }
@@ -143,8 +147,7 @@ namespace StgSharp.Graphics
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public abstract void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight); public abstract void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight);
public static TTarget ShareContextFrom<TSource, TTarget>([NotNull]TSource source) public static TTarget ShareContextFrom<TSource, TTarget>([NotNull]TSource source) where TSource: RenderStream
where TSource: RenderStream
where TTarget: RenderStream, new() where TTarget: RenderStream, new()
{ {
TTarget target = new TTarget(); TTarget target = new TTarget();
+35 -38
View File
@@ -1,40 +1,37 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="TextureProvider.cs" // file="TextureProvider.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction, // files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, // including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, // publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, // and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// //
// The above copyright notice and // The above copyright notice and
// this permission notice shall be included in all copies // this permission notice shall be included in all copies
// or substantial portions of the Software. // or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED “AS IS”, // THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH // ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics.Graphic;
using System; using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Text;
namespace StgSharp.Graphics namespace StgSharp.Graphics
{ {
@@ -44,20 +41,20 @@ namespace StgSharp.Graphics
private Vec2[] _texCoord; private Vec2[] _texCoord;
private Image _tex; private Image _tex;
public TextureProvider( Image image, Vec2[] coord ) public TextureProvider(Image image, Vec2[] coord)
{ {
_tex = image; _tex = image;
_texCoord = coord; _texCoord = coord;
} }
public ref Vec2 this[ int index ] public ref Vec2 this[int index]
{ {
get => ref _texCoord[ index ]; get => ref _texCoord[index];
} }
public Span<Vec2> TextureCoordinate public Span<Vec2> TextureCoordinate
{ {
get => new Span<Vec2>( _texCoord ); get => new Span<Vec2>(_texCoord);
} }
public Image ProvideImage() public Image ProvideImage()
@@ -65,23 +62,23 @@ namespace StgSharp.Graphics
return _tex; return _tex;
} }
public void ReadImage( IImageProvider provider ) public void ReadImage(IImageProvider provider)
{ {
_tex = provider.ProvideImage(); _tex = provider.ProvideImage();
} }
public void UpdateFromImage( [NotNull]Image i ) public void UpdateFromImage([NotNull]Image i)
{ {
if( i == _tex ) { if (i == _tex) {
return; return;
} }
if( i.Size == _tex.Size ) if (i.Size == _tex.Size)
{ {
_tex = i; _tex = i;
} else } else
{ {
throw new ArgumentException( throw new ArgumentException(
$"Size of {nameof(i)} does not equals to current image." ); $"Size of {nameof(i)} does not equals to current image.");
} }
} }
+25 -27
View File
@@ -1,30 +1,27 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="ViewModel.cs" // file="ViewModel"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -32,6 +29,7 @@ using StgSharp.Controlling.UsrActivity;
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Graphics.OpenGL; using StgSharp.Graphics.OpenGL;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using StgSharp.MVVM; using StgSharp.MVVM;
using StgSharp.MVVM.ViewModel; using StgSharp.MVVM.ViewModel;
using StgSharp.Threading; using StgSharp.Threading;
@@ -142,7 +140,7 @@ namespace StgSharp.MVVM.ViewModel
/// </summary> /// </summary>
public int Height public int Height
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
get => viewPortDisplay.Height; get => viewPortDisplay.Height;
} }
@@ -151,19 +149,19 @@ namespace StgSharp.MVVM.ViewModel
/// </summary> /// </summary>
public int Width public int Width
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
get => viewPortDisplay.Width; get => viewPortDisplay.Width;
} }
public unsafe IntPtr WindowID public unsafe IntPtr WindowID
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
get => viewPortDisplay.ViewPortHandle; get => viewPortDisplay.ViewPortHandle;
} }
public string Name public string Name
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
get => viewPortDisplay.Name; get => viewPortDisplay.Name;
} }
@@ -172,13 +170,13 @@ namespace StgSharp.MVVM.ViewModel
/// </summary> /// </summary>
public Vec2 Size public Vec2 Size
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
get => new Vec2(Width, Height); get => new Vec2(Width, Height);
} }
public ViewPort ViewPortBinding public ViewPort ViewPortBinding
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
get => viewPortDisplay; get => viewPortDisplay;
} }
@@ -1,33 +1,30 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Cordination.cs" // file="Cordination"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
namespace StgSharp.Mathematics.Numeric namespace StgSharp.Mathematics.Numeric
{ {
public enum CoordinatePlain public enum CoordinatePlain
@@ -1,6 +1,6 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="IFixedVector.cs" // file="IUnmanagedVector.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
+36 -34
View File
@@ -1,35 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Bullet.cs" // file="Bullet"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// //
// The above copyright notice and // -----------------------------------------------------------------------
// this permission notice shall be included in all copies // -----------------------------------------------------------------------
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Geometries; using StgSharp.Geometries;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System; using System;
@@ -43,14 +41,14 @@ namespace StgSharp.Gaming
GeometryMotion movement, GeometryMotion movement,
Vec2 beginPosition, Vec2 beginPosition,
float angle, float angle,
float scale ) float scale)
{ {
ArgumentNullException.ThrowIfNull( buffer ); ArgumentNullException.ThrowIfNull(buffer);
GlobalBuffer = buffer; GlobalBuffer = buffer;
BufferId = buffer.CreateInstanceID(); BufferId = buffer.CreateInstanceID();
( ( IInstancing )this ).Scale = scale; ((IInstancing)this).Scale = scale;
( ( IInstancing )this ).Coord = new Vec3( beginPosition, 0 ); ((IInstancing)this).Coord = new Vec3(beginPosition, 0);
( ( IInstancing )this ).Rotation = angle; ((IInstancing)this).Rotation = angle;
Motion = movement; Motion = movement;
} }
@@ -62,12 +60,16 @@ namespace StgSharp.Gaming
public Vec2 CenterPosition { get; set; } public Vec2 CenterPosition { get; set; }
public bool CollideWith( IPlainEntity entity ) public bool CollideWith(IPlainEntity entity)
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
Vec3 IInstancing.CenterPositionGlobal { get; set; } Vec3 IInstancing.CenterPositionGlobal
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
} }
} }
+22 -26
View File
@@ -1,30 +1,27 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="CollisionTexture.cs" // file="CollisionTexture"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -34,6 +31,7 @@ using StgSharp.Graphics.OpenGL;
using StgSharp.Internal; using StgSharp.Internal;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using StgSharp.MVVM; using StgSharp.MVVM;
using System; using System;
@@ -94,8 +92,7 @@ namespace StgSharp.Stg
vbo.WriteVectorData<Vec4>(0, item.CoordAndRotationSpan, BufferUsage.StreamDraw); vbo.WriteVectorData<Vec4>(0, item.CoordAndRotationSpan, BufferUsage.StreamDraw);
vao.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0); vao.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
vao.SetVertexAttribute( vao.SetVertexAttribute(2, 1, TypeCode.Single, false, 4 * sizeof(float), 3 * sizeof(float));
2, 1, TypeCode.Single, false, 4 * sizeof(float), 3 * sizeof(float));
vbo.WriteScalerData<float>(2, item.ScalingSpan, BufferUsage.StreamDraw); vbo.WriteScalerData<float>(2, item.ScalingSpan, BufferUsage.StreamDraw);
vao.SetVertexAttribute(3, 1, TypeCode.Single, false, sizeof(float), 0); vao.SetVertexAttribute(3, 1, TypeCode.Single, false, sizeof(float), 0);
@@ -159,9 +156,8 @@ namespace StgSharp.Stg
t = CreateTexture(1); t = CreateTexture(1);
t.Bind2D(0); t.Bind2D(0);
GL.TextureImage2d<byte>( GL.TextureImage2d<byte>(
Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, (uint)Height,
(uint)Height, ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, Array.Empty<byte>());
Array.Empty<byte>());
t.Set2dWrapProperty(0, TextureWrap.Repeat, TextureWrap.Repeat); t.Set2dWrapProperty(0, TextureWrap.Repeat, TextureWrap.Repeat);
t.Set2dFilterProperty(0, TextureFilter.Nearest, TextureFilter.Nearest); t.Set2dFilterProperty(0, TextureFilter.Nearest, TextureFilter.Nearest);
+2 -6
View File
@@ -29,7 +29,7 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using StgSharp.Model.Step; using StgSharp.Model.Step;
using StgSharp.Script; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
@@ -79,11 +79,7 @@ namespace StgSharp.Model.Step
return false; return false;
} }
return ItemType == other.ItemType && return ItemType == other.ItemType && X == other.X && Y == other.Y && Z == other.Z && Name == other.Name;
X == other.X &&
Y == other.Y &&
Z == other.Z &&
Name == other.Name;
} }
public override bool Equals(object obj) public override bool Equals(object obj)
+1
View File
@@ -29,6 +29,7 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using StgSharp.Model.Step; using StgSharp.Model.Step;
using StgSharp.Script; using StgSharp.Script;
using StgSharp.Script.Express; using StgSharp.Script.Express;
+2 -3
View File
@@ -31,6 +31,7 @@
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using StgSharp.Script.Express; using StgSharp.Script.Express;
using System; using System;
@@ -48,9 +49,7 @@ namespace StgSharp.Model.Step
private static Regex _vectorParser = GetVectorParser(); private static Regex _vectorParser = GetVectorParser();
private static Type _implementorInterface = typeof(IExpConvertableFrom<>); private static Type _implementorInterface = typeof(IExpConvertableFrom<>);
public static StepRepresentationItem Implement( public static StepRepresentationItem Implement(StepRepresentationItem left, StepRepresentationItem right)
StepRepresentationItem left,
StepRepresentationItem right)
{ {
Type tLeft = left.GetType(), Type tLeft = left.GetType(),
tRight = right.GetType(), tRight = right.GetType(),
+22 -22
View File
@@ -1,34 +1,33 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="MatrixParallelTest.cs" // file="MatrixParallelTest"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Numeric;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Threading; using System.Threading;
@@ -37,7 +36,7 @@ namespace StgSharp
{ {
internal partial class Program internal partial class Program
{ {
/*
public static void TestMatrixParallel() public static void TestMatrixParallel()
{ {
// 4. 线程调度基础功能测试 // 4. 线程调度基础功能测试
@@ -193,6 +192,7 @@ namespace StgSharp
Console.WriteLine($"? 基本调度操作测试失败: {ex.Message}"); Console.WriteLine($"? 基本调度操作测试失败: {ex.Message}");
} }
} }
/**/
} }
} }
+20 -21
View File
@@ -1,30 +1,27 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="MatrixParallelThreadTest.cs" // file="MatrixParallelThreadTest"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -34,6 +31,7 @@ using System.Threading;
namespace StgSharp namespace StgSharp
{ {
/*
/// <summary> /// <summary>
/// 矩阵计算并发调度器线程调度测试 修复的问题: 1. 添加了ResetThreadCount()方法,在每轮任务调度前重置线程计数 2. /// 矩阵计算并发调度器线程调度测试 修复的问题: 1. 添加了ResetThreadCount()方法,在每轮任务调度前重置线程计数 2.
/// 调度器线程不再递减RemainThreadCount,只有工作线程才递减 3. 改进了控制台输出,显示更清晰的线程活动信息 使用方法:在Program.cs的Main方法中调用 /// 调度器线程不再递减RemainThreadCount,只有工作线程才递减 3. 改进了控制台输出,显示更清晰的线程活动信息 使用方法:在Program.cs的Main方法中调用
@@ -114,4 +112,5 @@ namespace StgSharp
} }
} }
/**/
} }
+20 -22
View File
@@ -1,30 +1,27 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Program.cs" // file="Program"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -35,6 +32,7 @@ using StgSharp.Graphics;
using StgSharp.HighPerformance; using StgSharp.HighPerformance;
using StgSharp.HighPerformance.Memory; using StgSharp.HighPerformance.Memory;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Numeric;
using StgSharp.Model.Step; using StgSharp.Model.Step;
using StgSharp.MVVM; using StgSharp.MVVM;
using StgSharp.MVVM.ViewModel; using StgSharp.MVVM.ViewModel;
@@ -61,7 +59,7 @@ namespace StgSharp
{ {
World.Init(); World.Init();
TestMatrixParallel(); // TestMatrixParallel();
// 原有的矩阵测试代码 // 原有的矩阵测试代码
HybridLayerSegregatedFitAllocator hlsf = new HybridLayerSegregatedFitAllocator(64 * 400 * 400); HybridLayerSegregatedFitAllocator hlsf = new HybridLayerSegregatedFitAllocator(64 * 400 * 400);
+27 -34
View File
@@ -1,30 +1,27 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="Partical.cs" // file="Partical"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person obtaining a copy
// obtaining a copy of this software and associated documentation // of this software and associated documentation files (the "Software"), to deal
// files (the “Software”), to deal in the Software without restriction, // in the Software without restriction, including without limitation the rights
// including without limitation the rights to use, copy, modify, merge, // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// publish, distribute, sublicense, and/or sell copies of the Software, // copies of the Software, and to permit persons to whom the Software is
// and to permit persons to whom the Software is furnished to do so, // furnished to do so, subject to the following conditions:
// subject to the following conditions: //
// // The above copyright notice and this permission notice shall be included in all
// The above copyright notice and // copies or substantial portions of the Software.
// this permission notice shall be included in all copies //
// or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// THE SOFTWARE IS PROVIDED “AS IS”, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // SOFTWARE.
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -34,6 +31,7 @@ using StgSharp.Graphics;
using StgSharp.Graphics.OpenGL; using StgSharp.Graphics.OpenGL;
using StgSharp.Internal.OpenGL; using StgSharp.Internal.OpenGL;
using StgSharp.Mathematics; using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using StgSharp.Timing; using StgSharp.Timing;
using System; using System;
@@ -125,8 +123,8 @@ namespace StgSharp
/**/ /**/
GL.TextureImage2d<byte>( GL.TextureImage2d<byte>(
Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, (uint)Height,
(uint)Height, ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, null); ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, null);
/**/ /**/
// GL.Assert(false); // GL.Assert(false);
@@ -194,10 +192,7 @@ namespace StgSharp
GL.Assert(false); GL.Assert(false);
} }
public void RenderButton( public void RenderButton(ButtonStatus status, float statusBegin, in TextureProvider provider)
ButtonStatus status,
float statusBegin,
in TextureProvider provider)
{ {
provider.UpdateFromImage(i); provider.UpdateFromImage(i);
} }
@@ -269,8 +264,7 @@ namespace StgSharp
ebo = CreateElementBuffer(1); ebo = CreateElementBuffer(1);
vbo.Bind(0); vbo.Bind(0);
Rectangle rec = new Rectangle( Rectangle rec = new Rectangle(0.05f, 0.05f, 0.05f, -0.05f, -0.05f, -0.05f, -0.05f, 0.05f);
0.05f, 0.05f, 0.05f, -0.05f, -0.05f, -0.05f, -0.05f, 0.05f);
// GL.Assert(true); // GL.Assert(true);
vao.Bind(0); vao.Bind(0);
@@ -280,8 +274,7 @@ namespace StgSharp
vbo.WriteVectorData<Vec4>(1, buffer.CoordAndRotationSpan, BufferUsage.StreamDraw); vbo.WriteVectorData<Vec4>(1, buffer.CoordAndRotationSpan, BufferUsage.StreamDraw);
vao.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0); vao.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
vao.SetVertexAttribute( vao.SetVertexAttribute(2, 1, TypeCode.Single, false, 4 * sizeof(float), 3 * sizeof(float));
2, 1, TypeCode.Single, false, 4 * sizeof(float), 3 * sizeof(float));
GL.VertexAttributeDivisor(1, 1); GL.VertexAttributeDivisor(1, 1);
GL.VertexAttributeDivisor(2, 1); GL.VertexAttributeDivisor(2, 1);
@@ -294,7 +287,7 @@ namespace StgSharp
vbo.Unbind(); vbo.Unbind();
GL.BindVertexArray(GlHandle.Zero); GL.BindVertexArray(GlHandle.Zero);
NativeCameraViewTarget([0f, 0f, -100f], [0f, 0f, 0f], [0f, 1f, 0f]); NativeCameraViewTarget([ 0f, 0f, -100f ], [ 0f, 0f, 0f ], [ 0f, 1f, 0f ]);
NativeCameraViewRange(new Degree(1.5f), Vec2.Zero, (50, 50)); NativeCameraViewRange(new Degree(1.5f), Vec2.Zero, (50, 50));
NativeCameraUniform(s, "Camera"); NativeCameraUniform(s, "Camera");
@@ -309,8 +302,8 @@ namespace StgSharp
t = CreateTexture(1); t = CreateTexture(1);
t.Bind2D(0); t.Bind2D(0);
GL.TextureImage2d<byte>( GL.TextureImage2d<byte>(
Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, (uint)Height,
(uint)Height, ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, null!); ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, null!);
t.Set2dWrapProperty(0, TextureWrap.Repeat, TextureWrap.Repeat); t.Set2dWrapProperty(0, TextureWrap.Repeat, TextureWrap.Repeat);
t.Set2dFilterProperty(0, TextureFilter.Linear, TextureFilter.Linear); t.Set2dFilterProperty(0, TextureFilter.Linear, TextureFilter.Linear);
+1
View File
@@ -65,6 +65,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\StgSharp.Common\StgSharp.Common.csproj" /> <ProjectReference Include="..\StgSharp.Common\StgSharp.Common.csproj" />
<ProjectReference Include="..\StgSharp.Mathematics\StgSharp.Mathematics.csproj" />
<ProjectReference Include="..\StgSharp.Model\StgSharp.Model.csproj" /> <ProjectReference Include="..\StgSharp.Model\StgSharp.Model.csproj" />
<ProjectReference Include="..\StgSharp.Script\StgSharp.Script.csproj" /> <ProjectReference Include="..\StgSharp.Script\StgSharp.Script.csproj" />
</ItemGroup> </ItemGroup>