Daily update on 20250618-051714 by Nitload Youmu. Additional Message : Brief support to collection operation in EXPRESS. A collection type added in core lib and compilestack.

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-06-18 05:17:14 +08:00
parent 74c01effe4
commit c624a8ca38
300 changed files with 12227 additions and 4303 deletions
@@ -1,30 +1,25 @@
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\build\stgsharp.c.bsc c:\users\youmu\onedrive - msft\大学\毕业设计\graduationproject\build\stgsharp.c.bsc
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vc143.pdb
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vc143.idb
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharpc.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharpc.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharpc.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\intrinsic.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\intrinsic.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\intrinsic.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\string.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\string.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\string.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat4.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat4.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat4.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vector.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vector.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vector.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\hash.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\hash.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\hash.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stb_image.sbr d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stb_image.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stb_image.obj d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stb_image.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stb_image.cod d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stb_image.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat2.sbr d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat2.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat2.obj d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat2.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat2.cod d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat2.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\hash.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\hash.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\hash.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\string.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\string.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\string.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat4.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat4.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat4.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharpc.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharpc.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharpc.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vector.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vector.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vector.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat3.sbr d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat3.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat3.obj d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat3.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat3.cod d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat3.cod
@@ -34,18 +29,23 @@ d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\st
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\dllmain.sbr d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\dllmain.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\dllmain.obj d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\dllmain.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\dllmain.cod d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\dllmain.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\build\stgsharp.c.dll d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\intrinsic.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\build\stgsharp.c.pdb d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\intrinsic.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\build\stgsharp.c.lib d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\intrinsic.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\build\stgsharp.c.exp d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vc143.pdb
c:\users\youmu\onedrive - msft\大学\毕业设计\graduationproject\build\stgsharp.c.dll
c:\users\youmu\onedrive - msft\大学\毕业设计\graduationproject\build\stgsharp.c.pdb
c:\users\youmu\onedrive - msft\大学\毕业设计\graduationproject\build\stgsharp.c.lib
c:\users\youmu\onedrive - msft\大学\毕业设计\graduationproject\build\stgsharp.c.exp
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.ilk d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.ilk
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vc143.idb
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\bscmake.command.1.tlog d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\bscmake.command.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\bscmake.read.1.tlog d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\bscmake.read.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\bscmake.write.1.tlog d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\bscmake.write.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.12408.write.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.command.1.tlog d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.command.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.items.tlog d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.items.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.read.1.tlog d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.read.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.write.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\link.command.1.tlog d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\link.command.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\link.read.1.tlog d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\link.read.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\link.secondary.1.tlog d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\link.secondary.1.tlog
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3
View File
@@ -4,4 +4,7 @@ D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\St
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\hash.c(31,50): warning C4244: “函数”: 从“uint64_t”转换到“unsigned char”,可能丢失数据 D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\hash.c(31,50): warning C4244: “函数”: 从“uint64_t”转换到“unsigned char”,可能丢失数据
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\hash.c(7,15): warning C4090: “初始化”: 不同的“const”限定符 D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\hash.c(7,15): warning C4090: “初始化”: 不同的“const”限定符
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\hash.c(7,34): warning C4090: “初始化”: 不同的“const”限定符 D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\hash.c(7,34): warning C4090: “初始化”: 不同的“const”限定符
LINK : 没有找到 D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\build\StgSharp.C.dll 或上一个增量链接没有生成它;正在执行完全链接
正在创建库 D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\build\StgSharp.C.lib 和对象 D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\build\StgSharp.C.exp
LINK : warning LNK4098: 默认库“MSVCRT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
StgSharpC.vcxproj -> D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\build\StgSharp.C.dll StgSharpC.vcxproj -> D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\build\StgSharp.C.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\Youmu\OneDrive - MSFT\大学\毕业设计\GraduationProject\build\StgSharp.C.dll</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
<SatelliteDlls />
<NonRecipeFileRefs />
</Project>
Binary file not shown.
@@ -0,0 +1,11 @@
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\dllmain.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\dllmain.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\intrinsic.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\intrinsic.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat2.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\mat2.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat3.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\mat3.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\mat4.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\stb_image.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\stb_image.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\StgSharpC.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\StgSharpC.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\hash.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\hash.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\string.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\string.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\vector.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\vector.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\vector_dot.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\vector_dot.obj
@@ -0,0 +1,2 @@
PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.41.34120:TargetPlatformVersion=10.0.22621.0:
Release|x64|C:\Users\Youmu\OneDrive - MSFT\大学\毕业设计\GraduationProject\|
@@ -0,0 +1,4 @@
^D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\GLFW3.LIB|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\GLFW3DLL.LIB|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\GLFW3_MT.LIB|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\DLLMAIN.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\HASH.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\INTRINSIC.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\MAT2.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\MAT3.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\MAT4.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\STB_IMAGE.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\STGSHARPC.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\STRING.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\VECTOR.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\VECTOR_DOT.OBJ
C:\Users\Youmu\OneDrive - MSFT\大学\毕业设计\GraduationProject\build\StgSharp.C.lib
C:\Users\Youmu\OneDrive - MSFT\大学\毕业设计\GraduationProject\build\StgSharp.C.EXP
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\StgSharp.C.iobj
File diff suppressed because it is too large Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -56,15 +56,16 @@ namespace StgSharp.Commom.Collections
if( _reverse.TryGetValue( key, out TFirst value ) ) { if( _reverse.TryGetValue( key, out TFirst value ) ) {
return value; return value;
} }
throw new ArgumentException( throw new ArgumentException( $"Cannot find key {key!.ToString()} in dictionary." );
$"Cannot find key {key!.ToString()} in dictionary." );
} }
set set
{ {
if( _reverse.TryGetValue( key, out TFirst origin ) ) { if( _reverse.TryGetValue( key, out TFirst origin ) )
{
_reverse[ key ] = value; _reverse[ key ] = value;
_forward.Remove( origin ); _forward.Remove( origin );
} else { } else
{
_reverse.Add( key, value ); _reverse.Add( key, value );
} }
_forward.Add( value, key ); _forward.Add( value, key );
@@ -78,15 +79,16 @@ namespace StgSharp.Commom.Collections
if( _forward.TryGetValue( key, out TSecond value ) ) { if( _forward.TryGetValue( key, out TSecond value ) ) {
return value; return value;
} }
throw new ArgumentException( throw new ArgumentException( $"Cannot find key {key!.ToString()} in dictionary." );
$"Cannot find key {key!.ToString()} in dictionary." );
} }
set set
{ {
if( _forward.TryGetValue( key, out TSecond origin ) ) { if( _forward.TryGetValue( key, out TSecond origin ) )
{
_forward[ key ] = value; _forward[ key ] = value;
_reverse.Remove( origin ); _reverse.Remove( origin );
} else { } else
{
_forward.Add( key, value ); _forward.Add( key, value );
} }
_reverse.Add( value, key ); _reverse.Add( value, key );
@@ -109,8 +111,7 @@ namespace StgSharp.Commom.Collections
public void Add( KeyValuePair<TFirst, TSecond> item ) public void Add( KeyValuePair<TFirst, TSecond> item )
{ {
if( _forward.ContainsKey( item.Key ) || _reverse.ContainsKey( if( _forward.ContainsKey( item.Key ) || _reverse.ContainsKey( item.Value ) ) {
item.Value ) ) {
throw new ArgumentException( "Duplicate key or value." ); throw new ArgumentException( "Duplicate key or value." );
} }
_forward.Add( item.Key, item.Value ); _forward.Add( item.Key, item.Value );
@@ -134,8 +135,9 @@ namespace StgSharp.Commom.Collections
public bool Contains( KeyValuePair<TFirst, TSecond> item ) public bool Contains( KeyValuePair<TFirst, TSecond> item )
{ {
return _forward.Contains( item ) && _reverse.TryGetValue( return _forward.Contains( item ) &&
item.Value, out TFirst var ) && var!.Equals( item.Key ); _reverse.TryGetValue( item.Value, out TFirst var ) &&
var!.Equals( item.Key );
} }
public bool Contains( TSecond key ) public bool Contains( TSecond key )
@@ -148,9 +150,7 @@ namespace StgSharp.Commom.Collections
return _forward.ContainsKey( key ); return _forward.ContainsKey( key );
} }
public void CopyTo( public void CopyTo( KeyValuePair<TFirst, TSecond>[] array, int arrayIndex )
KeyValuePair<TFirst, TSecond>[] array,
int arrayIndex )
{ {
if( array == null ) { if( array == null ) {
throw new ArgumentNullException( nameof( array ) ); throw new ArgumentNullException( nameof( array ) );
@@ -159,8 +159,7 @@ namespace StgSharp.Commom.Collections
throw new ArgumentOutOfRangeException( nameof( arrayIndex ) ); throw new ArgumentOutOfRangeException( nameof( arrayIndex ) );
} }
if( array.Length - arrayIndex < _forward.Count ) { if( array.Length - arrayIndex < _forward.Count ) {
throw new ArgumentException( throw new ArgumentException( "The array is too small to copy the elements." );
"The array is too small to copy the elements." );
} }
foreach( KeyValuePair<TFirst, TSecond> pair in _forward ) { foreach( KeyValuePair<TFirst, TSecond> pair in _forward ) {
@@ -39,13 +39,17 @@ namespace StgSharp.Commom.Collections
{ {
public static class CapacityFixedListBuilder public static class CapacityFixedListBuilder
{ {
internal static CapacityFixedList<T> Create<T>( ReadOnlySpan<T> values ) internal static CapacityFixedList<T> Create<T>( ReadOnlySpan<T> values )
{ {
return new CapacityFixedList<T>( values ); return new CapacityFixedList<T>( values );
} }
} }
[CollectionBuilder(typeof(CapacityFixedListBuilder),nameof(CapacityFixedListBuilder.Create))] [CollectionBuilder(
typeof( CapacityFixedListBuilder ),
nameof( CapacityFixedListBuilder.Create ) )]
public class CapacityFixedList<T> : IList<T> public class CapacityFixedList<T> : IList<T>
{ {
@@ -65,13 +69,14 @@ namespace StgSharp.Commom.Collections
public T this[ int index ] public T this[ int index ]
{ {
get => index < _index ? get => index < _index ?
_values[ index ] : throw new ArgumentOutOfRangeException( _values[ index ] : throw new ArgumentOutOfRangeException( nameof( index ) );
nameof( index ) );
set set
{ {
if( index < _index ) { if( index < _index )
{
_values[ index ] = value; _values[ index ] = value;
} else { } else
{
throw new ArgumentOutOfRangeException( nameof( index ) ); throw new ArgumentOutOfRangeException( nameof( index ) );
} }
} }
@@ -83,7 +88,8 @@ namespace StgSharp.Commom.Collections
public void Add( T item ) public void Add( T item )
{ {
if( _index < capacity - 1 ) { if( _index < capacity - 1 )
{
_index++; _index++;
this[ _index ] = item; this[ _index ] = item;
} }
@@ -97,7 +103,8 @@ namespace StgSharp.Commom.Collections
public bool Contains( T item ) public bool Contains( T item )
{ {
for( int i = 0; i <= _index; i++ ) { for( int i = 0; i <= _index; i++ )
{
if( item.Equals( _values[ i ] ) ) { if( item.Equals( _values[ i ] ) ) {
return true; return true;
} }
@@ -120,7 +127,8 @@ namespace StgSharp.Commom.Collections
public int IndexOf( T item ) public int IndexOf( T item )
{ {
T v; T v;
for( int i = 0; i <= _index; i++ ) { for( int i = 0; i <= _index; i++ )
{
if( ( v = _values[ i ] ) != null && v.Equals( item ) ) { if( ( v = _values[ i ] ) != null && v.Equals( item ) ) {
return i; return i;
} }
@@ -131,8 +139,10 @@ namespace StgSharp.Commom.Collections
public bool Remove( T item ) public bool Remove( T item )
{ {
T v; T v;
for( int i = 0; i <= _index; i++ ) { for( int i = 0; i <= _index; i++ )
if( ( v = _values[ i ] ) != null && v.Equals( item ) ) { {
if( ( v = _values[ i ] ) != null && v.Equals( item ) )
{
_values[ i ] = _values[ _index ]; _values[ i ] = _values[ _index ];
_index--; _index--;
return true; return true;
@@ -143,8 +153,10 @@ namespace StgSharp.Commom.Collections
public void RemoveAll( Predicate<T> predicate ) public void RemoveAll( Predicate<T> predicate )
{ {
for( int i = _index; i > 0; i-- ) { for( int i = _index; i > 0; i-- )
if( predicate( _values[ i ] ) ) { {
if( predicate( _values[ i ] ) )
{
_values[ i ] = _values[ _index ]; _values[ i ] = _values[ _index ];
_index--; _index--;
} }
@@ -153,7 +165,8 @@ namespace StgSharp.Commom.Collections
public void RemoveAt( int index ) public void RemoveAt( int index )
{ {
if( index <= _index ) { if( index <= _index )
{
_values[ index ] = _values[ _index ]; _values[ index ] = _values[ _index ];
_index--; _index--;
} }
@@ -38,51 +38,39 @@ namespace StgSharp.Commom.Collections
public interface IBidirectionalDictionary<TFirst, TSecond> : IDictionary<TFirst, TSecond> public interface IBidirectionalDictionary<TFirst, TSecond> : IDictionary<TFirst, TSecond>
{ {
public TFirst this[ TSecond key ] public TFirst this[ TSecond key ] { get; set; }
{
get;
set;
}
public ICollection<TFirst> FirstIndex public ICollection<TFirst> FirstIndex { get; }
{
get;
}
public ICollection<TSecond> SecondIndex public ICollection<TSecond> SecondIndex { get; }
{
get;
}
public IReadOnlyDictionary<TFirst, TSecond> Forward public IReadOnlyDictionary<TFirst, TSecond> Forward { get; }
{
get;
}
public IReadOnlyDictionary<TSecond, TFirst> Reverse public IReadOnlyDictionary<TSecond, TFirst> Reverse { get; }
{
get;
}
/// <summary> /// <summary>
/// Determines whether the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains /// Determines whether the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />
/// the specified key. /// contains the specified key.
/// </summary> /// </summary>
/// <param _name="key"> The value to locate in the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />. </param> /// <param _label="key">
/// The value to locate in the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />.
/// </param>
/// <returns> /// <returns>
/// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an element /// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an
/// with the specified key; otherwise, false. /// element with the specified key; otherwise, false.
/// </returns> /// </returns>
public bool Contains( TSecond key ); public bool Contains( TSecond key );
/// <summary> /// <summary>
/// Determines whether the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains /// Determines whether the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />
/// the specified key. /// contains the specified key.
/// </summary> /// </summary>
/// <param _name="key"> The value to locate in the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />. </param> /// <param _label="key">
/// The value to locate in the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />.
/// </param>
/// <returns> /// <returns>
/// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an element /// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an
/// with the specified key; otherwise, false. /// element with the specified key; otherwise, false.
/// </returns> /// </returns>
public bool Contains( TFirst key ); public bool Contains( TFirst key );
@@ -93,8 +81,7 @@ namespace StgSharp.Commom.Collections
ICollection<TSecond> IDictionary<TFirst, TSecond>.Values => SecondIndex; ICollection<TSecond> IDictionary<TFirst, TSecond>.Values => SecondIndex;
bool IDictionary<TFirst, TSecond>.ContainsKey( TFirst key ) => Contains( bool IDictionary<TFirst, TSecond>.ContainsKey( TFirst key ) => Contains( key );
key );
#pragma warning restore CA1033 #pragma warning restore CA1033
} }
} }
@@ -36,11 +36,7 @@ namespace StgSharp.Collections
public interface IHashMultiplexer<T> : IEqualityComparer<T> public interface IHashMultiplexer<T> : IEqualityComparer<T>
{ {
int RemainedMultiplexCount int RemainedMultiplexCount { get; set; }
{
get;
set;
}
void CacheHash( T obj, int count ); void CacheHash( T obj, int count );
+19 -9
View File
@@ -40,10 +40,12 @@ using System.Xml.Serialization;
namespace StgSharp.Collections namespace StgSharp.Collections
{ {
/// <summary> /// <summary>
/// Part of a collection. This contains a direct reference to _origin collection, so all change /// Part of a collection. This contains a direct reference to _origin collection, so all
/// to _origin collection will be reflected in this object. /// change to _origin collection will be reflected in this object.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T">
///
/// </typeparam>
public struct ListSegment<T> : ICollection<T> public struct ListSegment<T> : ICollection<T>
{ {
@@ -56,8 +58,7 @@ namespace StgSharp.Collections
ArgumentNullException.ThrowIfNull( collection ); ArgumentNullException.ThrowIfNull( collection );
ArgumentOutOfRangeException.ThrowIfLessThan( begin, 0 ); ArgumentOutOfRangeException.ThrowIfLessThan( begin, 0 );
ArgumentOutOfRangeException.ThrowIfLessThan( length, 0 ); ArgumentOutOfRangeException.ThrowIfLessThan( length, 0 );
ArgumentOutOfRangeException.ThrowIfLessThan( ArgumentOutOfRangeException.ThrowIfLessThan( begin + length, collection.Count );
begin + length, collection.Count );
_collection = collection; _collection = collection;
_begin = begin; _begin = begin;
_length = length; _length = length;
@@ -68,12 +69,22 @@ namespace StgSharp.Collections
get get
{ {
ArgumentOutOfRangeException.ThrowIfLessThan( indexValue, 0 ); ArgumentOutOfRangeException.ThrowIfLessThan( indexValue, 0 );
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual( ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual( indexValue, _length );
indexValue, _length );
return _collection[ indexValue + _begin ]; return _collection[ indexValue + _begin ];
} }
} }
public T this[ Index i ]
{
get
{
int offset = i.IsFromEnd ? _length - i.Value : i.Value;
ArgumentOutOfRangeException.ThrowIfLessThan( offset, 0 );
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual( offset, _length );
return _collection[ offset + _begin ];
}
}
public bool IsReadOnly => true; public bool IsReadOnly => true;
public int Count => _length; public int Count => _length;
@@ -87,8 +98,7 @@ namespace StgSharp.Collections
public void CopyTo( T[] array, int arrayIndex ) public void CopyTo( T[] array, int arrayIndex )
{ {
ArgumentNullException.ThrowIfNull( array ); ArgumentNullException.ThrowIfNull( array );
Span<T> span = CollectionsMarshal.AsSpan<T>( _collection ) Span<T> span = CollectionsMarshal.AsSpan<T>( _collection ).Slice( _begin, _length );
.Slice( _begin, _length );
Span<T> target = new Span<T>( array, arrayIndex, _length ); Span<T> target = new Span<T>( array, arrayIndex, _length );
span.CopyTo( target ); span.CopyTo( target );
} }
@@ -40,49 +40,47 @@ namespace StgSharp.Collections
{ {
public partial class PartialDictionary<TKey, TValue> : IDictionary<TKey, TValue> public partial class PartialDictionary<TKey, TValue> : IDictionary<TKey, TValue>
{ {
private readonly Dictionary<TKey, TValue> _source; private readonly Dictionary<TKey, TValue> _source;
private readonly HashSet<TKey> _keys; private readonly HashSet<TKey> _keys;
private readonly PartialDictionaryValues _values; private readonly PartialDictionaryValues _values;
public PartialDictionary( public PartialDictionary( Dictionary<TKey, TValue> source, TKey[] index )
Dictionary<TKey, TValue> source,
TKey[] index )
{
_source = source;
_keys = new HashSet<TKey>( index );
foreach( TKey item in _keys ) {
if( !_source.ContainsKey( item ) ) {
_source.Add( item, default! );
}
}
_values = new PartialDictionaryValues( this );
}
public PartialDictionary(
Dictionary<TKey, TValue> source,
HashSet<TKey> keys )
{
_source = source;
_keys = keys;
foreach( TKey item in _keys ) {
if( !_source.ContainsKey( item ) ) {
_source.Add( item, default! );
}
}
_values = new PartialDictionaryValues( this );
}
public PartialDictionary(
Dictionary<TKey, TValue> source,
TKey[] index, IHashMultiplexer<TKey> multiplexer
)
{ {
_source = source; _source = source;
_keys = new HashSet<TKey>( index ); _keys = new HashSet<TKey>( index );
foreach( TKey item in _keys ) foreach( TKey item in _keys )
{ {
if (!_source.ContainsKey(item)) if( !_source.ContainsKey( item ) ) {
_source.Add( item, default! );
}
}
_values = new PartialDictionaryValues( this );
}
public PartialDictionary( Dictionary<TKey, TValue> source, HashSet<TKey> keys )
{ {
_source = source;
_keys = keys;
foreach( TKey item in _keys )
{
if( !_source.ContainsKey( item ) ) {
_source.Add( item, default! );
}
}
_values = new PartialDictionaryValues( this );
}
public PartialDictionary(
Dictionary<TKey, TValue> source,
TKey[] index,
IHashMultiplexer<TKey> multiplexer )
{
_source = source;
_keys = new HashSet<TKey>( index );
foreach( TKey item in _keys )
{
if( !_source.ContainsKey( item ) ) {
_source.Add( item, default! ); _source.Add( item, default! );
} }
} }
@@ -131,14 +129,14 @@ namespace StgSharp.Collections
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{ {
foreach( TKey item in _keys ) { foreach( TKey item in _keys ) {
yield return new KeyValuePair<TKey, TValue>( yield return new KeyValuePair<TKey, TValue>( item, _source[ item ] );
item, _source[ item ] );
} }
} }
public bool TryGetValue( TKey key, out TValue value ) public bool TryGetValue( TKey key, out TValue value )
{ {
if( _keys.Contains( key ) ) { if( _keys.Contains( key ) )
{
value = _source[ key ]; value = _source[ key ];
return true; return true;
} }
@@ -146,8 +144,7 @@ namespace StgSharp.Collections
return false; return false;
} }
void ICollection<KeyValuePair<TKey, TValue>>.Add( void ICollection<KeyValuePair<TKey, TValue>>.Add( KeyValuePair<TKey, TValue> item )
KeyValuePair<TKey, TValue> item )
{ {
return; return;
} }
@@ -157,8 +154,7 @@ namespace StgSharp.Collections
throw new NotSupportedException(); throw new NotSupportedException();
} }
bool ICollection<KeyValuePair<TKey, TValue>>.Remove( bool ICollection<KeyValuePair<TKey, TValue>>.Remove( KeyValuePair<TKey, TValue> item )
KeyValuePair<TKey, TValue> item )
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }
@@ -43,8 +43,7 @@ namespace StgSharp.Collections
private readonly PartialDictionary<TKey, TValue> _values; private readonly PartialDictionary<TKey, TValue> _values;
public PartialDictionaryValues( public PartialDictionaryValues( PartialDictionary<TKey, TValue> value )
PartialDictionary<TKey, TValue> value )
{ {
_values = value; _values = value;
} }
@@ -55,7 +54,8 @@ namespace StgSharp.Collections
public bool Contains( TValue item ) public bool Contains( TValue item )
{ {
foreach( KeyValuePair<TKey, TValue> kvp in _values ) { foreach( KeyValuePair<TKey, TValue> kvp in _values )
{
if( kvp.Value != null && kvp.Value.Equals( item ) ) { if( kvp.Value != null && kvp.Value.Equals( item ) ) {
return true; return true;
} }
@@ -65,7 +65,8 @@ namespace StgSharp.Collections
public void CopyTo( TValue[] array, int arrayIndex ) public void CopyTo( TValue[] array, int arrayIndex )
{ {
foreach( KeyValuePair<TKey, TValue> kvp in _values ) { foreach( KeyValuePair<TKey, TValue> kvp in _values )
{
array[ arrayIndex ] = kvp.Value; array[ arrayIndex ] = kvp.Value;
arrayIndex++; arrayIndex++;
} }
@@ -0,0 +1,185 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="RandomAccessibleStack.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;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Collections
{
public class RandomAccessibleStack<T> : IEnumerable<T>
{
private const int DefaultCapacity = 4;
private T[] _array;
private int _size;
private int _version;
/// <summary>
/// Initializes a new instance of the RandomAccessStack class that is empty and has the
/// default initial capacity.
/// </summary>
public RandomAccessibleStack()
{
_array = new T[DefaultCapacity];
}
/// <summary>
/// Initializes a new instance of the RandomAccessStack class that is empty and has the
/// specified initial capacity.
/// </summary>
public RandomAccessibleStack( int capacity )
{
if( capacity < 0 ) {
throw new ArgumentOutOfRangeException(
nameof( capacity ), "Capacity must be non-negative." );
}
_array = new T[capacity];
}
/// <summary>
/// Gets or sets the element at the specified index in the stack (0 = bottom, Count-1 =
/// top).
/// </summary>
public T this[ int index ]
{
get
{
if( index < 0 || index >= _size ) {
throw new ArgumentOutOfRangeException( nameof( index ) );
}
return _array[ index ];
}
/*
set
{
if( index < 0 || index >= _size ) {
throw new ArgumentOutOfRangeException( nameof( index ) );
}
_array[ index ] = value;
_version++;
}
/**/
}
/// <summary>
/// Gets the number of elements contained in the stack.
/// </summary>
public int Count => _size;
/// <summary>
/// Removes all objects from the stack.
/// </summary>
public void Clear()
{
Array.Clear( _array, 0, _size );
_size = 0;
_version++;
}
/// <summary>
/// Returns an enumerator that iterates through the stack from top to bottom. Throws if
/// the stack is modified during iteration.
/// </summary>
public IEnumerator<T> GetEnumerator()
{
int expectedVersion = _version;
for( int i = _size - 1; i >= 0; i-- )
{
if( expectedVersion != _version ) {
throw new InvalidOperationException(
"Collection was modified during enumeration." );
}
yield return _array[ i ];
}
}
/// <summary>
/// Returns the object at the top of the stack without removing it.
/// </summary>
public T Peek()
{
if( _size == 0 ) {
throw new InvalidOperationException( "Stack is empty." );
}
return _array[ _size - 1 ];
}
/// <summary>
/// Removes and returns the object at the top of the stack.
/// </summary>
public T Pop()
{
if( _size == 0 ) {
throw new InvalidOperationException( "Stack is empty." );
}
T item = _array[ --_size ];
_array[ _size ] = default!;
_version++;
return item;
}
/// <summary>
/// Adds an item to the top of the stack.
/// </summary>
public void Push( T item )
{
if( _size == _array.Length ) {
EnsureCapacity( _size + 1 );
}
_array[ _size++ ] = item;
_version++;
}
private void EnsureCapacity( int min )
{
int newCapacity = _array.Length == 0 ? DefaultCapacity : _array.Length * 2;
if( newCapacity < min ) {
newCapacity = min;
}
Array.Resize( ref _array, newCapacity );
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
@@ -1,6 +1,6 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// file="KeyMultiplexer.cs" // file="StringHashMultiplexer.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.
@@ -74,15 +74,15 @@ namespace StgSharp.Collections
{ {
int hash; int hash;
fixed( char* cPtr = obj.AsSpan() ) { fixed( char* cPtr = obj.AsSpan() ) {
hash = InternalIO.Intrinsic hash = InternalIO.Intrinsic.city_hash_simplify( cPtr, obj.Length );
.city_hash_simplify( cPtr, obj.Length );
} }
return hash; return hash;
} }
public int GetHashCode( string obj ) public int GetHashCode( string obj )
{ {
if( _remainedCount > 0 && ReferenceEquals( _source, obj ) ) { if( _remainedCount > 0 && ReferenceEquals( _source, obj ) )
{
_remainedCount--; _remainedCount--;
return _hashCache; return _hashCache;
} }
@@ -139,8 +139,7 @@ namespace StgSharp.Collections
{ {
int hash; int hash;
fixed( char* cPtr = obj.AsSpan() ) { fixed( char* cPtr = obj.AsSpan() ) {
hash = InternalIO.Intrinsic hash = InternalIO.Intrinsic.city_hash_simplify( cPtr, obj.Length );
.city_hash_simplify( cPtr, obj.Length );
} }
return hash; return hash;
} }
@@ -152,7 +151,8 @@ namespace StgSharp.Collections
private void Dispose( bool disposing ) private void Dispose( bool disposing )
{ {
if( !disposedValue ) { if( !disposedValue )
{
if( disposing ) { if( disposing ) {
_multiplexers.Dispose(); _multiplexers.Dispose();
} }
@@ -51,17 +51,9 @@ namespace StgSharp.Controls
get => throw new NotImplementedException(); get => throw new NotImplementedException();
} }
public Rectangle BoundingBox public Rectangle BoundingBox { get; set; }
{
get;
set;
}
public Vec2 Position public Vec2 Position { get; set; }
{
get;
set;
}
public IEnumerator<PlainGeometryMesh> GetEnumerator() public IEnumerator<PlainGeometryMesh> GetEnumerator()
{ {
@@ -63,22 +63,14 @@ namespace StgSharp.Controls
get => throw new NotSupportedException(); get => throw new NotSupportedException();
} }
public Rectangle BoundingBox public Rectangle BoundingBox { get; set; }
{
get;
set;
}
public TriggerButton CurrentButton public TriggerButton CurrentButton
{ {
get => current; get => current;
} }
public Vec2 Position public Vec2 Position { get; set; }
{
get;
set;
}
protected List<TriggerButton> AllButton protected List<TriggerButton> AllButton
{ {
@@ -60,8 +60,7 @@ namespace StgSharp.Controls
this.length = length; this.length = length;
displayIndex = new char[length]; displayIndex = new char[length];
_tittleMesh = tittleMesh; _tittleMesh = tittleMesh;
texIndex = indexEnumeration.ToDictionary( texIndex = indexEnumeration.ToDictionary( item => item.Item1, item => item.Item2 );
item => item.Item1, item => item.Item2 );
} }
public bool IsEntity public bool IsEntity
@@ -42,27 +42,13 @@ namespace StgSharp.Controls
public interface ControllingItem : IEnumerable<PlainGeometryMesh> public interface ControllingItem : IEnumerable<PlainGeometryMesh>
{ {
public abstract bool IsEntity public abstract bool IsEntity { get; }
{
get;
}
public abstract ReadOnlySpan<Vec4> TextureBox public abstract ReadOnlySpan<Vec4> TextureBox { get; }
{
get;
}
public abstract Rectangle BoundingBox public abstract Rectangle BoundingBox { get; set; }
{
get;
set;
}
public abstract Vec2 Position public abstract Vec2 Position { get; set; }
{
get;
set;
}
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
@@ -57,17 +57,9 @@ namespace StgSharp.Controls
get => renderMesh.TextureCoord; get => renderMesh.TextureCoord;
} }
public Rectangle BoundingBox public Rectangle BoundingBox { get; set; }
{
get;
set;
}
public Vec2 Position public Vec2 Position { get; set; }
{
get;
set;
}
public IEnumerator<PlainGeometryMesh> GetEnumerator() public IEnumerator<PlainGeometryMesh> GetEnumerator()
{ {
@@ -63,17 +63,9 @@ namespace StgSharp.Controls
get => marker.TextureCoord; get => marker.TextureCoord;
} }
public Rectangle BoundingBox public Rectangle BoundingBox { get; set; }
{
get;
set;
}
public Vec2 Position public Vec2 Position { get; set; }
{
get;
set;
}
public IEnumerator<PlainGeometryMesh> GetEnumerator() public IEnumerator<PlainGeometryMesh> GetEnumerator()
{ {
@@ -106,9 +106,11 @@ namespace StgSharp.Controls
{ {
add add
{ {
if( _renderButton == null ) { if( _renderButton == null )
{
_renderButton = value; _renderButton = value;
} else { } else
{
_renderButton += value; _renderButton += value;
} }
} }
@@ -120,17 +122,9 @@ namespace StgSharp.Controls
} }
} }
public bool IsHighLighted public bool IsHighLighted { get; internal set; }
{
get;
internal set;
}
public bool IsDisabled public bool IsDisabled { get; internal set; }
{
get;
internal set;
}
public bool IsEntity => true; public bool IsEntity => true;
@@ -139,41 +133,17 @@ namespace StgSharp.Controls
get => MemoryMarshal.Cast<Vec2, Vec4>( _texture.TextureCoordinate ); get => MemoryMarshal.Cast<Vec2, Vec4>( _texture.TextureCoordinate );
} }
public Rectangle BoundingBox public Rectangle BoundingBox { get; set; }
{
get;
set;
}
public TriggerButton Left public TriggerButton Left { get; internal set; }
{
get;
internal set;
}
public TriggerButton Right public TriggerButton Right { get; internal set; }
{
get;
internal set;
}
public TriggerButton Up public TriggerButton Up { get; internal set; }
{
get;
internal set;
}
public TriggerButton Down public TriggerButton Down { get; internal set; }
{
get;
internal set;
}
public Vec2 Position public Vec2 Position { get; set; }
{
get;
set;
}
internal TextureProvider Texture internal TextureProvider Texture
{ {
@@ -181,11 +151,7 @@ namespace StgSharp.Controls
set => _texture = value; set => _texture = value;
} }
protected ButtonStatus CurrentStatus protected ButtonStatus CurrentStatus { get; set; }
{
get;
set;
}
public void DeHighlight() public void DeHighlight()
{ {
@@ -209,9 +175,11 @@ namespace StgSharp.Controls
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 ) {
@@ -227,9 +195,11 @@ namespace StgSharp.Controls
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 ) {
@@ -37,15 +37,9 @@ namespace StgSharp.Controlling.UsrActivity
public interface IClickTrigger public interface IClickTrigger
{ {
public int TargetKeyOrButtonID public int TargetKeyOrButtonID { get; }
{
get;
}
public KeyStatus TriggeredStatus public KeyStatus TriggeredStatus { get; }
{
get;
}
} }
} }
@@ -70,16 +70,12 @@ namespace StgSharp.Controlling.UsrActivity
return $"Key {_stick} triggered when {_status}"; return $"Key {_stick} triggered when {_status}";
} }
public static bool operator !=( public static bool operator !=( JoystickTrigger left, JoystickTrigger right )
JoystickTrigger left,
JoystickTrigger right )
{ {
return !( left == right ); return !( left == right );
} }
public static bool operator ==( public static bool operator ==( JoystickTrigger left, JoystickTrigger right )
JoystickTrigger left,
JoystickTrigger right )
{ {
return ( left._status == right._status ) && ( left._stick == right._stick ); return ( left._status == right._status ) && ( left._stick == right._stick );
} }
@@ -73,7 +73,8 @@ namespace StgSharp.Controlling.UsrActivity
public static bool operator ==( KeyTrigger left, KeyTrigger right ) public static bool operator ==( KeyTrigger left, KeyTrigger right )
{ {
return ( left._triggerStat == right._triggerStat ) && ( left._targetKey == right._targetKey ); return ( left._triggerStat == right._triggerStat ) &&
( left._targetKey == right._targetKey );
} }
bool IEquatable<KeyTrigger>.Equals( KeyTrigger other ) bool IEquatable<KeyTrigger>.Equals( KeyTrigger other )
@@ -49,42 +49,31 @@ namespace StgSharp.Controlling.UsrActivity
private static KeyTrigger keyboardtemp; private static KeyTrigger keyboardtemp;
private static MouseTrigger mousetemp; private static MouseTrigger mousetemp;
public static JoystickTrigger BuildJoystickClickTrigger( public static JoystickTrigger BuildJoystickClickTrigger( int keyCode, KeyStatus status )
int keyCode,
KeyStatus status )
{ {
if( keyCode > MouseMin && keyCode < MouseMax ) { if( keyCode > MouseMin && keyCode < MouseMax ) {
return new JoystickTrigger( ( Joystick )keyCode, status ); return new JoystickTrigger( ( Joystick )keyCode, status );
} }
throw new InvalidOperationException( throw new InvalidOperationException( "Known key code or key is not on joystick." );
"Known key code or key is not on joystick." );
} }
public static KeyTrigger BuildKeyboardClickTrigger( public static KeyTrigger BuildKeyboardClickTrigger( int keyCode, KeyStatus status )
int keyCode,
KeyStatus status )
{ {
if( keyCode > KeyboardMin && keyCode < KeyboardMax ) { if( keyCode > KeyboardMin && keyCode < KeyboardMax ) {
return new KeyTrigger( ( KeyboardKey )keyCode, status ); return new KeyTrigger( ( KeyboardKey )keyCode, status );
} }
throw new InvalidOperationException( throw new InvalidOperationException( "Known key code or kay is not on keyboard." );
"Known key code or kay is not on keyboard." );
} }
public static MouseTrigger BuildMouseClickTrigger( public static MouseTrigger BuildMouseClickTrigger( int keyCode, KeyStatus status )
int keyCode,
KeyStatus status )
{ {
if( keyCode >= MouseMin && keyCode <= MouseMax ) { if( keyCode >= MouseMin && keyCode <= MouseMax ) {
return new MouseTrigger( ( Mouse )keyCode, status ); return new MouseTrigger( ( Mouse )keyCode, status );
} }
throw new InvalidOperationException( throw new InvalidOperationException( "Known key code or key is not on mouse." );
"Known key code or key is not on mouse." );
} }
public static IClickTrigger BuildTrigger( public static IClickTrigger BuildTrigger( int keyCode, KeyStatus status )
int keyCode,
KeyStatus status )
{ {
if( keyCode > KeyboardMin && keyCode < KeyboardMax ) { if( keyCode > KeyboardMin && keyCode < KeyboardMax ) {
return new KeyTrigger( ( KeyboardKey )keyCode, status ); return new KeyTrigger( ( KeyboardKey )keyCode, status );
+1 -1
View File
@@ -38,7 +38,7 @@ using System.Threading.Tasks;
namespace StgSharp namespace StgSharp
{ {
public static unsafe partial class StgSharp public static unsafe partial class World
{ {
private static byte leastUnusedArea; private static byte leastUnusedArea;
+2 -1
View File
@@ -66,7 +66,8 @@ namespace StgSharp.Internal
public unsafe byte[] GetBytes() public unsafe byte[] GetBytes()
{ {
byte[] ret = new byte[16]; byte[] ret = new byte[16];
fixed( M128* vptr = &data ) { fixed( M128* vptr = &data )
{
byte* bptr = ( byte* )vptr; byte* bptr = ( byte* )vptr;
for( int i = 0; i < 15; i++ ) { for( int i = 0; i < 15; i++ ) {
ret[ i ] = *bptr; ret[ i ] = *bptr;
+24 -19
View File
@@ -44,12 +44,11 @@ using System.Threading.Tasks;
namespace StgSharp.Internal namespace StgSharp.Internal
{ {
[StructLayout( LayoutKind.Explicit, Size = StgSharp.ssdSegmentLength * 16 )] [StructLayout( LayoutKind.Explicit, Size = World.ssdSegmentLength * 16 )]
public unsafe struct SSDSegment : IComparable<int>, IComparable<SSDSegment> public unsafe struct SSDSegment : IComparable<int>, IComparable<SSDSegment>
{ {
[FieldOffset( 16 )] public fixed byte Data[ [FieldOffset( 16 )] public fixed byte Data[ 16 * ( World.ssdSegmentLength - 1 ) ];
16 * ( StgSharp.ssdSegmentLength - 1 ) ];
[FieldOffset( 12 )] public int DataHash; [FieldOffset( 12 )] public int DataHash;
[FieldOffset( 8 )] public int PreviousHash; [FieldOffset( 8 )] public int PreviousHash;
[FieldOffset( 0 * 16 )] public SSDSegmentHead Head; [FieldOffset( 0 * 16 )] public SSDSegmentHead Head;
@@ -63,7 +62,7 @@ namespace StgSharp.Internal
{ {
get get
{ {
if( index > ( 16 * ( StgSharp.ssdSegmentLength - 1 ) ) - 1 ) { if( index > ( 16 * ( World.ssdSegmentLength - 1 ) ) - 1 ) {
throw new IndexOutOfRangeException(); throw new IndexOutOfRangeException();
} }
return Data[ index ]; return Data[ index ];
@@ -71,7 +70,7 @@ namespace StgSharp.Internal
set set
{ {
if( index > ( 16 * ( StgSharp.ssdSegmentLength - 1 ) ) - 1 ) { if( index > ( 16 * ( World.ssdSegmentLength - 1 ) ) - 1 ) {
throw new IndexOutOfRangeException(); throw new IndexOutOfRangeException();
} }
Data[ index ] = value; Data[ index ] = value;
@@ -98,15 +97,15 @@ namespace StgSharp.Internal
public static SSDSegment FromStream( byte[] stream ) public static SSDSegment FromStream( byte[] stream )
{ {
if( stream.Length != 16 * StgSharp.ssdSegmentLength ) { if( stream.Length != 16 * World.ssdSegmentLength ) {
throw new ArgumentException(); throw new ArgumentException();
} }
SSDSegment ret = new SSDSegment(); SSDSegment ret = new SSDSegment();
fixed( byte* bptr = stream ) { fixed( byte* bptr = stream )
{
ret.Head.data = *( M128* )bptr; ret.Head.data = *( M128* )bptr;
for( int i = 1; i < StgSharp.ssdSegmentLength; i++ ) { for( int i = 1; i < World.ssdSegmentLength; i++ ) {
ret.WriteData<M128>( ret.WriteData<M128>( i - 1, *( M128* )( bptr + ( 16 * i ) ) );
i - 1, *( M128* )( bptr + ( 16 * i ) ) );
} }
} }
return ret; return ret;
@@ -114,9 +113,11 @@ namespace StgSharp.Internal
public byte[] GetBytes() public byte[] GetBytes()
{ {
byte[] ret = new byte[16 * StgSharp.ssdSegmentLength]; byte[] ret = new byte[16 * World.ssdSegmentLength];
fixed( M128* mptr = &Head.data ) { fixed( M128* mptr = &Head.data )
fixed( byte* aptr = ret ) { {
fixed( byte* aptr = ret )
{
Vector4* vsptr = ( Vector4* )mptr; Vector4* vsptr = ( Vector4* )mptr;
Vector4* vtptr = ( Vector4* )aptr; Vector4* vtptr = ( Vector4* )aptr;
for( int i = 0; i < 18; i++ ) { for( int i = 0; i < 18; i++ ) {
@@ -131,9 +132,10 @@ namespace StgSharp.Internal
public int GetDataHash() public int GetDataHash()
{ {
Vector4 v = Vector4.One; Vector4 v = Vector4.One;
fixed( M128* mptr = &Head.data ) { fixed( M128* mptr = &Head.data )
{
Vector4* vptr = ( Vector4* )mptr; Vector4* vptr = ( Vector4* )mptr;
for( int i = 0; i < StgSharp.ssdSegmentLength - 1; i += 1 ) { for( int i = 0; i < World.ssdSegmentLength - 1; i += 1 ) {
v += ( *vptr ) * 31; v += ( *vptr ) * 31;
} }
} }
@@ -145,9 +147,10 @@ namespace StgSharp.Internal
public override int GetHashCode() public override int GetHashCode()
{ {
int ret = 17; int ret = 17;
fixed( M128* mptr = &Head.data ) { fixed( M128* mptr = &Head.data )
{
Vector4* vptr = ( Vector4* )mptr; Vector4* vptr = ( Vector4* )mptr;
for( int i = 0; i < StgSharp.ssdSegmentLength; i++ ) { for( int i = 0; i < World.ssdSegmentLength; i++ ) {
ret = ( ret + ( *vptr ).GetHashCode() ) * 31; ret = ( ret + ( *vptr ).GetHashCode() ) * 31;
} }
} }
@@ -156,7 +159,8 @@ namespace StgSharp.Internal
public unsafe T ReadData<T>( int index ) where T: struct public unsafe T ReadData<T>( int index ) where T: struct
{ {
fixed( byte* bptr = Data ) { fixed( byte* bptr = Data )
{
T* tptr = ( T* )bptr; T* tptr = ( T* )bptr;
return *( tptr + index ); return *( tptr + index );
} }
@@ -164,7 +168,8 @@ namespace StgSharp.Internal
public unsafe void WriteData<T>( int index, T value ) where T: struct public unsafe void WriteData<T>( int index, T value ) where T: struct
{ {
fixed( byte* bptr = Data ) { fixed( byte* bptr = Data )
{
T* tptr = ( T* )bptr; T* tptr = ( T* )bptr;
*( tptr + index ) = value; *( tptr + index ) = value;
} }
+1 -2
View File
@@ -58,8 +58,7 @@ namespace StgSharp.Internal
public static SSD FromFile( string fileRoute ) public static SSD FromFile( string fileRoute )
{ {
return new SSD( return new SSD( new FileStream( fileRoute, FileMode.Open, FileAccess.Read ) )
new FileStream( fileRoute, FileMode.Open, FileAccess.Read ) )
{ {
}; };
} }
+2 -10
View File
@@ -60,17 +60,9 @@ namespace StgSharp.Internal.FileIO
streamSource.Read( data.AsSpan() ); streamSource.Read( data.AsSpan() );
} }
public SSDrawHead Head public SSDrawHead Head { get; set; }
{
get;
set;
}
public string Name public string Name { get; set; }
{
get;
set;
}
} }
@@ -39,10 +39,7 @@ namespace StgSharp.Internal
public interface ISSDSerializable public interface ISSDSerializable
{ {
public SerializableTypeCode SSDTypeCode public SerializableTypeCode SSDTypeCode { get; }
{
get;
}
public byte[] GetBytes(); public byte[] GetBytes();
@@ -68,8 +65,7 @@ namespace StgSharp.Internal
public static partial class Serializer public static partial class Serializer
{ {
public static T Deserialize<T>( byte[] stream ) public static T Deserialize<T>( byte[] stream ) where T: ISSDSerializable
where T: ISSDSerializable
{ {
T serializableObject = Activator.CreateInstance<T>(); T serializableObject = Activator.CreateInstance<T>();
serializableObject.FromBytes( stream ); serializableObject.FromBytes( stream );
@@ -78,7 +74,8 @@ namespace StgSharp.Internal
public static string GetNameTail( SerializableTypeCode typeCode ) public static string GetNameTail( SerializableTypeCode typeCode )
{ {
switch( typeCode ) { switch( typeCode )
{
case SerializableTypeCode.IndexTable: case SerializableTypeCode.IndexTable:
return "_idt"; return "_idt";
case SerializableTypeCode.PixelImage: case SerializableTypeCode.PixelImage:
+7 -14
View File
@@ -41,13 +41,9 @@ namespace StgSharp.Data
public interface IValueBox public interface IValueBox
{ {
ref object ValueReference ref object ValueReference { get; }
{
get;
}
static virtual IValueBox<T> AsGeneric<T>( IValueBox box ) static virtual IValueBox<T> AsGeneric<T>( IValueBox box ) where T: struct
where T: struct
{ {
if( box is not IValueBox<T> genericBox ) { if( box is not IValueBox<T> genericBox ) {
return null; return null;
@@ -65,11 +61,7 @@ namespace StgSharp.Data
public interface IValueBox<T> where T: struct public interface IValueBox<T> where T: struct
{ {
T Value T Value { get; set; }
{
get;
set;
}
} }
@@ -77,7 +69,9 @@ namespace StgSharp.Data
/// A class attempt to reduce cost of boxing, though still a bit slower than direct access to /// A class attempt to reduce cost of boxing, though still a bit slower than direct access to
/// _origin value type instance. /// _origin value type instance.
/// </summary> /// </summary>
/// <typeparam name="T"> Type of instance to be boxed. </typeparam> /// <typeparam name="T">
/// Type of instance to be boxed.
/// </typeparam>
public class ValueBox<T> : IValueBox, IValueBox<T> where T: struct public class ValueBox<T> : IValueBox, IValueBox<T> where T: struct
{ {
@@ -88,8 +82,7 @@ namespace StgSharp.Data
_value = value; _value = value;
} }
public ref object ValueReference => ref Unsafe.As<T, object>( public ref object ValueReference => ref Unsafe.As<T, object>( ref _value );
ref _value );
public T Value public T Value
{ {
+3 -16
View File
@@ -28,7 +28,6 @@
// //
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
namespace StgSharp.Entities namespace StgSharp.Entities
{ {
public class Enemy : IEntity public class Enemy : IEntity
@@ -39,23 +38,11 @@ namespace StgSharp.Entities
internal Launcher<EntityPartical> _dieBulletLauncher; internal Launcher<EntityPartical> _dieBulletLauncher;
public bool _selectalbe; public bool _selectalbe;
public Launcher<EntityPartical> AwardLauncher public Launcher<EntityPartical> AwardLauncher { get; set; }
{
get;
set;
}
public Launcher<EntityPartical> CommonBulletLauncher public Launcher<EntityPartical> CommonBulletLauncher { get; set; }
{
get;
set;
}
public Launcher<EntityPartical> DieBulletLauncher public Launcher<EntityPartical> DieBulletLauncher { get; set; }
{
get;
set;
}
public override void OnRenderFrame() public override void OnRenderFrame()
{ {
+7 -22
View File
@@ -42,29 +42,21 @@ namespace StgSharp
protected uint _bornTick; protected uint _bornTick;
internal Func<int, Vec3> _movHandler; internal Func<int, Vec3> _movHandler;
internal LinkedList<PlainGeometry> _collisionBox; internal LinkedList<PlainGeometry> _collisionBox;
internal PlainGeometryCollisionSensor<PlainGeometry, PlainGeometry> _collisionSensor;
internal Point _basePoint; internal Point _basePoint;
internal Point _pos; internal Point _pos;
internal Point _position; internal Point _position;
internal PlainGeometryCollisionSensor<PlainGeometry, PlainGeometry> _collisionSensor;
internal string _texture; internal string _texture;
/// <summary> /// <summary>
/// X position of an enenmy entity /// X position of an enenmy entity
/// </summary> /// </summary>
public float X public float X { get; set; }
{
get;
set;
}
/// <summary> /// <summary>
/// Y position of an enemy entity /// Y position of an enemy entity
/// </summary> /// </summary>
public float Y public float Y { get; set; }
{
get;
set;
}
public LinkedList<PlainGeometry> CollisionBox public LinkedList<PlainGeometry> CollisionBox
{ {
@@ -81,20 +73,13 @@ namespace StgSharp
set => _collisionSensor = value; set => _collisionSensor = value;
} }
public string TextureGL public string TextureGL { get; set; }
{
get;
set;
}
/// <summary> /// <summary>
/// A 2D vector presenting the position of an enemy entity, position can also be visited by /// A 2D vector presenting the position of an enemy entity, position can also be visited
/// X, Y /// by X, Y
/// </summary> /// </summary>
public Vec2 Location public Vec2 Location { get; }
{
get;
}
public abstract void OnRenderFrame(); public abstract void OnRenderFrame();
+40 -46
View File
@@ -46,17 +46,21 @@ namespace StgSharp
private static Process? _dialogueProcess; private static Process? _dialogueProcess;
private static AnonymousPipeServerStream _dialogueClientPipe,_dialogueServerPipe; private static AnonymousPipeServerStream _dialogueClientPipe,_dialogueServerPipe;
private static ConcurrentBag<string> msgCache = new ConcurrentBag<string>( private static ConcurrentBag<string> msgCache = new ConcurrentBag<string>();
);
private static int _readAndWriteThreadId; private static int _readAndWriteThreadId;
private static ProcessStartInfo _dialogueProcessInfo; private static ProcessStartInfo _dialogueProcessInfo;
private static StreamReader _dr; private static StreamReader _dr;
private static StreamWriter _dw; private static StreamWriter _dw;
public static bool NeedShowWhenStartup public static bool NeedShowWhenStartup { get; set; }
public static void PostError( Exception ex )
{ {
get; CreateDialogueProcessIfNotExist();
set;
_dw.WriteLine( $"posterror {ex.Message}" );
_dialogueProcess!.Exited -= DialogueProcessExitCallback;
} }
public static void SetReadAndWriteThread( Thread thread ) public static void SetReadAndWriteThread( Thread thread )
@@ -64,23 +68,12 @@ namespace StgSharp
_readAndWriteThreadId = thread.ManagedThreadId; _readAndWriteThreadId = thread.ManagedThreadId;
} }
private static void AssertThread()
{
if (_readAndWriteThreadId != Environment.CurrentManagedThreadId)
{
throw new InvalidOperationException("Communication with dialogue can only call from certain thread.");
}
}
internal static void CreateDialogueProcessIfNotExist() internal static void CreateDialogueProcessIfNotExist()
{ {
if( _dialogueProcess != null ) { if( _dialogueProcess != null ) {
return; return;
} }
if (!File.Exists(_dialogueProcessInfo.FileName)) if( !File.Exists( _dialogueProcessInfo.FileName ) ) { }
{
}
_dialogueProcess = Process.Start( _dialogueProcessInfo ); _dialogueProcess = Process.Start( _dialogueProcessInfo );
_dr = new StreamReader( _dialogueClientPipe ); _dr = new StreamReader( _dialogueClientPipe );
@@ -92,13 +85,6 @@ namespace StgSharp
_dialogueClientPipe.DisposeLocalCopyOfClientHandle(); _dialogueClientPipe.DisposeLocalCopyOfClientHandle();
} }
private static void DialogueProcessExitCallback(object? sender, EventArgs e)
{
_dialogueProcess = null;
_dr.Close();
_dw.Close();
}
internal static void LoadDialogue() internal static void LoadDialogue()
{ {
_dialogueServerPipe = new AnonymousPipeServerStream( _dialogueServerPipe = new AnonymousPipeServerStream(
@@ -106,21 +92,25 @@ namespace StgSharp
_dialogueClientPipe = new AnonymousPipeServerStream( _dialogueClientPipe = new AnonymousPipeServerStream(
PipeDirection.In, HandleInheritability.Inheritable ); PipeDirection.In, HandleInheritability.Inheritable );
string route = Assembly.GetAssembly( typeof( StgSharp ) ).Location; string route = Assembly.GetAssembly( typeof( World ) ).Location;
string path = Path.GetDirectoryName( route ); string path = Path.GetDirectoryName( route );
string exeName; string exeName;
if( RuntimeInformation.IsOSPlatform( OSPlatform.Windows ) ) { if( RuntimeInformation.IsOSPlatform( OSPlatform.Windows ) )
{
exeName = ".exe"; exeName = ".exe";
} else if( RuntimeInformation.IsOSPlatform( OSPlatform.Linux ) || RuntimeInformation.IsOSPlatform( } else if( RuntimeInformation.IsOSPlatform( OSPlatform.Linux ) ||
OSPlatform.OSX ) ) { RuntimeInformation.IsOSPlatform( OSPlatform.OSX ) )
{
exeName = string.Empty; exeName = string.Empty;
} else { } else
{
throw new PlatformNotSupportedException( "Unknown OS platform" ); throw new PlatformNotSupportedException( "Unknown OS platform" );
} }
string consoleRoute = Path.Combine(path, @"StgSharpTerminalDialogue", $@"StgSharpTerminalDialogue{exeName}"); string consoleRoute = Path.Combine(
path, @"StgSharpTerminalDialogue", $@"StgSharpTerminalDialogue{exeName}" );
_dialogueProcessInfo = new ProcessStartInfo _dialogueProcessInfo = new ProcessStartInfo
{ {
@@ -129,26 +119,13 @@ namespace StgSharp
UseShellExecute = true, UseShellExecute = true,
RedirectStandardOutput = false, RedirectStandardOutput = false,
}; };
} }
internal static void PostMessage( internal static void PostMessage( string instruction, params string[] operands )
string instruction,
params string[] operands)
{ {
CreateDialogueProcessIfNotExist(); CreateDialogueProcessIfNotExist();
_dw.WriteLine( $"{instruction} {operands}" ); _dw.WriteLine( $"{instruction} {operands}" );
}
public static void PostError(Exception ex)
{
CreateDialogueProcessIfNotExist();
_dw.WriteLine($"posterror {ex.Message}");
_dialogueProcess!.Exited -= DialogueProcessExitCallback;
} }
internal static void UnloadDialogue() internal static void UnloadDialogue()
@@ -169,10 +146,12 @@ namespace StgSharp
} }
string temp = string .Empty; string temp = string .Empty;
do { do
{
temp = _dr.ReadLine(); temp = _dr.ReadLine();
temp = temp ?? string.Empty; temp = temp ?? string.Empty;
if( !temp!.StartsWith( target ) ) { if( !temp!.StartsWith( target ) )
{
break; break;
} }
} while (true); } while (true);
@@ -181,5 +160,20 @@ namespace StgSharp
return index != -1 ? temp.Substring( index + 1 ) : string.Empty; return index != -1 ? temp.Substring( index + 1 ) : string.Empty;
} }
private static void AssertThread()
{
if( _readAndWriteThreadId != Environment.CurrentManagedThreadId ) {
throw new InvalidOperationException(
"Communication with dialogue can only call from certain thread." );
}
}
private static void DialogueProcessExitCallback( object? sender, EventArgs e )
{
_dialogueProcess = null;
_dr.Close();
_dw.Close();
}
} }
} }
+3 -3
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// file="GlobalSetting.cs" // file="GlobalSetting.cs"
// Project: StgSharp // Project: World
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
@@ -39,7 +39,7 @@ using System.Threading.Tasks;
namespace StgSharp namespace StgSharp
{ {
public static unsafe partial class StgSharp public static unsafe partial class World
{ {
internal const int ssdSegmentLength = 16; internal const int ssdSegmentLength = 16;
@@ -74,7 +74,7 @@ namespace StgSharp
/// <summary> /// <summary>
/// CustomizeInit an instance of OpenGL program, This method should be called before any /// CustomizeInit an instance of OpenGL program, This method should be called before any
/// other StgSharp api. /// other World api.
/// </summary> /// </summary>
public static void InitGL( int majorVersion, int minorVersion ) public static void InitGL( int majorVersion, int minorVersion )
{ {
+4 -4
View File
@@ -39,7 +39,7 @@ using System.Threading.Tasks;
namespace StgSharp namespace StgSharp
{ {
public static partial class StgSharp public static partial class World
{ {
private static unsafe IntPtr[] monitorsArray; private static unsafe IntPtr[] monitorsArray;
@@ -48,12 +48,12 @@ namespace StgSharp
{ {
get get
{ {
if( monitorsArray == null ) { if( monitorsArray == null )
{
int count = 0; int count = 0;
IntPtr* arrayhandle = InternalIO.glfwGetMonitors( &count ); IntPtr* arrayhandle = InternalIO.glfwGetMonitors( &count );
monitorsArray = new IntPtr[count]; monitorsArray = new IntPtr[count];
Marshal.Copy( Marshal.Copy( ( IntPtr )arrayhandle, monitorsArray, 0, count );
( IntPtr )arrayhandle, monitorsArray, 0, count );
Marshal.FreeHGlobal( ( IntPtr )arrayhandle ); Marshal.FreeHGlobal( ( IntPtr )arrayhandle );
} }
return monitorsArray; return monitorsArray;
+22 -19
View File
@@ -28,11 +28,6 @@
// //
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// using StgSharp.Envitronment;
// using StgSharp.Envitronment.Win32;
// using StgSharp.Graphics;
// using StgSharp.Math;
using StgSharp.Internal; using StgSharp.Internal;
using StgSharp.Internal.Intrinsic; using StgSharp.Internal.Intrinsic;
@@ -71,11 +66,11 @@ namespace StgSharp
} }
public static partial class StgSharp public static partial class World
{ {
/// <summary> /// <summary>
/// Version of current StgSharp platform. Main version represent in hundred's digit, and sub /// Version of current World platform. Main version represent in hundred's digit, and sub
/// version represent in ten's digit. /// version represent in ten's digit.
/// </summary> /// </summary>
public const long version = 430; public const long version = 430;
@@ -92,8 +87,7 @@ namespace StgSharp
InternalIO.glfwInit(); InternalIO.glfwInit();
InternalIO.InternalAppendLog( "\n\n\n" ); InternalIO.InternalAppendLog( "\n\n\n" );
InternalIO.InternalWriteLog( InternalIO.InternalWriteLog(
$"Program {Assembly.GetEntryAssembly()!.FullName} Started.", $"Program {Assembly.GetEntryAssembly()!.FullName} Started.", LogType.Info );
LogType.Info );
_mainThreadID = Environment.CurrentManagedThreadId; _mainThreadID = Environment.CurrentManagedThreadId;
@@ -122,8 +116,7 @@ namespace StgSharp
public static void LogWarning( Exception notVerySeriesException ) public static void LogWarning( Exception notVerySeriesException )
{ {
InternalIO.InternalWriteLog( InternalIO.InternalWriteLog( notVerySeriesException.Message, LogType.Warning );
notVerySeriesException.Message, LogType.Warning );
} }
public static void Mark( bool needConsole ) public static void Mark( bool needConsole )
@@ -159,9 +152,11 @@ namespace StgSharp
} }
log += $"Tracking at:\n{filePath}\t{callerName}\tline {lineNumber}\n"; log += $"Tracking at:\n{filePath}\t{callerName}\tline {lineNumber}\n";
log += $"Additional information:\n{message}\n"; log += $"Additional information:\n{message}\n";
if( isConsole ) { if( isConsole )
{
Console.WriteLine( log ); Console.WriteLine( log );
} else { } else
{
InternalIO.InternalWriteLog( log, LogType.Info ); InternalIO.InternalWriteLog( log, LogType.Info );
} }
} }
@@ -169,8 +164,12 @@ namespace StgSharp
/// <summary> /// <summary>
/// Write a log message to log file, and mark the _level of this message. /// Write a log message to log file, and mark the _level of this message.
/// </summary> /// </summary>
/// <param _name="message"> A string contains information of how current evironment runs. </param> /// <param _label="message">
/// <param _name="logType"> The severity of current message. </param> /// A string contains information of how current evironment runs.
/// </param>
/// <param _label="logType">
/// The severity of current message.
/// </param>
[MethodImpl( MethodImplOptions.AggressiveInlining )] [MethodImpl( MethodImplOptions.AggressiveInlining )]
public static void WriteLog( string message, LogType logType ) public static void WriteLog( string message, LogType logType )
{ {
@@ -183,10 +182,12 @@ namespace StgSharp
throw new InvalidCastException( throw new InvalidCastException(
"Failed to convert api, the function pointer is zero." ); "Failed to convert api, the function pointer is zero." );
} }
try { try
{
return Marshal.GetDelegateForFunctionPointer<TDele>( funcPtr ); return Marshal.GetDelegateForFunctionPointer<TDele>( funcPtr );
} }
catch( Exception ) { catch( Exception )
{
throw; throw;
} }
} }
@@ -197,10 +198,12 @@ namespace StgSharp
throw new InvalidCastException( throw new InvalidCastException(
"Failed to convert api, the function pointer is zero." ); "Failed to convert api, the function pointer is zero." );
} }
try { try
{
return Marshal.GetDelegateForFunctionPointer( funcPtr, T ); return Marshal.GetDelegateForFunctionPointer( funcPtr, T );
} }
catch( Exception ) { catch( Exception )
{
throw; throw;
} }
} }
+1 -1
View File
@@ -37,7 +37,7 @@ using System.Threading.Tasks;
namespace StgSharp namespace StgSharp
{ {
public static partial class StgSharp public static partial class World
{ {
private static ConcurrentDictionary<int, KeyStatus> keyListener private static ConcurrentDictionary<int, KeyStatus> keyListener
@@ -41,22 +41,16 @@ namespace StgSharp.Geometries
{ {
private static PlainCoordinate statndardPlainCoordination = new PlainCoordinate( private static PlainCoordinate statndardPlainCoordination = new PlainCoordinate(
null, new Point( 0, 0, 0 ), new Vec3( 1, 0, 0 ), null, new Point( 0, 0, 0 ), new Vec3( 1, 0, 0 ), new Vec3( 0, 1, 0 ) );
new Vec3( 0, 1, 0 ) );
public PlainCoordinate( public PlainCoordinate( CoordinationBase local, Point origin, Vec3 xAxis, Vec3 yAxis )
CoordinationBase local,
Point origin,
Vec3 xAxis,
Vec3 yAxis )
: base( local ) : base( local )
{ {
CoordMat = Matrix44.Unit; CoordMat = Matrix44.Unit;
CoordMat.colum0 = new Vec4( xAxis, 0 ); CoordMat.colum0 = new Vec4( xAxis, 0 );
CoordMat.colum1 = new Vec4( yAxis, 0 ); CoordMat.colum1 = new Vec4( yAxis, 0 );
CoordMat.colum2 = new Vec4( CoordMat.colum2 = new Vec4( Linear.Normalize( Vec3.Cross( xAxis, yAxis ) ), 0 );
Linear.Normalize( Vec3.Cross( xAxis, yAxis ) ), 0 );
LocalOrigin = origin; LocalOrigin = origin;
} }
@@ -36,18 +36,14 @@ namespace StgSharp.Geometries
public unsafe class ToUpperDimensionException : Exception public unsafe class ToUpperDimensionException : Exception
{ {
protected ToUpperDimensionException( protected ToUpperDimensionException( SerializationInfo info, StreamingContext context )
SerializationInfo info,
StreamingContext context )
: base( info, context ) { } : base( info, context ) { }
public ToUpperDimensionException() { } public ToUpperDimensionException() { }
public ToUpperDimensionException( string message ) : base( message ) { } public ToUpperDimensionException( string message ) : base( message ) { }
public ToUpperDimensionException( public ToUpperDimensionException( string message, Exception innerException )
string message,
Exception innerException )
: base( message, innerException ) { } : base( message, innerException ) { }
} }
@@ -58,9 +54,7 @@ namespace StgSharp.Geometries
public class UnusedVertexException : Exception public class UnusedVertexException : Exception
{ {
protected UnusedVertexException( protected UnusedVertexException( SerializationInfo info, StreamingContext context )
SerializationInfo info,
StreamingContext context )
: base( info, context ) { } : base( info, context ) { }
public UnusedVertexException() { } public UnusedVertexException() { }
@@ -40,9 +40,7 @@ using System.Text;
namespace StgSharp.Geometries namespace StgSharp.Geometries
{ {
[UnmanagedFunctionPointer( CallingConvention.Cdecl )] [UnmanagedFunctionPointer( CallingConvention.Cdecl )]
public delegate Vec3 GeometryMotionDelegate( public delegate Vec3 GeometryMotionDelegate( TimeSpanProvider timeSource, out float rotation );
TimeSpanProvider timeSource,
out float rotation );
public class GeometryMotion public class GeometryMotion
{ {
@@ -60,14 +58,17 @@ namespace StgSharp.Geometries
{ {
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;
} }
@@ -88,25 +89,27 @@ namespace StgSharp.Geometries
{ {
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;
} else { } else
{
coord = vec; coord = vec;
rotation = rot; rotation = rot;
} }
} }
private static Vec3 defaultMotion( private static Vec3 defaultMotion( TimeSpanProvider provider, out float rotation )
TimeSpanProvider provider,
out float rotation )
{ {
rotation = 0; rotation = 0;
return Vec3.Zero; return Vec3.Zero;
+5 -20
View File
@@ -42,33 +42,18 @@ namespace StgSharp.Geometries
public interface IGeometry public interface IGeometry
{ {
public Point this[ int index ] public Point this[ int index ] { get; set; }
{
get;
set;
}
#pragma warning disable CA1819 #pragma warning disable CA1819
public Vec4[] VertexStream public Vec4[] VertexStream
#pragma warning restore CA1819 #pragma warning restore CA1819
{ { get; }
get;
}
public CoordinationBase Coordination public CoordinationBase Coordination { get; }
{
get;
}
public int VertexCount public int VertexCount { get; }
{
get;
}
public ReadOnlySpan<int> VertexIndices public ReadOnlySpan<int> VertexIndices { get; }
{
get;
}
} }
} }
+15 -39
View File
@@ -43,53 +43,29 @@ namespace StgSharp.Geometries
public interface IInstancing public interface IInstancing
{ {
public float Rotation public float Rotation { get { return GlobalBuffer.CoordAndRotationList[ BufferId ].W; } set
{ {
get { return GlobalBuffer.CoordAndRotationList[ BufferId ].W; } Vec4 temp = GlobalBuffer.CoordAndRotationList[
set BufferId ];
{
Vec4 temp = GlobalBuffer.CoordAndRotationList[ BufferId ];
temp.W = value; temp.W = value;
GlobalBuffer.CoordAndRotationList[ BufferId ] = temp; GlobalBuffer.CoordAndRotationList[
} BufferId ] = temp;
} } }
public float Scale public float Scale { get { return GlobalBuffer.ScalingList[ BufferId ]; } set { GlobalBuffer.ScalingList[
{ BufferId ] = value; } }
get { return GlobalBuffer.ScalingList[ BufferId ]; }
set { GlobalBuffer.ScalingList[ BufferId ] = value; }
}
public GeometryMotion Motion public GeometryMotion Motion { get; set; }
{
get;
set;
}
public IInstancingBuffer GlobalBuffer public IInstancingBuffer GlobalBuffer { get; internal set; }
{
get;
internal set;
}
public int BufferId public int BufferId { get; internal set; }
{
get;
internal set;
}
public Vec3 CenterPositionGlobal public Vec3 CenterPositionGlobal { get; internal set; }
{
get;
internal set;
}
public Vec3 Coord public Vec3 Coord { get { return GlobalBuffer.CoordAndRotationList[ BufferId ].XYZ; } set { GlobalBuffer.CoordAndRotationList[
{ BufferId ] = new Vec4(
get { return GlobalBuffer.CoordAndRotationList[ BufferId ].XYZ; } value.reg ); } }
set { GlobalBuffer.CoordAndRotationList[ BufferId ] = new Vec4(
value.reg ); }
}
public void Move() public void Move()
{ {
@@ -39,35 +39,17 @@ namespace StgSharp.Geometries
public interface IInstancingBuffer public interface IInstancingBuffer
{ {
public Span<Vec4> CoordAndRotationSpan public Span<Vec4> CoordAndRotationSpan { get; }
{
get;
}
public Span<float> ScalingSpan public Span<float> ScalingSpan { get; }
{
get;
}
internal IGeometry TypicalShape internal IGeometry TypicalShape { get; }
{
get;
}
internal List<IInstancing> InstanceList internal List<IInstancing> InstanceList { get; }
{
get;
}
internal List<Vec4> CoordAndRotationList internal List<Vec4> CoordAndRotationList { get; }
{
get;
}
internal List<float> ScalingList internal List<float> ScalingList { get; }
{
get;
}
} }
} }
@@ -51,10 +51,7 @@ namespace StgSharp.Geometries
/// </summary> /// </summary>
public Vec3 origin; public Vec3 origin;
public PartialPlainCoordinate( public PartialPlainCoordinate( Vec3 origin, Vec3 horiziontial, Vec3 vertical )
Vec3 origin,
Vec3 horiziontial,
Vec3 vertical )
{ {
this.origin = origin; this.origin = origin;
axis = new Matrix32(); axis = new Matrix32();
@@ -41,11 +41,7 @@ namespace StgSharp.Geometries
public interface IPlainEntity public interface IPlainEntity
{ {
public Vec2 CenterPosition public Vec2 CenterPosition { get; set; }
{
get;
set;
}
public bool CollideWith( IPlainEntity entity ); public bool CollideWith( IPlainEntity entity );
@@ -53,29 +53,13 @@ namespace StgSharp.Geometries
( ( IInstancingBuffer )buffer ).InstanceList.Add( this ); ( ( IInstancingBuffer )buffer ).InstanceList.Add( this );
} }
public GeometryMotion Motion public GeometryMotion Motion { get; set; }
{
get;
set;
}
public IInstancingBuffer GlobalBuffer public IInstancingBuffer GlobalBuffer { get; set; }
{
get;
set;
}
public int BufferId public int BufferId { get; set; }
{
get;
set;
}
Vec3 IInstancing.CenterPositionGlobal Vec3 IInstancing.CenterPositionGlobal { get; set; }
{
get;
set;
}
bool IPlainEntity.CollideWith( IPlainEntity entity ) bool IPlainEntity.CollideWith( IPlainEntity entity )
{ {
@@ -58,10 +58,7 @@ namespace StgSharp.Geometries
public int VertexCount => this.vertexMat.Length; public int VertexCount => this.vertexMat.Length;
public abstract ReadOnlySpan<int> VertexIndices public abstract ReadOnlySpan<int> VertexIndices { get; }
{
get;
}
#pragma warning disable CA1819 #pragma warning disable CA1819
public Vec4[] VertexStream => vertexMat; public Vec4[] VertexStream => vertexMat;
@@ -85,12 +85,12 @@ namespace StgSharp.Geometries
{ {
get get
{ {
if( coordArray.Length != coordList.Capacity ) { if( coordArray.Length != coordList.Capacity )
{
FieldInfo fieldInfo = typeof( List<Vec4> ). FieldInfo fieldInfo = typeof( List<Vec4> ).
GetField( GetField( "_items", BindingFlags.NonPublic | BindingFlags.Instance );
"_items", if( fieldInfo == null )
BindingFlags.NonPublic | BindingFlags.Instance ); {
if( fieldInfo == null ) {
#pragma warning disable CA1065 #pragma warning disable CA1065
#pragma warning disable CA2201 #pragma warning disable CA2201
throw new NullReferenceException(); throw new NullReferenceException();
@@ -107,12 +107,12 @@ namespace StgSharp.Geometries
{ {
get get
{ {
if( scaleArray.Length != coordList.Capacity ) { if( scaleArray.Length != coordList.Capacity )
{
FieldInfo fieldInfo = typeof( List<float> ). FieldInfo fieldInfo = typeof( List<float> ).
GetField( GetField( "_items", BindingFlags.NonPublic | BindingFlags.Instance );
"_items", if( fieldInfo == null )
BindingFlags.NonPublic | BindingFlags.Instance ); {
if( fieldInfo == null ) {
#pragma warning disable CA1065 #pragma warning disable CA1065
#pragma warning disable CA2201 #pragma warning disable CA2201
throw new NullReferenceException(); throw new NullReferenceException();
@@ -167,8 +167,7 @@ namespace StgSharp.Geometries
temp.BufferId = instance.BufferId; temp.BufferId = instance.BufferId;
coordList[ instance.BufferId ] = coordList[ coordList.Count - 1 ]; coordList[ instance.BufferId ] = coordList[ coordList.Count - 1 ];
scalingList[ instance.BufferId ] = scalingList[ scalingList[ instance.BufferId ] = scalingList[ scalingList.Count - 1 ];
scalingList.Count - 1 ];
instanceList.RemoveAt( instanceList.Count - 1 ); instanceList.RemoveAt( instanceList.Count - 1 );
coordList.RemoveAt( coordList.Count - 1 ); coordList.RemoveAt( coordList.Count - 1 );
@@ -185,7 +184,8 @@ namespace StgSharp.Geometries
protected virtual void Dispose( bool disposing ) protected virtual void Dispose( bool disposing )
{ {
if( !disposedValue ) { if( !disposedValue )
{
if( disposing ) { if( disposing ) {
mutex.Dispose(); mutex.Dispose();
} }
@@ -204,8 +204,7 @@ namespace StgSharp.Geometries
} }
} }
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException( IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException();
);
#region field of mem opt #region field of mem opt
@@ -28,7 +28,6 @@
// //
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
using StgSharp.Math; using StgSharp.Math;
using System; using System;
@@ -55,7 +54,8 @@ namespace StgSharp.Geometries
: base( v0x, v0y, v1x, v1y, v2x, v2y, v3x, 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(
"Init of geometry item failed, because four vertices cannot form a rectangle.", "Init of geometry item failed, because four vertices cannot form a rectangle.",
LogType.Warning ); LogType.Warning );
@@ -76,7 +76,8 @@ namespace StgSharp.Geometries
: 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(
"Init of geometry item failed, because four vertices cannot form a rectangle.", "Init of geometry item failed, because four vertices cannot form a rectangle.",
LogType.Warning ); LogType.Warning );
@@ -28,7 +28,6 @@
// //
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
using StgSharp.Math; using StgSharp.Math;
using System; using System;
@@ -56,11 +55,7 @@ namespace StgSharp.Geometries
vertexMat = rawCoord; vertexMat = rawCoord;
} }
public Polygon4( public Polygon4( Point topLeft, Point topRight, Point bottomRight, Point bottomLeft )
Point topLeft,
Point topRight,
Point bottomRight,
Point bottomLeft )
: base( PlainCoordinate.StandardPlainCoordination ) : base( PlainCoordinate.StandardPlainCoordination )
{ {
this[ 0 ] = topLeft; this[ 0 ] = topLeft;
@@ -28,7 +28,6 @@
// //
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
using StgSharp.Math; using StgSharp.Math;
using System; using System;
@@ -28,7 +28,6 @@
// //
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
using StgSharp.Math; using StgSharp.Math;
using System; using System;
@@ -82,8 +82,12 @@ namespace StgSharp.Geometries
/// <summary> /// <summary>
/// Calculate movement to center /// Calculate movement to center
/// </summary> /// </summary>
/// <param _name="tick"> CurrentBlueprint time tick </param> /// <param _label="tick">
/// <returns></returns> /// CurrentPipeline time tick
/// </param>
/// <returns>
///
/// </returns>
public virtual Vec3 MovCenter( uint tick ) public virtual Vec3 MovCenter( uint tick )
{ {
return default( Vec3 ); return default( Vec3 );
@@ -28,7 +28,6 @@
// //
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
using StgSharp.Graphics; using StgSharp.Graphics;
using StgSharp.Math; using StgSharp.Math;
@@ -68,13 +67,7 @@ namespace StgSharp.Geometries
this[ 2 ] = vertex03; this[ 2 ] = vertex03;
} }
public Triangle( public Triangle( float v0x, float v0y, float v1x, float v1y, float v2x, float v2y )
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 );
+1 -1
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// file="Point.cs" // file="Point.cs"
// Project: StgSharp // Project: World
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
// //
@@ -0,0 +1,145 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="TriangulatedSurface.cs"
// Project: StepVisualizer
// 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.HighPerformance;
using StgSharp.Math;
using StgSharp.Math.HighPrecision;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Text;
namespace StgSharp.Geometries
{
public class TriangulatedSurface
{
private HashSet<(int begin,int end)> _sides;
private List<List<int>> _sideIndices;
private List<int> _triangleIndices;
private List<Vec3> _vertices;
public TriangulatedSurface()
{
_triangleIndices = new List<int>();
_vertices = new List<Vec3>();
_sides = new HashSet<(int,int)>();
_sideIndices = new List<List<int>>();
}
/**/
public IEnumerable<List<int>> SideIndicesEnumeratble
{
get => _sideIndices ;
}
/*
public Triangle GetTriangle( int index )
{
Vec3HP v1,v2,v3;
int t = index * 3;
v1 = _vertices[ t + 0 ];
v2 = _vertices[ t + 1 ];
v3 = _vertices[ t + 2 ];
return new Triangle( v1, v2, v3 );
}
/**/
public Span<Vec3> VertexSpan
{
get => CollectionsMarshal.AsSpan( _vertices );
}
public Span<int> TriangleIndicesSpan
{
get => CollectionsMarshal.AsSpan( _triangleIndices );
}
/**/
public void AddIndicesByOrder( int v1, int v2, int v3 )
{
_triangleIndices.Add( v1 );
_triangleIndices.Add( v2 );
_triangleIndices.Add( v3 );
if( !( _sides.Remove( (v1,v2) ) || _sides.Remove( (v2, v1) ) ) ) {
_sides.Add( (v1, v2) );
}
if( !( _sides.Remove( (v2, v3) ) || _sides.Remove( (v3, v2) ) ) ) {
_sides.Add( (v2, v3) );
}
if( !( _sides.Remove( (v3, v1) ) || _sides.Remove( (v1, v3) ) ) ) {
_sides.Add( (v3, v1) );
}
}
public void AddVertexByOrder( Vec3 vertex )
{
_vertices.Add( vertex );
}
public int TriangleCount()
{
return _triangleIndices.Count / 3;
}
public void TrimExcess()
{
_triangleIndices.TrimExcess();
_vertices.TrimExcess();
Dictionary<int, int> side_dictionary = _sides.ToDictionary( x => x.begin, x => x.end );
int begin = side_dictionary.First().Key;
List<int> sideLoop = new List<int>( begin );
_sideIndices.Add( sideLoop );
while( side_dictionary.Count > 0 )
{
if( side_dictionary.Remove( begin, out begin ) )
{
sideLoop.Add( begin );
} else
{
begin = side_dictionary.First().Key;
sideLoop = new List<int>( begin );
_sideIndices.Add( sideLoop );
}
}
_sideIndices.TrimExcess();
}
public int VertexCount()
{
return _vertices.Count;
}
}
}
+91 -11
View File
@@ -1,4 +1,34 @@
// This file is used by Code Analysis to maintain SuppressMessage //-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Global.cs"
// Project: StepVisualizer
// 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.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project. // attributes that are applied to this project.
// Project-level suppressions either have no target or are given // Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc. // a specific target and scoped to a namespace, type, member, etc.
@@ -9,13 +39,63 @@ global using StgSharp.Internal.OpenGL;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Design", "CA1008:枚举应具有零值", Justification = "<挂起>", Scope = "type", Target = "~T:StgSharp.Graphics.OpenGL.ShaderStatus")] [assembly: SuppressMessage(
[assembly: SuppressMessage("Naming", "CA1715:标识符应具有正确的前缀", Justification = "<挂起>", Scope = "member", Target = "~M:StgSharp.Graphics.OpenGL.ShaderProgram.GetUniform``2(System.String)~StgSharp.Graphics.OpenGL.Uniform{``0,``1}")] "Design",
[assembly: SuppressMessage("Naming", "CA1715:标识符应具有正确的前缀", Justification = "<挂起>", Scope = "member", Target = "~M:StgSharp.Graphics.OpenGL.ShaderProgram.GetUniform``3(System.String)~StgSharp.Graphics.OpenGL.Uniform{``0,``1,``2}")] "CA1008:枚举应具有零值",
[assembly: SuppressMessage("Naming", "CA1715:标识符应具有正确的前缀", Justification = "<挂起>", Scope = "member", Target = "~M:StgSharp.Graphics.OpenGL.ShaderProgram.GetUniform``4(System.String)~StgSharp.Graphics.OpenGL.Uniform{``0,``1,``2,``3}")] Justification = "<挂起>",
[assembly: SuppressMessage("Naming", "CA1715:标识符应具有正确的前缀", Justification = "<挂起>", Scope = "type", Target = "~T:StgSharp.Graphics.OpenGL.Uniform`4")] Scope = "type",
[assembly: SuppressMessage("Design", "CA1043:将整型或字符串参数用于索引器", Justification = "<挂起>", Scope = "member", Target = "~P:StgSharp.MVVM.View.ViewBase.IViewResponder`1.Item(StgSharp.Controlling.UsrActivity.ITrigger)")] Target = "~T:StgSharp.Graphics.OpenGL.ShaderStatus" )]
[assembly: SuppressMessage("Design", "CA1043:将整型或字符串参数用于索引器", Justification = "<挂起>", Scope = "member", Target = "~P:StgSharp.MVVM.View.ViewBase.ViewResponder`1.Item(StgSharp.Controlling.UsrActivity.ITrigger)")] [assembly: SuppressMessage(
[assembly: SuppressMessage("Performance", "CA1864:首选 \"IDictionary.TryAdd(TKey, TValue)\" 方法", Justification = "<挂起>", Scope = "member", Target = "~P:StgSharp.MVVM.View.ViewBase.ViewRender`1.Item(System.String)")] "Naming",
[assembly: SuppressMessage("Design", "CA1033:接口方法应可由子类型调用", Justification = "<挂起>", Scope = "member", Target = "~P:StgSharp.Collections.IBidirectionalDictionary`2.System#Collections#Generic#IDictionary<TFirst,TSecond>#Keys")] "CA1715:标识符应具有正确的前缀",
[assembly: SuppressMessage("Design", "CA1033:接口方法应可由子类型调用", Justification = "<挂起>", Scope = "member", Target = "~P:StgSharp.Collections.IBidirectionalDictionary`2.System#Collections#Generic#IDictionary<TFirst,TSecond>#Values")] Justification = "<挂起>",
Scope = "member",
Target = "~M:StgSharp.Graphics.OpenGL.ShaderProgram.GetUniform``2(System.String)~StgSharp.Graphics.OpenGL.Uniform{``0,``1}" )]
[assembly: SuppressMessage(
"Naming",
"CA1715:标识符应具有正确的前缀",
Justification = "<挂起>",
Scope = "member",
Target = "~M:StgSharp.Graphics.OpenGL.ShaderProgram.GetUniform``3(System.String)~StgSharp.Graphics.OpenGL.Uniform{``0,``1,``2}" )]
[assembly: SuppressMessage(
"Naming",
"CA1715:标识符应具有正确的前缀",
Justification = "<挂起>",
Scope = "member",
Target = "~M:StgSharp.Graphics.OpenGL.ShaderProgram.GetUniform``4(System.String)~StgSharp.Graphics.OpenGL.Uniform{``0,``1,``2,``3}" )]
[assembly: SuppressMessage(
"Naming",
"CA1715:标识符应具有正确的前缀",
Justification = "<挂起>",
Scope = "type",
Target = "~T:StgSharp.Graphics.OpenGL.Uniform`4" )]
[assembly: SuppressMessage(
"Design",
"CA1043:将整型或字符串参数用于索引器",
Justification = "<挂起>",
Scope = "member",
Target = "~P:StgSharp.MVVM.ViewBase.IViewResponder`1.Item(StgSharp.Controlling.UsrActivity.ITrigger)" )]
[assembly: SuppressMessage(
"Design",
"CA1043:将整型或字符串参数用于索引器",
Justification = "<挂起>",
Scope = "member",
Target = "~P:StgSharp.MVVM.ViewBase.ViewResponder`1.Item(StgSharp.Controlling.UsrActivity.ITrigger)" )]
[assembly: SuppressMessage(
"Performance",
"CA1864:首选 \"IDictionary.TryAdd(TKey, TValue)\" 方法",
Justification = "<挂起>",
Scope = "member",
Target = "~P:StgSharp.MVVM.ViewBase.ViewRender`1.Item(System.String)" )]
[assembly: SuppressMessage(
"Design",
"CA1033:接口方法应可由子类型调用",
Justification = "<挂起>",
Scope = "member",
Target = "~P:StgSharp.Collections.IBidirectionalDictionary`2.System#Collections#Generic#IDictionary<TFirst,TSecond>#Keys" )]
[assembly: SuppressMessage(
"Design",
"CA1033:接口方法应可由子类型调用",
Justification = "<挂起>",
Scope = "member",
Target = "~P:StgSharp.Collections.IBidirectionalDictionary`2.System#Collections#Generic#IDictionary<TFirst,TSecond>#Values" )]
@@ -38,11 +38,7 @@ namespace StgSharp.Graphics
public static class ImageHelper public static class ImageHelper
{ {
public static void Resize( public static void Resize( Image i, int width, int height, ImageMovement move )
Image i,
int width,
int height,
ImageMovement move )
{ {
if( i == null ) { if( i == null ) {
throw new ArgumentNullException( nameof( i ) ); throw new ArgumentNullException( nameof( i ) );
@@ -58,7 +54,8 @@ namespace StgSharp.Graphics
i.Height = height; i.Height = height;
i.Width = width; i.Width = width;
i.PixelUpdateCount++; i.PixelUpdateCount++;
switch( move ) { switch( move )
{
case ImageMovement.Discard: case ImageMovement.Discard:
break; break;
case ImageMovement.Top: case ImageMovement.Top:
@@ -50,14 +50,20 @@ namespace StgSharp.Graphics
/// <summary> /// <summary>
/// Get the only handle to one of the Object instance /// Get the only handle to one of the Object instance
/// </summary> /// </summary>
/// <param _name="index"></param> /// <param _label="index">
/// <returns></returns> ///
/// </param>
/// <returns>
///
/// </returns>
public GlHandle this[ int index ] => _bufferHandle[ index ]; public GlHandle this[ int index ] => _bufferHandle[ index ];
/// <summary> /// <summary>
/// Bind a Buffer instance to OpenGL /// Bind a Buffer instance to OpenGL
/// </summary> /// </summary>
/// <param _name="index"> Index of handle of the object in this instance to be bind </param> /// <param _label="index">
/// Index of handle of the object in this instance to be bind
/// </param>
public abstract void Bind( int index ); public abstract void Bind( int index );
public void Dispose() public void Dispose()

Some files were not shown because too many files have changed in this diff Show More