feat: add camera culling masks

This commit is contained in:
2026-04-01 01:42:06 +08:00
parent 51736253e3
commit 0fe02fd1b4
9 changed files with 81 additions and 3 deletions

View File

@@ -34,6 +34,7 @@ void CameraComponent::Serialize(std::ostream& os) const {
os << "depth=" << m_depth << ";";
os << "primary=" << (m_primary ? 1 : 0) << ";";
os << "clearMode=" << static_cast<int>(m_clearMode) << ";";
os << "cullingMask=" << m_cullingMask << ";";
os << "clearColor=" << m_clearColor.r << "," << m_clearColor.g << "," << m_clearColor.b << "," << m_clearColor.a << ";";
}
@@ -68,6 +69,8 @@ void CameraComponent::Deserialize(std::istream& is) {
m_primary = (std::stoi(value) != 0);
} else if (key == "clearMode") {
m_clearMode = static_cast<CameraClearMode>(std::stoi(value));
} else if (key == "cullingMask") {
m_cullingMask = static_cast<uint32_t>(std::stoul(value));
} else if (key == "clearColor") {
std::replace(value.begin(), value.end(), ',', ' ');
std::istringstream ss(value);

View File

@@ -317,6 +317,7 @@ void GameObject::Destroy() {
void GameObject::Serialize(std::ostream& os) const {
os << "name=" << m_name << ";";
os << "active=" << (m_activeSelf ? "1" : "0") << ";";
os << "layer=" << static_cast<uint32_t>(m_layer) << ";";
os << "id=" << m_id << ";";
os << "uuid=" << m_uuid << ";";
os << "transform=";
@@ -346,6 +347,11 @@ void GameObject::Deserialize(std::istream& is) {
is.get(val);
m_activeSelf = (val == '1');
if (is.peek() == ';') is.get();
} else if (strcmp(key, "layer") == 0) {
uint32_t layer = 0;
is >> layer;
SetLayer(static_cast<uint8_t>(layer));
if (is.peek() == ';') is.get();
} else if (strcmp(key, "id") == 0) {
is >> m_id;
if (is.peek() == ';') is.get();