daily update on 20240828 by nitload youmu, autotexture added
This commit is contained in:
@@ -37,6 +37,7 @@ namespace StgSharp.Geometries
|
||||
|
||||
public static unsafe class GeometryOperation
|
||||
{
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static vec3d DefaultMotion(int tick)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,34 @@
|
||||
using StgSharp.Math;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="IPlainEntity.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// 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.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -11,22 +41,19 @@ namespace StgSharp.Geometries
|
||||
|
||||
public interface IPlainEntity
|
||||
{
|
||||
|
||||
public vec2d CenterPosition { get; set; }
|
||||
|
||||
public bool CollideWith(IPlainEntity entity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class PlainEntity:IPlainEntity
|
||||
public class PlainEntity : IPlainEntity
|
||||
{
|
||||
private PlainGeometry _shape;
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
{
|
||||
get => _shape.Coordination.LocalOrigin.Coord.XY;
|
||||
set => throw new InvalidOperationException();
|
||||
}
|
||||
private PlainGeometry _shape;
|
||||
|
||||
public PlainEntity(PlainGeometry shape)
|
||||
{
|
||||
@@ -37,6 +64,13 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
{
|
||||
get => _shape.Coordination.LocalOrigin.Coord.XY;
|
||||
set => throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="IInstancing.cs"
|
||||
// file="ParticleOnPlain.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -54,7 +54,7 @@ namespace StgSharp.Geometries
|
||||
((IInstancingBuffer)buffer).InstanceList.Add(this);
|
||||
}
|
||||
|
||||
public int BufferId
|
||||
public GeometryMotion Motion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
@@ -65,9 +65,10 @@ namespace StgSharp.Geometries
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public GeometryMotion Motion
|
||||
{
|
||||
get;
|
||||
|
||||
public int BufferId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
@@ -77,16 +78,17 @@ namespace StgSharp.Geometries
|
||||
set;
|
||||
}
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
{
|
||||
get => GlobalBuffer.CoordAndRotationList[BufferId].XY;
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
bool IPlainEntity.CollideWith(IPlainEntity entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
{
|
||||
get => GlobalBuffer.CoordAndRotationList[BufferId].XY;
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace StgSharp.Geometries
|
||||
/// </summary>
|
||||
public abstract class PlainGeometry : IGeometry
|
||||
{
|
||||
|
||||
protected vec4d[] vertexMat;
|
||||
internal CoordinationBase coordinate;
|
||||
|
||||
|
||||
@@ -44,30 +44,24 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class PlainInstancingBuffer<T> :
|
||||
IDisposable,IEnumerable<T>, IInstancingBuffer
|
||||
where T :
|
||||
public class PlainInstancingBuffer<T> :
|
||||
IDisposable, IEnumerable<T>, IInstancingBuffer
|
||||
where T :
|
||||
IInstancing
|
||||
{
|
||||
|
||||
private bool disposedValue;
|
||||
|
||||
private CoordinatePlain globalCorrdinnate;
|
||||
private List<vec4d> coordList;
|
||||
private List<IInstancing> instanceList;
|
||||
private List<float> scalingList;
|
||||
private Mutex mutex;
|
||||
private bool disposedValue;
|
||||
|
||||
#region field of mem opt
|
||||
|
||||
vec4d[] coordArray;
|
||||
float[] scaleArray;
|
||||
|
||||
#endregion
|
||||
|
||||
public PlainInstancingBuffer()
|
||||
{
|
||||
coordList = new List<vec4d>(capacity: 100);
|
||||
instanceList = new List<IInstancing>(capacity:100);
|
||||
instanceList = new List<IInstancing>(capacity: 100);
|
||||
scalingList = new List<float>(capacity: 100);
|
||||
coordArray = Array.Empty<vec4d>();
|
||||
scaleArray = Array.Empty<float>();
|
||||
@@ -133,8 +127,6 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
}
|
||||
|
||||
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException();
|
||||
|
||||
public int CreateInstanceID()
|
||||
{
|
||||
mutex.WaitOne();
|
||||
@@ -145,13 +137,32 @@ namespace StgSharp.Geometries
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ~PlainInstancingBuffer()
|
||||
// {
|
||||
// Dispose(disposing: false);
|
||||
// }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
foreach (IInstancing item in instanceList)
|
||||
{
|
||||
yield return (T)item;
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(T instance)
|
||||
{
|
||||
mutex.WaitOne();
|
||||
if (instance.GlobalBuffer != this)
|
||||
{
|
||||
throw new ArgumentException(
|
||||
message:"instance does not belong to current Particle Buffer",
|
||||
message: "instance does not belong to current Particle Buffer",
|
||||
paramName: nameof(instance));
|
||||
}
|
||||
int index = instance.BufferId;
|
||||
@@ -170,7 +181,7 @@ namespace StgSharp.Geometries
|
||||
|
||||
public void UpdateAllParticles()
|
||||
{
|
||||
foreach (var particle in instanceList)
|
||||
foreach (IInstancing particle in instanceList)
|
||||
{
|
||||
particle.Move();
|
||||
}
|
||||
@@ -192,31 +203,23 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
}
|
||||
|
||||
// ~PlainInstancingBuffer()
|
||||
// {
|
||||
// Dispose(disposing: false);
|
||||
// }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
foreach (var item in instanceList)
|
||||
{
|
||||
yield return (T)item;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
foreach (var item in instanceList)
|
||||
foreach (IInstancing item in instanceList)
|
||||
{
|
||||
yield return (T)item;
|
||||
}
|
||||
}
|
||||
|
||||
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException();
|
||||
|
||||
#region field of mem opt
|
||||
|
||||
vec4d[] coordArray;
|
||||
float[] scaleArray;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user