Skip to content

Commit

Permalink
Allow previewing non-drawable scene objects with drawable children
Browse files Browse the repository at this point in the history
  • Loading branch information
dgelessus committed Mar 1, 2024
1 parent 723ce69 commit 577cf95
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/PrpShop/PRP/Render/QPlasmaRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,22 @@ void QPlasmaRender::mouseReleaseEvent(QMouseEvent* evt)
}
}

void QPlasmaRender::addObject(plKey obj)
{
fObjects[obj] = ObjectInfo();

plSceneObject* sceneObj = GET_KEY_OBJECT(obj, plSceneObject);
plCoordinateInterface* coord = GET_KEY_OBJECT(sceneObj->getCoordInterface(), plCoordinateInterface);
if (coord == nullptr) {
return;
}
for (auto childKey : coord->getChildren()) {
if (childKey->getType() == kSceneObject) {
addObject(std::move(childKey));
}
}
}

void QPlasmaRender::setView(const hsVector3& view, float angle)
{
fViewPos = view;
Expand Down
2 changes: 1 addition & 1 deletion src/PrpShop/PRP/Render/QPlasmaRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class QPlasmaRender : public QOpenGLWidget
QSize minimumSizeHint() const override { return QSize(50, 50); }
QSize sizeHint() const override { return QSize(400, 400); }

void addObject(plKey obj) { fObjects[obj] = ObjectInfo(); }
void addObject(plKey obj);
void setView(const hsVector3& view, float angle = 0.0f);
void center(plKey obj, bool world);
void build(NavigationMode navMode, DrawMode drawMode);
Expand Down
22 changes: 21 additions & 1 deletion src/PrpShop/QPlasmaUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <algorithm>
#include "QPlasmaUtils.h"
#include <ResManager/pdUnifiedTypeMap.h>
#include <PRP/Object/plCoordinateInterface.h>
#include <PRP/Object/plSceneObject.h>

bool s_showTypeIDs = false;
Expand Down Expand Up @@ -613,6 +614,25 @@ bool pqIsValidKOType(short objType)
return std::find(valid_types.begin(), valid_types.end(), objType) != valid_types.end();
}

static bool pqCanPreviewSceneObject(plSceneObject* sceneObj)
{
if (sceneObj->getDrawInterface().Exists()) {
return true;
}

plCoordinateInterface* coord = GET_KEY_OBJECT(sceneObj->getCoordInterface(), plCoordinateInterface);
if (coord == nullptr) {
return false;
}
for (const auto& childKey : coord->getChildren()) {
plSceneObject* child = GET_KEY_OBJECT(childKey, plSceneObject);
if (child != nullptr && pqCanPreviewSceneObject(child)) {
return true;
}
}
return false;
}

bool pqCanPreviewType(plCreatable* pCre)
{
short type = pCre->ClassIndex();
Expand All @@ -624,7 +644,7 @@ bool pqCanPreviewType(plCreatable* pCre)

if (type == kSceneObject) {
plSceneObject* tmp = plSceneObject::Convert(pCre);
return tmp->getDrawInterface().Exists();
return pqCanPreviewSceneObject(tmp);
}

for (size_t i=0; i<s_numTypes; i++) {
Expand Down

0 comments on commit 577cf95

Please sign in to comment.