Skip to content

Commit 108b3ff

Browse files
committed
fix: restore old SDK const compatibility
1 parent ca0b94e commit 108b3ff

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

source/module/tools/object/mmd_bone_manager.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ namespace
6060
return String();
6161
}
6262

63+
BaseTime GetDocumentTimeOrInvalid(const BaseDocument* doc)
64+
{
65+
// Older Cinema 4D SDKs expose BaseDocument::GetTime() as non-const.
66+
BaseDocument* const mutable_doc = const_cast<BaseDocument*>(doc);
67+
return mutable_doc ? mutable_doc->GetTime() : BaseTime(-1.);
68+
}
69+
6370
BaseTag* ResolveInheritSourceBoneTag(MMDBoneManagerObject* bone_manager, BaseTag* self_tag)
6471
{
6572
if (!bone_manager || !self_tag)
@@ -1321,7 +1328,7 @@ const MMDBoneManagerObject::PhysicsOverrideState* MMDBoneManagerObject::FindPhys
13211328
const auto* const entry = physics_overrides_.Find(bone_index);
13221329
if (!entry)
13231330
return nullptr;
1324-
const BaseTime current_time = doc ? doc->GetTime() : BaseTime(-1.);
1331+
const BaseTime current_time = GetDocumentTimeOrInvalid(doc);
13251332
return entry->GetValue().time == current_time ? &entry->GetValue() : nullptr;
13261333
}
13271334

@@ -1337,7 +1344,7 @@ void MMDBoneManagerObject::SetPhysicsOverride(const Int32 bone_index, const Base
13371344
}
13381345

13391346
PhysicsOverrideState state;
1340-
state.time = doc ? doc->GetTime() : BaseTime(-1.);
1347+
state.time = GetDocumentTimeOrInvalid(doc);
13411348
state.translation = translation;
13421349
state.rotation = rotation;
13431350
iferr(physics_overrides_.Insert(bone_index, state))

source/module/tools/tag/mmd_bone.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,9 @@ namespace
547547

548548
BaseTime GetDocumentTimeOrInvalid(const BaseDocument* doc)
549549
{
550-
return doc ? doc->GetTime() : BaseTime(-1.);
550+
// Older Cinema 4D SDKs expose BaseDocument::GetTime() as non-const.
551+
BaseDocument* const mutable_doc = const_cast<BaseDocument*>(doc);
552+
return mutable_doc ? mutable_doc->GetTime() : BaseTime(-1.);
551553
}
552554

553555
Float GetAnimationFrameFromDocumentContinuous(BaseDocument* doc)
@@ -1156,7 +1158,7 @@ Bool MMDBoneTag::GetPlaybackRuntimeOverride(Vector& translation, std::array<Floa
11561158
if (!has_runtime_playback_override_)
11571159
return false;
11581160

1159-
const BaseTag* const self_tag = static_cast<BaseTag*>(const_cast<MMDBoneTag*>(this)->Get());
1161+
BaseTag* const self_tag = static_cast<BaseTag*>(const_cast<MMDBoneTag*>(this)->Get());
11601162
const BaseDocument* const doc = self_tag ? self_tag->GetDocument() : nullptr;
11611163
if (runtime_playback_override_time_ != GetDocumentTimeOrInvalid(doc))
11621164
return false;
@@ -1168,12 +1170,12 @@ Bool MMDBoneTag::GetPlaybackRuntimeOverride(Vector& translation, std::array<Floa
11681170

11691171
Bool MMDBoneTag::HasPostPhysicsIKSolveAtTime(const BaseDocument* doc) const
11701172
{
1171-
return doc != nullptr && last_postphysics_ik_solve_time_ == doc->GetTime();
1173+
return last_postphysics_ik_solve_time_ == GetDocumentTimeOrInvalid(doc);
11721174
}
11731175

11741176
void MMDBoneTag::MarkPostPhysicsIKSolvedAtTime(const BaseDocument* doc)
11751177
{
1176-
last_postphysics_ik_solve_time_ = doc ? doc->GetTime() : BaseTime(-1.);
1178+
last_postphysics_ik_solve_time_ = GetDocumentTimeOrInvalid(doc);
11771179
}
11781180

11791181
void MMDBoneTag::SetAppendRecursionDepth(const Int32 depth)
@@ -2273,8 +2275,6 @@ void MMDBoneTag::BuildStandaloneIKChains()
22732275
if (!CollectStandaloneIKChainEntries(tag, entries))
22742276
return;
22752277

2276-
BaseDocument* const tag_doc = tag->GetDocument();
2277-
22782278
if (entries.IsEmpty())
22792279
{
22802280
ik_solver->ClearIKChains();
@@ -2470,7 +2470,6 @@ Bool MMDBoneTag::RunIKSolveAnimMode(BaseObject* op, const Bool mark_prephysics_c
24702470
return false;
24712471

24722472
BaseDocument* const doc = op->GetDocument();
2473-
const Int32 current_frame = GetAnimationFrameFromDocument(doc);
24742473
const BaseTime current_time = GetDocumentTimeOrInvalid(doc);
24752474
if (!allow_same_frame_resolve && last_ik_solve_time_ == current_time)
24762475
return false;

0 commit comments

Comments
 (0)