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 Feb 29, 2024
1 parent 723ce69 commit a526e74
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/PrpShop/PRP/Render/QPlasmaRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,21 @@ 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 == NULL) {
return;
}
for (auto it = coord->getChildren().begin(); it != coord->getChildren().end(); it++) {
if ((*it)->getType() == kSceneObject) {
addObject(*it);
}
}
}

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 == NULL) {
return false;
}
for (auto it = coord->getChildren().begin(); it != coord->getChildren().end(); it++) {
plSceneObject* child = GET_KEY_OBJECT((*it), plSceneObject);
if (child != NULL && 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 a526e74

Please sign in to comment.