新增根据帧数控制可见性
This commit is contained in:
@@ -251,6 +251,14 @@ public:
|
||||
|
||||
writeAnimationBlock(ds, entity, true);
|
||||
ds << entity.displayName << double(entity.userScale) << double(entity.distanceScaleCalibMult);
|
||||
ds << bool(entity.ignoreDistanceScale);
|
||||
ds << entity.parentId;
|
||||
ds << double(entity.parentOffsetWorld.x()) << double(entity.parentOffsetWorld.y());
|
||||
// v7:实体可见性关键帧
|
||||
ds << qint32(entity.visibilityKeys.size());
|
||||
for (const auto& k : entity.visibilityKeys) {
|
||||
ds << qint32(k.frame) << bool(k.value);
|
||||
}
|
||||
writeIntroBlock(ds, entity);
|
||||
}
|
||||
|
||||
@@ -270,6 +278,40 @@ public:
|
||||
tmp.displayName = dn;
|
||||
tmp.userScale = std::clamp(us, 1e-3, 1e3);
|
||||
tmp.distanceScaleCalibMult = (cal > 0.0) ? std::clamp(cal, 1e-6, 10.0) : 0.0;
|
||||
bool ign = false;
|
||||
QString pid;
|
||||
double pox = 0.0;
|
||||
double poy = 0.0;
|
||||
ds >> ign >> pid >> pox >> poy;
|
||||
if (ds.status() != QDataStream::Ok) {
|
||||
return false;
|
||||
}
|
||||
tmp.ignoreDistanceScale = ign;
|
||||
tmp.parentId = pid;
|
||||
tmp.parentOffsetWorld = QPointF(pox, poy);
|
||||
|
||||
// v7:实体可见性关键帧
|
||||
qint32 nVis = 0;
|
||||
ds >> nVis;
|
||||
if (ds.status() != QDataStream::Ok) {
|
||||
return false;
|
||||
}
|
||||
tmp.visibilityKeys.clear();
|
||||
if (nVis > 0) {
|
||||
tmp.visibilityKeys.reserve(nVis);
|
||||
for (qint32 i = 0; i < nVis; ++i) {
|
||||
qint32 fr = 0;
|
||||
bool val = true;
|
||||
ds >> fr >> val;
|
||||
if (ds.status() != QDataStream::Ok) {
|
||||
return false;
|
||||
}
|
||||
core::Project::ToolKeyframeBool k;
|
||||
k.frame = int(fr);
|
||||
k.value = val;
|
||||
tmp.visibilityKeys.push_back(k);
|
||||
}
|
||||
}
|
||||
if (!readIntroBlock(ds, tmp.intro)) {
|
||||
return false;
|
||||
}
|
||||
@@ -329,7 +371,7 @@ bool EntityPayloadBinary::load(const QString& absolutePath, Project::Entity& ent
|
||||
if (ds.status() != QDataStream::Ok || magic != kMagicPayload) {
|
||||
return false;
|
||||
}
|
||||
if (ver != 1 && ver != 2 && ver != 3 && ver != 4 && ver != 5) {
|
||||
if (ver != 1 && ver != 2 && ver != 3 && ver != 4 && ver != 5 && ver != 6 && ver != 7) {
|
||||
return false;
|
||||
}
|
||||
Project::Entity tmp;
|
||||
@@ -353,6 +395,48 @@ bool EntityPayloadBinary::load(const QString& absolutePath, Project::Entity& ent
|
||||
}
|
||||
tmp.distanceScaleCalibMult = (cal > 0.0) ? std::clamp(cal, 1e-6, 10.0) : 0.0;
|
||||
}
|
||||
if (ver >= 6) {
|
||||
bool ign = false;
|
||||
QString pid;
|
||||
double pox = 0.0;
|
||||
double poy = 0.0;
|
||||
ds >> ign >> pid >> pox >> poy;
|
||||
if (ds.status() != QDataStream::Ok) {
|
||||
return false;
|
||||
}
|
||||
tmp.ignoreDistanceScale = ign;
|
||||
tmp.parentId = pid;
|
||||
tmp.parentOffsetWorld = QPointF(pox, poy);
|
||||
} else {
|
||||
tmp.ignoreDistanceScale = false;
|
||||
tmp.parentId.clear();
|
||||
tmp.parentOffsetWorld = QPointF();
|
||||
}
|
||||
if (ver >= 7) {
|
||||
qint32 nVis = 0;
|
||||
ds >> nVis;
|
||||
if (ds.status() != QDataStream::Ok) {
|
||||
return false;
|
||||
}
|
||||
tmp.visibilityKeys.clear();
|
||||
if (nVis > 0) {
|
||||
tmp.visibilityKeys.reserve(nVis);
|
||||
for (qint32 i = 0; i < nVis; ++i) {
|
||||
qint32 fr = 0;
|
||||
bool val = true;
|
||||
ds >> fr >> val;
|
||||
if (ds.status() != QDataStream::Ok) {
|
||||
return false;
|
||||
}
|
||||
core::Project::ToolKeyframeBool k;
|
||||
k.frame = int(fr);
|
||||
k.value = val;
|
||||
tmp.visibilityKeys.push_back(k);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tmp.visibilityKeys.clear();
|
||||
}
|
||||
if (ver >= 5) {
|
||||
if (!readIntroBlock(ds, tmp.intro)) {
|
||||
return false;
|
||||
@@ -361,6 +445,10 @@ bool EntityPayloadBinary::load(const QString& absolutePath, Project::Entity& ent
|
||||
} else {
|
||||
tmp.displayName.clear();
|
||||
tmp.userScale = 1.0;
|
||||
tmp.ignoreDistanceScale = false;
|
||||
tmp.parentId.clear();
|
||||
tmp.parentOffsetWorld = QPointF();
|
||||
tmp.visibilityKeys.clear();
|
||||
}
|
||||
entity = std::move(tmp);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user