MiMoEngine ASM: x86-64 MASM汇编+C混合架构游戏引擎

核心热路径(数学/内存/字符串/性能分析)用MASM汇编(SSE/AVX2)
外围系统(窗口/渲染/ECS/音频/UI/脚本)用C语言
含自研编辑器、VisualScript积木编程、中文渲染(glyph_atlas)
This commit is contained in:
shuiyu1123 committed 2026-07-10 19:20:40 +08:00
commit 2d56cb3bc9
91 files changed
+9988

No files matched your search

+182
View File
@@ -0,0 +1,182 @@
#pragma once
// ============================================================================
// block_core.h - 积木核心数据结构
// ============================================================================
#include <stdint.h>
#include <stdbool.h>
#define MAX_BLOCK_INPUTS 8
#define MAX_BLOCK_OUTPUTS 8
#define MAX_BLOCK_LABEL 64
// 颜色
typedef struct {
float r, g, b, a;
} Color;
typedef Color BlockColor;
// 预定义颜色
#define BLOCK_COLOR_EVENT {0.9f, 0.2f, 0.2f, 1.0f} // 红
#define BLOCK_COLOR_ACTION {0.2f, 0.5f, 0.9f, 1.0f} // 蓝
#define BLOCK_COLOR_CONTROL {0.2f, 0.7f, 0.3f, 1.0f} // 绿
#define BLOCK_COLOR_OPERATOR {0.9f, 0.6f, 0.1f, 1.0f} // 橙
#define BLOCK_COLOR_VARIABLE {0.7f, 0.3f, 0.8f, 1.0f} // 紫
#define BLOCK_COLOR_FUNCTION {0.9f, 0.8f, 0.2f, 1.0f} // 黄
#define BLOCK_COLOR_DATA {0.4f, 0.7f, 0.9f, 1.0f} // 浅蓝
// 槽位值类型
typedef enum {
SLOT_VALUE_NUMBER = 0,
SLOT_VALUE_STRING,
SLOT_VALUE_BOOLEAN,
SLOT_VALUE_VECTOR3,
SLOT_VALUE_ANY
} SlotValueType;
// 槽位值
typedef struct {
SlotValueType type;
union {
double number;
char string[256];
int boolean;
struct { float x, y, z; } vector3;
} as;
} SlotValue;
// 槽位类型
typedef enum {
SLOT_STATEMENT = 0, // 语句槽位 (执行流)
SLOT_VALUE // 值槽位 (数据流)
} SlotKind;
// 槽位
typedef struct BlockSlot {
int id;
SlotKind kind;
SlotValueType value_type;
char label[MAX_BLOCK_LABEL];
struct Block* owner; // 所属积木
struct BlockSlot* connected; // 连接的槽位
SlotValue value; // 当前值 (仅值槽位)
float x, y; // 相对于积木的位置
float width, height; // 槽位尺寸
} BlockSlot;
// 积木类型
typedef enum {
// 事件
BLOCK_EVENT_START = 0,
BLOCK_EVENT_UPDATE,
BLOCK_EVENT_COLLISION,
BLOCK_EVENT_KEY_PRESSED,
BLOCK_EVENT_MOUSE_CLICK,
BLOCK_EVENT_TIMER,
// 动作
BLOCK_ACTION_MOVE,
BLOCK_ACTION_ROTATE,
BLOCK_ACTION_SCALE,
BLOCK_ACTION_SET_POSITION,
BLOCK_ACTION_SET_ROTATION,
BLOCK_ACTION_PLAY_SOUND,
BLOCK_ACTION_DESTROY,
BLOCK_ACTION_INSTANTIATE,
// 控制
BLOCK_CONTROL_IF,
BLOCK_CONTROL_IF_ELSE,
BLOCK_CONTROL_REPEAT,
BLOCK_CONTROL_REPEAT_TIMES,
BLOCK_CONTROL_WHILE,
BLOCK_CONTROL_WAIT,
BLOCK_CONTROL_FUNCTION_DEF,
// 运算
BLOCK_OP_ADD,
BLOCK_OP_SUB,
BLOCK_OP_MUL,
BLOCK_OP_DIV,
BLOCK_OP_MOD,
BLOCK_OP_EQUALS,
BLOCK_OP_NOT_EQUALS,
BLOCK_OP_GREATER,
BLOCK_OP_LESS,
BLOCK_OP_AND,
BLOCK_OP_OR,
BLOCK_OP_NOT,
// 变量
BLOCK_VAR_GET,
BLOCK_VAR_SET,
BLOCK_VAR_CREATE,
// 函数
BLOCK_FUNC_CALL,
BLOCK_FUNC_RETURN,
BLOCK_TYPE_COUNT
} BlockType;
// 积木类型信息
typedef struct {
BlockType type;
const char* name;
const char* label;
const char* category;
BlockColor color;
int input_count;
int output_count;
SlotValueType input_types[MAX_BLOCK_INPUTS];
SlotValueType output_types[MAX_BLOCK_OUTPUTS];
const char* input_labels[MAX_BLOCK_INPUTS];
const char* output_labels[MAX_BLOCK_OUTPUTS];
} BlockTypeInfo;
// 积木
typedef struct Block {
int id;
BlockType type;
char label[MAX_BLOCK_LABEL];
float x, y; // 画布位置
float width, height; // 尺寸
Color color; // 颜色
BlockSlot inputs[MAX_BLOCK_INPUTS];
int input_count;
BlockSlot outputs[MAX_BLOCK_OUTPUTS];
int output_count;
struct Block* next; // 下一个积木 (堆叠)
struct Block* parent_if; // 所属 if 块 (用于子语句)
struct BlockWorkspace* workspace;
void* user_data;
} Block;
// 连接
typedef struct BlockConnection {
BlockSlot* from;
BlockSlot* to;
float points[8]; // 贝塞尔曲线控制点
} BlockConnection;
// 函数声明
Block* block_create(BlockType type, float x, float y);
void block_destroy(Block* block);
BlockSlot* block_add_input(Block* block, SlotKind kind, SlotValueType value_type, const char* label);
BlockSlot* block_add_output(Block* block, SlotKind kind, SlotValueType value_type, const char* label);
bool block_connect(BlockSlot* from, BlockSlot* to);
void block_disconnect(BlockSlot* slot);
SlotValue block_slot_get_value(BlockSlot* slot);
void block_slot_set_value(BlockSlot* slot, SlotValue value);
bool block_contains_point(Block* block, float px, float py);
void block_slot_world_pos(BlockSlot* slot, float* wx, float* wy);