daily update on 20240828 by nitload youmu, autotexture added

This commit is contained in:
Nitload
2024-08-28 10:58:31 +08:00
parent d082071f2d
commit 1ee4e4a42f
586 changed files with 60910 additions and 123106 deletions
@@ -1,4 +1,34 @@
using StgSharp.Data;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="root.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.Data;
using System;
using System.Collections.Generic;
@@ -10,10 +40,10 @@ namespace StgSharp
{
public static unsafe partial class StgSharp
{
private static SSD defaultIdProvider = new SSD();
private static List<Area> root = new List<Area>();
private static byte leastUnusedArea;
private static List<Area> root = new List<Area>();
private static SSD defaultIdProvider = new SSD();
public static byte NewArea()
{
+92 -3
View File
@@ -1,4 +1,34 @@
using StgSharp;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="InternalData.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;
using System;
using System.Collections.Generic;
@@ -8,7 +38,66 @@ namespace StgSharp
{
internal partial class InternalIO
{
internal const string CollisionTextureVertexShader ="#version 430 core\r\n\r\nlayout(location = 0) in vec2 localCollisionCoord;\r\nlayout(location = 1) in vec2 spaceCoord;\r\nlayout(location = 2) in float rotation;\r\nlayout(location = 3) in float scaling;\r\n\r\nuniform vec2 target;\r\nuniform mat2 projection;\r\n\r\nvoid main()\r\n{\r\n mat2 scaling = mat2(\r\n scaling,0,\r\n 0,scaling\r\n );\r\n mat2 rotation = mat2(\r\n cos(rotation),-sin(rotation),\r\n sin(rotation),cos(rotation) \r\n );\r\n vec2 realCoord = (rotation * scaling * localCollisionCoord) + spaceCoord - target;\r\n realCoord = projection * realCoord;\r\n\r\n float dist = distance(realCoord, vec2(0,0));\r\n float angle = atan(realCoord.y, realCoord.x);\r\n \r\n gl_Position = vec4(angle, realCoord.y, dist, 1);\r\n}";
internal const string CollisionTextureFragmentShader = "#version 430 core\r\n\r\nout vec4 Color;\r\n\r\nuniform float range;\r\n\r\nvoid main()\r\n{\r\n float dist = gl_FragCoord.z;\r\n\r\n if(dist > range)\r\n {\r\n discard;\r\n }\r\n dist /= range;\r\n gl_FragDepth = min(dist, gl_FragDepth);\r\n\r\n Color = vec4(dist,0,0,1);\r\n}";
#region ControllingItemRender
internal const string ControlItemRenderVertexShader = """
""";
#endregion
#region CollisionTexture
internal const string CollisionTextureVertexShader = """
#version 430 core
layout(location = 0) in vec2 localCollisionCoord;
layout(location = 1) in vec2 spaceCoord;
layout(location = 2) in float rotation;
layout(location = 3) in float scaling;
uniform vec2 target;
uniform mat2 projection;
void main()
{
mat2 scaling = mat2(
scaling,0,
0,scaling );
mat2 rotation = mat2(
cos(rotation),-sin(rotation),
sin(rotation),cos(rotation) );
vec2 realCoord = (rotation * scaling * localCollisionCoord) + spaceCoord - target;
realCoord = projection * realCoord;
float dist = distance(realCoord, vec2(0,0));
float angle = atan(realCoord.y, realCoord.x);
gl_Position = vec4(angle, realCoord.y, dist, 1);
}
""";
internal const string CollisionTextureFragmentShader = """
#version 430 core
out vec4 Color;
uniform float range;
void main()
{
float dist = gl_FragCoord.z;
if(dist > range)
{
discard;
}
dist /= range;
gl_FragDepth = min(dist, gl_FragDepth);
Color = vec4(dist,0,0,1);
}
""";
#endregion
}
}
+29 -2
View File
@@ -32,6 +32,7 @@ using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -43,8 +44,9 @@ using System.Text;
namespace StgSharp.Data
{
[StructLayout(LayoutKind.Explicit, Pack = 16)]
public unsafe struct M128:IMemoryType
public unsafe struct M128 : IMemoryType
{
[FieldOffset(0)] internal Vector4 vec;
internal M128(Vector4 v)
@@ -52,6 +54,20 @@ namespace StgSharp.Data
vec = v;
}
public override bool Equals([NotNullWhen(true)] object obj)
{
if (obj is not M128 other)
{
return false;
}
return this == other;
}
public override int GetHashCode()
{
return vec.GetHashCode();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Read<T>(int index) where T : struct
#if NET8_0_OR_GREATER
@@ -89,7 +105,7 @@ namespace StgSharp.Data
#if NET8_0_OR_GREATER
, INumber
#else
,IConvertible
, IConvertible
#endif
{
fixed (Vector4* p = &vec)
@@ -100,7 +116,17 @@ namespace StgSharp.Data
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(M128 left, M128 right)
{
return left.vec == right.vec;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(M128 left, M128 right)
{
return left.vec != right.vec;
}
#if NET5_0_OR_GREATER
@@ -165,5 +191,6 @@ namespace StgSharp.Data
}
#endif
}
}
+34 -2
View File
@@ -1,4 +1,34 @@
using StgSharp.Data;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="M256.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.Data;
using System;
using System.Collections.Generic;
@@ -12,8 +42,9 @@ namespace StgSharp.Math.HighPrecession
{
[StructLayout(LayoutKind.Sequential)]
public unsafe struct M256:IMemoryType
public unsafe struct M256 : IMemoryType
{
private M128 v0;
private M128 v1;
@@ -33,5 +64,6 @@ namespace StgSharp.Math.HighPrecession
*(((T*)mptr) + index) = value;
}
}
}
}
+60 -29
View File
@@ -1,4 +1,34 @@
using StgSharp.Data;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="RandomGenerator.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.Data;
using System;
using System.IO;
@@ -14,15 +44,16 @@ namespace StgSharp.Data
public class RandomGenerator
{
private byte[] currentKey;
private readonly byte[] originKey;
private byte[] currentKey;
private int cycleCount;
private SHA512 hash;
public RandomGenerator():this(DateTime.UtcNow.ToBinary())
public RandomGenerator() : this(DateTime.UtcNow.ToBinary())
{
}
public RandomGenerator(object source)
@@ -77,28 +108,38 @@ namespace StgSharp.Data
return source.Read<int>(cycleCount % 4);
}
public byte GenRandomInt8()
{
cycleCount++;
if (cycleCount % 64 == 0)
{
PrivateRand();
}
return currentKey[cycleCount % 64];
}
public float GenRandomSingle()
{
cycleCount++;
while (true)
{
M128 source = PrivateRand();
uint
temp0 = source.Read<uint>(0),
temp1 = source.Read<uint>(2);
if (temp0 * temp1 != 0)
{
float ret = (temp0 % temp1) * 1.0f / temp1;
float ret = ((temp0 % temp1) * 1.0f) / temp1;
if (ret < 0.335f)
{
ret = ret * (ret * -0.7811934f + 1.4489113f);
ret = ret * ((ret * (-0.7811934f)) + 1.4489113f);
}
else
else
{
ret = ret * (ret * -0.1158368f + 1.0580600f) + 0.0590584f;
ret = (ret * ((ret * (-0.1158368f)) + 1.0580600f)) + 0.0590584f;
}
if (ret > 1)
{
@@ -111,14 +152,11 @@ namespace StgSharp.Data
}
public byte GenRandomInt8()
public void Reset()
{
cycleCount++;
if (cycleCount % 64 == 0)
{
PrivateRand();
}
return (byte)(currentKey[ cycleCount % 64 ]);
currentKey = originKey;
cycleCount = 0;
}
private unsafe M128 PrivateRand()
@@ -127,16 +165,16 @@ namespace StgSharp.Data
M128 ret;
fixed (byte* bptr = currentKey)
{
switch ((cycleCount % 16) / 4)
switch ((cycleCount % 16) / 4)
{
case 0:
ret= *((M128*)bptr + 0);break;
ret = *(((M128*)bptr) + 0); break;
case 1:
ret= *((M128*)bptr + 1);break;
ret = *(((M128*)bptr) + 1); break;
case 2:
ret= *((M128*)bptr + 2);break;
ret = *(((M128*)bptr) + 2); break;
case 3:
ret= *((M128*)bptr + 3);break;
ret = *(((M128*)bptr) + 3); break;
default:
throw new InvalidOperationException();
}
@@ -145,12 +183,5 @@ namespace StgSharp.Data
return ret;
}
public void Reset()
{
currentKey = originKey;
cycleCount = 0;
}
}
}
+32 -2
View File
@@ -1,4 +1,34 @@
using StgSharp.Data.FileIO;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Area.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.Data.FileIO;
using System;
using System.Collections.Generic;
@@ -15,6 +45,6 @@ namespace StgSharp.Data
/// </summary>
public partial class Area
{
}
}
+6 -6
View File
@@ -43,19 +43,19 @@ namespace StgSharp.Data
public struct SSDSegmentHead
{
[FieldOffset(12)] internal byte size;
[FieldOffset(0)] internal M128 data;
[FieldOffset(13)] public byte selfDefine_1;
[FieldOffset(14)] public byte selfDefine_2;
[FieldOffset(15)] public byte selfDefine_3;
[FieldOffset(0)] public int globalID;
[FieldOffset(4)] public int nextID;
[FieldOffset(8)] public int previousHash;
[FieldOffset(12)] internal byte size;
[FieldOffset(13)] public byte selfDefine_1;
[FieldOffset(14)] public byte selfDefine_2;
[FieldOffset(15)] public byte selfDefine_3;
public int Size
{
get => ((int)size) + 1;
+18 -18
View File
@@ -54,24 +54,6 @@ namespace StgSharp.Data
this.PreviousHash = previousHash;
}
public static SSDSegment FromStream(byte[] stream)
{
if (stream.Length != 16 * StgSharp.ssdSegmentLength)
{
throw new ArgumentException();
}
SSDSegment ret = new SSDSegment();
fixed (byte* bptr = stream)
{
ret.Head.data = *(M128*)bptr;
for (int i = 1; i < StgSharp.ssdSegmentLength; i++)
{
ret.WriteData<M128>(i - 1, *(M128*)(bptr + 16 * i));
}
}
return ret;
}
public byte this[int index]
{
get
@@ -113,6 +95,24 @@ namespace StgSharp.Data
}
}
public static SSDSegment FromStream(byte[] stream)
{
if (stream.Length != 16 * StgSharp.ssdSegmentLength)
{
throw new ArgumentException();
}
SSDSegment ret = new SSDSegment();
fixed (byte* bptr = stream)
{
ret.Head.data = *(M128*)bptr;
for (int i = 1; i < StgSharp.ssdSegmentLength; i++)
{
ret.WriteData<M128>(i - 1, *(M128*)(bptr + (16 * i)));
}
}
return ret;
}
public byte[] GetBytes()
{
byte[] ret = new byte[16 * StgSharp.ssdSegmentLength];
+2 -2
View File
@@ -39,11 +39,11 @@ namespace StgSharp.Data
{
public partial class SSD
{
private SSDrawHead head;
private Dictionary<string, SSDraw> fileList;
private FileStream file;
private SSDrawHead head;
public SSD()
{
@@ -39,9 +39,10 @@ namespace StgSharp.Data
{
public class SSDFolder : ISSDSerializable
{
internal Dictionary<string, SSDFolder> folders;
internal int _folderID;
internal string _name;
internal Dictionary<string, SSDFolder> folders;
internal SSDFolder()
{
@@ -68,6 +69,11 @@ namespace StgSharp.Data
public SerializableTypeCode SSDTypeCode => SerializableTypeCode.VirtualFolder;
public void FromBytes(byte[] stream)
{
throw new NotImplementedException();
}
//TODO 虚拟文件夹的GetBytes好难写
public byte[] GetBytes()
@@ -75,10 +81,5 @@ namespace StgSharp.Data
throw new NotImplementedException();
}
public void FromBytes(byte[] stream)
{
throw new NotImplementedException();
}
}
}
+3 -1
View File
@@ -47,6 +47,7 @@ namespace StgSharp.Data.FileIO
{
public class SSDraw
{
private byte[] data;
public SSDraw(string name, Stream streamSource)
@@ -62,13 +63,14 @@ namespace StgSharp.Data.FileIO
public SSDrawHead Head { get; set; }
public string Name { get; set; }
}
[StructLayout(LayoutKind.Explicit, Size = 32 * 16)]
public unsafe struct SSDrawHead
{
}
@@ -1,4 +1,34 @@
using System;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ISSDSerializable.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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,11 +39,13 @@ namespace StgSharp.Data
public interface ISSDSerializable
{
public SerializableTypeCode SSDTypeCode { get; }
public byte[] GetBytes();
internal void FromBytes(byte[] stream);
}
public enum SerializableTypeCode
@@ -31,14 +63,10 @@ namespace StgSharp.Data
public static partial class Serializer
{
public static byte[] Serialize(ISSDSerializable serializableObject)
{
return serializableObject.GetBytes();
}
public static T Deserialize<T>(byte[] stream)where T : ISSDSerializable
public static T Deserialize<T>(byte[] stream) where T : ISSDSerializable
{
T serializableObject = (T)Activator.CreateInstance<T>();
T serializableObject = Activator.CreateInstance<T>();
serializableObject.FromBytes(stream);
return serializableObject;
}
@@ -67,5 +95,10 @@ namespace StgSharp.Data
throw new ArgumentException("Unknown file type");
}
}
public static byte[] Serialize(ISSDSerializable serializableObject)
{
return serializableObject.GetBytes();
}
}
}