Skip to content

Commit d06ab59

Browse files
committed
UPBBGE: Cleanup
1 parent 4125e2d commit d06ab59

File tree

5 files changed

+33
-63
lines changed

5 files changed

+33
-63
lines changed

source/gameengine/Ketsji/BL_Action.cpp

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,7 @@ void BL_Action::Update(float curtime, bool applyToObject)
431431
m_localframe);
432432

433433
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE) {
434-
if (ob->gameflag & OB_OVERLAY_COLLECTION) {
435-
scene->AppendToIdsToUpdateInOverlayPass(&ob->id, ID_RECALC_TRANSFORM);
436-
}
437-
else {
438-
scene->AppendToIdsToUpdateInAllRenderPasses(&ob->id, ID_RECALC_TRANSFORM);
439-
}
440-
434+
scene->AppendToIdsToUpdate(&ob->id, ID_RECALC_TRANSFORM, ob->gameflag & OB_OVERLAY_COLLECTION);
441435
BL_ArmatureObject *obj = (BL_ArmatureObject *)m_obj;
442436

443437
if (m_layer_weight >= 0)
@@ -480,12 +474,8 @@ void BL_Action::Update(float curtime, bool applyToObject)
480474
bool isRightAction = ActionMatchesName(m_action, md->name, ACT_TYPE_MODIFIER);
481475
// TODO: We need to find the good notifier per action
482476
if (isRightAction && !BKE_modifier_is_non_geometrical(md)) {
483-
if (ob->gameflag & OB_OVERLAY_COLLECTION) {
484-
scene->AppendToIdsToUpdateInOverlayPass(&ob->id, ID_RECALC_GEOMETRY);
485-
}
486-
else {
487-
scene->AppendToIdsToUpdateInAllRenderPasses(&ob->id, ID_RECALC_GEOMETRY);
488-
}
477+
scene->AppendToIdsToUpdate(
478+
&ob->id, ID_RECALC_GEOMETRY, ob->gameflag & OB_OVERLAY_COLLECTION);
489479
PointerRNA ptrrna = RNA_id_pointer_create(&ob->id);
490480
const blender::animrig::slot_handle_t slot_handle = blender::animrig::first_slot_handle(
491481
*m_action);
@@ -503,12 +493,8 @@ void BL_Action::Update(float curtime, bool applyToObject)
503493
// the Color ones)
504494
bool isRightAction = ActionMatchesName(m_action, gpmd->name, ACT_TYPE_GPMODIFIER);
505495
if (isRightAction) {
506-
if (ob->gameflag & OB_OVERLAY_COLLECTION) {
507-
scene->AppendToIdsToUpdateInOverlayPass(&ob->id, ID_RECALC_GEOMETRY);
508-
}
509-
else {
510-
scene->AppendToIdsToUpdateInAllRenderPasses(&ob->id, ID_RECALC_GEOMETRY);
511-
}
496+
scene->AppendToIdsToUpdate(
497+
&ob->id, ID_RECALC_GEOMETRY, ob->gameflag & OB_OVERLAY_COLLECTION);
512498
PointerRNA ptrrna = RNA_id_pointer_create(&ob->id);
513499
const blender::animrig::slot_handle_t slot_handle = blender::animrig::first_slot_handle(
514500
*m_action);
@@ -526,12 +512,8 @@ void BL_Action::Update(float curtime, bool applyToObject)
526512
if (!scene->OrigObCanBeTransformedInRealtime(ob)) {
527513
break;
528514
}
529-
if (ob->gameflag & OB_OVERLAY_COLLECTION) {
530-
scene->AppendToIdsToUpdateInOverlayPass(&ob->id, ID_RECALC_TRANSFORM);
531-
}
532-
else {
533-
scene->AppendToIdsToUpdateInAllRenderPasses(&ob->id, ID_RECALC_TRANSFORM);
534-
}
515+
scene->AppendToIdsToUpdate(
516+
&ob->id, ID_RECALC_TRANSFORM, ob->gameflag & OB_OVERLAY_COLLECTION);
535517
PointerRNA ptrrna = RNA_id_pointer_create(&ob->id);
536518
const blender::animrig::slot_handle_t slot_handle = blender::animrig::first_slot_handle(
537519
*m_action);
@@ -554,12 +536,8 @@ void BL_Action::Update(float curtime, bool applyToObject)
554536
continue;
555537
}
556538
if (ActionMatchesName(m_action, prop->name, ACT_TYPE_IDPROP)) {
557-
if (ob->gameflag & OB_OVERLAY_COLLECTION) {
558-
scene->AppendToIdsToUpdateInOverlayPass(&ob->id, ID_RECALC_TRANSFORM);
559-
}
560-
else {
561-
scene->AppendToIdsToUpdateInAllRenderPasses(&ob->id, ID_RECALC_TRANSFORM);
562-
}
539+
scene->AppendToIdsToUpdate(
540+
&ob->id, ID_RECALC_TRANSFORM, ob->gameflag & OB_OVERLAY_COLLECTION);
563541
PointerRNA ptrrna = RNA_id_pointer_create(&ob->id);
564542
const blender::animrig::slot_handle_t slot_handle =
565543
blender::animrig::first_slot_handle(*m_action);
@@ -588,7 +566,7 @@ void BL_Action::Update(float curtime, bool applyToObject)
588566
}
589567
}
590568
if (isRightAction) {
591-
scene->AppendToIdsToUpdateInAllRenderPasses(&nodetree->id, (IDRecalcFlag)0);
569+
scene->AppendToIdsToUpdate(&nodetree->id, (IDRecalcFlag)0, false);
592570
PointerRNA ptrrna = RNA_id_pointer_create(&nodetree->id);
593571
const blender::animrig::slot_handle_t slot_handle = blender::animrig::first_slot_handle(
594572
*m_action);
@@ -620,7 +598,7 @@ void BL_Action::Update(float curtime, bool applyToObject)
620598
}
621599

622600
if (play_normal_key_action || play_nla_key_action) {
623-
scene->AppendToIdsToUpdateInAllRenderPasses(&me->id, ID_RECALC_GEOMETRY);
601+
scene->AppendToIdsToUpdate(&me->id, ID_RECALC_GEOMETRY, false);
624602
Key *key = me->key;
625603

626604
PointerRNA ptrrna = RNA_id_pointer_create(&key->id);

source/gameengine/Ketsji/KX_FontObject.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,8 @@ void KX_FontObject::UpdateCurveText(std::string newText) // eevee
9999
cu->str = static_cast<char *>(MEM_mallocN(len_bytes + sizeof(char32_t), __func__));
100100
memcpy(cu->str, newText.c_str(), len_bytes + 1);
101101

102-
if (ob->gameflag & OB_OVERLAY_COLLECTION) {
103-
GetScene()->AppendToIdsToUpdateInOverlayPass(&ob->id, ID_RECALC_GEOMETRY);
104-
}
105-
else {
106-
GetScene()->AppendToIdsToUpdateInAllRenderPasses(&ob->id, ID_RECALC_GEOMETRY);
107-
}
102+
GetScene()->AppendToIdsToUpdate(
103+
&ob->id, ID_RECALC_GEOMETRY, ob->gameflag & OB_OVERLAY_COLLECTION);
108104
}
109105

110106
void KX_FontObject::UpdateTextFromProperty()

source/gameengine/Ketsji/KX_GameObject.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ void KX_GameObject::ReplicateBlenderObject()
395395
V3D_SHADING_USE_COMPOSITOR_DISABLED &&
396396
v3d->shading.type >= OB_MATERIAL;
397397
if (is_realtime_compositor_enabled) {
398-
GetScene()->AppendToIdsToUpdateInOverlayPass(&scene->id, ID_RECALC_EDITORS);
398+
GetScene()->AppendToIdsToUpdate(&scene->id, ID_RECALC_EDITORS, true);
399399
}
400400
}
401401

@@ -1283,12 +1283,8 @@ void KX_GameObject::SetVisible(bool v, bool recursive)
12831283
else {
12841284
ob->visibility_flag |= OB_HIDE_VIEWPORT;
12851285
}
1286-
if (ob->gameflag & OB_OVERLAY_COLLECTION) {
1287-
GetScene()->AppendToIdsToUpdateInOverlayPass(&ob->id, ID_RECALC_SYNC_TO_EVAL);
1288-
}
1289-
else {
1290-
GetScene()->AppendToIdsToUpdateInAllRenderPasses(&ob->id, ID_RECALC_SYNC_TO_EVAL);
1291-
}
1286+
GetScene()->AppendToIdsToUpdate(
1287+
&ob->id, ID_RECALC_SYNC_TO_EVAL, ob->gameflag & OB_OVERLAY_COLLECTION);
12921288
}
12931289

12941290
if (recursive) {

source/gameengine/Ketsji/KX_Scene.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ void KX_Scene::OverlayPassDisableEffects(Depsgraph *depsgraph,
617617
if ((m_backupOverlayFlag != scene_eval->eevee.flag) ||
618618
(m_backupOverlayGameFlag != scene_eval->eevee.gameflag)) {
619619
/* Only tag if overlay settings changed since previous frame */
620-
AppendToIdsToUpdateInOverlayPass(&obcam->id, ID_RECALC_TRANSFORM);
620+
AppendToIdsToUpdate(&obcam->id, ID_RECALC_TRANSFORM, true);
621621
}
622622
m_backupOverlayFlag = scene_eval->eevee.flag;
623623
m_backupOverlayGameFlag = scene_eval->eevee.gameflag;
@@ -1319,23 +1319,23 @@ bool KX_Scene::SomethingIsMoving()
13191319
return false;
13201320
}
13211321

1322-
void KX_Scene::AppendToIdsToUpdateInAllRenderPasses(ID *id, IDRecalcFlag flag)
1322+
void KX_Scene::AppendToIdsToUpdate(ID *id, IDRecalcFlag flag, bool in_overlay_collection_only)
13231323
{
13241324
std::pair<ID *, IDRecalcFlag> it = {id, flag};
1325-
if (std::find(m_idsToUpdateInAllRenderPasses.begin(),
1326-
m_idsToUpdateInAllRenderPasses.end(),
1327-
it) == m_idsToUpdateInAllRenderPasses.end()) {
1328-
m_idsToUpdateInAllRenderPasses.push_back(it);
1325+
if (in_overlay_collection_only) {
1326+
if (std::find(m_idsToUpdateInOverlayPass.begin(), m_idsToUpdateInOverlayPass.end(), it) ==
1327+
m_idsToUpdateInOverlayPass.end())
1328+
{
1329+
m_idsToUpdateInOverlayPass.push_back(it);
1330+
}
13291331
}
1330-
}
1331-
1332-
void KX_Scene::AppendToIdsToUpdateInOverlayPass(ID *id, IDRecalcFlag flag)
1333-
{
1334-
std::pair<ID *, IDRecalcFlag> it = {id, flag};
1335-
if (std::find(m_idsToUpdateInOverlayPass.begin(),
1336-
m_idsToUpdateInOverlayPass.end(),
1337-
it) == m_idsToUpdateInOverlayPass.end()) {
1338-
m_idsToUpdateInOverlayPass.push_back(it);
1332+
else {
1333+
if (std::find(m_idsToUpdateInAllRenderPasses.begin(),
1334+
m_idsToUpdateInAllRenderPasses.end(),
1335+
it) == m_idsToUpdateInAllRenderPasses.end())
1336+
{
1337+
m_idsToUpdateInAllRenderPasses.push_back(it);
1338+
}
13391339
}
13401340
}
13411341

@@ -1357,6 +1357,7 @@ void KX_Scene::TagForExtraIdsUpdate(Main *bmain, KX_Camera *cam)
13571357
}
13581358
m_idsToUpdateInOverlayPass.clear();
13591359
}
1360+
//m_idsToUpdateInAllRenderPasses will be cleared only at last render pass
13601361
}
13611362

13621363
void KX_Scene::TagBlenderPhysicsObject(Scene *scene, Object *ob)

source/gameengine/Ketsji/KX_Scene.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ class KX_Scene : public KX_PythonProxy, public SCA_IScene {
364364
Object *ob,
365365
std::vector<Object *> children);
366366
bool SomethingIsMoving();
367-
void AppendToIdsToUpdateInAllRenderPasses(ID *id, IDRecalcFlag flag);
368-
void AppendToIdsToUpdateInOverlayPass(ID *id, IDRecalcFlag flag);
367+
void AppendToIdsToUpdate(ID *id, IDRecalcFlag flag, bool in_overlay_collection_only);
369368
void TagForExtraIdsUpdate(Main *bmain, KX_Camera *cam);
370369
void TagBlenderPhysicsObject(Scene *scene, Object *ob);
371370
KX_GameObject *AddDuplicaObject(KX_GameObject *gameobj,

0 commit comments

Comments
 (0)