-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathMeshHandler.cs
More file actions
74 lines (63 loc) · 3.06 KB
/
Copy pathMeshHandler.cs
File metadata and controls
74 lines (63 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Text;
using Microsoft.Data.Sqlite;
using UnityDataTools.Analyzer.SerializedObjects;
using UnityDataTools.FileSystem.TypeTreeReaders;
namespace UnityDataTools.Analyzer.SQLite.Handlers;
public class MeshHandler : ISQLiteHandler
{
SqliteCommand m_InsertCommand;
public void Init(SqliteConnection db)
{
using var command = db.CreateCommand();
command.CommandText = Resources.Mesh;
command.ExecuteNonQuery();
m_InsertCommand = db.CreateCommand();
m_InsertCommand.CommandText = "INSERT INTO meshes(id, sub_meshes, blend_shapes, bones, indices, vertices, compression, rw_enabled, vertex_size, channels) VALUES(@id, @sub_meshes, @blend_shapes, @bones, @indices, @vertices, @compression, @rw_enabled, @vertex_size, @channels)";
m_InsertCommand.Parameters.Add("@id", SqliteType.Integer);
m_InsertCommand.Parameters.Add("@sub_meshes", SqliteType.Integer);
m_InsertCommand.Parameters.Add("@blend_shapes", SqliteType.Integer);
m_InsertCommand.Parameters.Add("@bones", SqliteType.Integer);
m_InsertCommand.Parameters.Add("@indices", SqliteType.Integer);
m_InsertCommand.Parameters.Add("@vertices", SqliteType.Integer);
m_InsertCommand.Parameters.Add("@compression", SqliteType.Integer);
m_InsertCommand.Parameters.Add("@rw_enabled", SqliteType.Integer);
m_InsertCommand.Parameters.Add("@vertex_size", SqliteType.Integer);
m_InsertCommand.Parameters.Add("@channels", SqliteType.Text);
}
public void Process(Context ctx, long objectId, RandomAccessReader reader, out string name, out long streamDataSize)
{
var mesh = Mesh.Read(reader);
m_InsertCommand.Transaction = ctx.Transaction;
m_InsertCommand.Parameters["@id"].Value = objectId;
m_InsertCommand.Parameters["@indices"].Value = mesh.Indices;
m_InsertCommand.Parameters["@vertices"].Value = mesh.Vertices;
m_InsertCommand.Parameters["@sub_meshes"].Value = mesh.SubMeshes;
m_InsertCommand.Parameters["@blend_shapes"].Value = mesh.BlendShapes;
m_InsertCommand.Parameters["@bones"].Value = mesh.Bones;
m_InsertCommand.Parameters["@compression"].Value = mesh.Compression;
m_InsertCommand.Parameters["@rw_enabled"].Value = mesh.RwEnabled;
m_InsertCommand.Parameters["@vertex_size"].Value = mesh.VertexSize;
StringBuilder channels = new StringBuilder();
foreach (var channel in mesh.Channels)
{
channels.Append(channel.Usage.ToString());
channels.Append(' ');
channels.Append(channel.Type.ToString());
channels.Append('[');
channels.Append(channel.Dimension);
channels.AppendLine("]");
}
m_InsertCommand.Parameters["@channels"].Value = channels.ToString();
m_InsertCommand.ExecuteNonQuery();
streamDataSize = mesh.StreamDataSize;
name = mesh.Name;
}
public void Finalize(SqliteConnection db)
{
}
void IDisposable.Dispose()
{
m_InsertCommand?.Dispose();
}
}