38 lines
1.4 KiB
C++
38 lines
1.4 KiB
C++
#include <tools.h>
|
||
using namespace std;
|
||
/**
|
||
* @brief 创建并打开SQLite数据库连接
|
||
* @param db_path 数据库文件路径
|
||
* @param overwrite_file 若为true则删除已有文件后创建新数据库
|
||
* @return 成功返回sqlite3句柄,失败返回NULL
|
||
*/
|
||
sqlite3* create_db(const char* db_path, bool overwrite_file);
|
||
|
||
/**
|
||
* @brief 在指定数据库中创建必要表结构
|
||
* @param db 已打开的SQLite数据库句柄
|
||
* @note 需确保db参数有效且已成功打开
|
||
*/
|
||
void create_tables(sqlite3* db);
|
||
|
||
|
||
///////////////////////////
|
||
//////// 数据保存 /////////
|
||
///////////////////////////
|
||
|
||
/**
|
||
* @brief 将网格数据元信息保存到数据库表
|
||
* @param ctx FTT上下文句柄,包含日志/错误处理等公共资源
|
||
* @param db 已打开的SQLite数据库连接
|
||
* @param name 网格名称(唯一标识)
|
||
* @param vertex_count 顶点数量
|
||
* @param index_count 索引数量
|
||
* @param fbx_id 关联的FBX文件ID
|
||
* @return 成功返回SQLITE_OK,失败返回SQLite错误码(<0)
|
||
* @note 1. 参数需确保有效:ctx/db非NULL,name/fbx_id非空
|
||
* 2. 内部自动处理事务,重复name会触发唯一键冲突
|
||
*/
|
||
int save_mesh_to_table(FttContext* ctx, sqlite3 *db, uint id, const std::string &name, int vertex_count, int index_count, const std::string &fbx_id);
|
||
|
||
int save_mesh_vertices(FttContext* ctx, uint mesh_id, std::vector<V3> vertices);
|
||
int save_mesh_indices(FttContext* ctx, uint mesh_id, std::vector<V3> indices); |