Skip to content

Commit

Permalink
Added component
Browse files Browse the repository at this point in the history
  • Loading branch information
denis authored and denis committed Nov 10, 2024
1 parent 672d8ce commit 7060da9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion GUI/include/NodeViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Prisma

void showComponents(Node* nodeData);

void showSelected(const NodeData& nodeData, bool end = true);
void showSelected(const NodeData& nodeData, bool end = true, bool showData = true);
// Getters for textures
const std::shared_ptr<Texture>& rotateTexture() const;

Expand Down
8 changes: 3 additions & 5 deletions GUI/src/MeshInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ void Prisma::MeshInfo::showSelected(const NodeViewer::NodeData& meshData)
auto mesh = dynamic_cast<Prisma::Mesh*>(meshData.node);
auto isAnimate = dynamic_cast<AnimatedMesh*>(meshData.node);

NodeViewer::getInstance().showSelected(meshData, false);
NodeViewer::getInstance().showSelected(meshData, false,
isAnimate || (physicsComponent && !physicsComponent->collisionData().
softBody));
ImGui::Dummy(ImVec2(0.0f, 4.0f));

if (mesh)
Expand All @@ -45,10 +47,6 @@ void Prisma::MeshInfo::showSelected(const NodeViewer::NodeData& meshData)
physicsComponent->updateCollisionData();
}

if (isAnimate || (physicsComponent && !physicsComponent->collisionData().softBody))
{
NodeViewer::getInstance().showComponents(meshData.node);
}
ImGui::Dummy(ImVec2(0, 10));
if (isAnimate)
{
Expand Down
14 changes: 11 additions & 3 deletions GUI/src/NodeViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void Prisma::NodeViewer::showComponents(Node* nodeData)
{
auto components = nodeData->components();
int i = 0;
std::string indexRemove = "";
for (const auto& component : components)
{
ImGui::Separator();
Expand All @@ -102,13 +103,18 @@ void Prisma::NodeViewer::showComponents(Node* nodeData)
getInstance().varsDispatcher(field, i);
}
}
ImGui::Button("Remove Component");
i++;
}
if (!indexRemove.empty())
{
nodeData->removeComponent(indexRemove);
}
}

// Getters for textures

void Prisma::NodeViewer::showSelected(const NodeData& nodeData, bool end)
void Prisma::NodeViewer::showSelected(const NodeData& nodeData, bool end, bool showData)
{
if (nodeData.node)
{
Expand Down Expand Up @@ -202,8 +208,10 @@ void Prisma::NodeViewer::showSelected(const NodeData& nodeData, bool end)
{
nodeData.node->addComponent(Prisma::Factory::createInstance(components[m_componentSelect]));
}

showComponents(nodeData.node);
if (showData)
{
showComponents(nodeData.node);
}
if (end)
{
ImGui::End();
Expand Down

0 comments on commit 7060da9

Please sign in to comment.