Skip to content

Commit

Permalink
[Component/Collider] Collider's plane information are displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
Razakhel committed Jan 15, 2021
1 parent 2f95ca7 commit 81af599
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 3 deletions.
18 changes: 18 additions & 0 deletions assets/translations/english.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,24 @@
<translation>Friction</translation>
</message>
</context>
<context>
<name>PlaneInfo</name>
<message>
<location filename="../../interface/PlaneInfo.ui" line="14"/>
<source>Plane</source>
<translation>Plane</translation>
</message>
<message>
<location filename="../../interface/PlaneInfo.ui" line="20"/>
<source>Distance</source>
<translation>Distance</translation>
</message>
<message>
<location filename="../../interface/PlaneInfo.ui" line="59"/>
<source>Normal</source>
<translation>Normal</translation>
</message>
</context>
<context>
<name>RenderSystemSettings</name>
<message>
Expand Down
18 changes: 18 additions & 0 deletions assets/translations/french.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,24 @@
<translation>Friction</translation>
</message>
</context>
<context>
<name>PlaneInfo</name>
<message>
<location filename="../../interface/PlaneInfo.ui" line="14"/>
<source>Plane</source>
<translation>Plan</translation>
</message>
<message>
<location filename="../../interface/PlaneInfo.ui" line="20"/>
<source>Distance</source>
<translation>Distance</translation>
</message>
<message>
<location filename="../../interface/PlaneInfo.ui" line="59"/>
<source>Normal</source>
<translation>Normale</translation>
</message>
</context>
<context>
<name>RenderSystemSettings</name>
<message>
Expand Down
16 changes: 13 additions & 3 deletions interface/ColliderComp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>279</width>
<height>53</height>
<width>231</width>
<height>61</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -25,7 +25,17 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="shapeType"/>
<widget class="QComboBox" name="shapeType">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<layout class="QVBoxLayout" name="shapeInfoLayout"/>
</item>
</layout>
</widget>
Expand Down
194 changes: 194 additions & 0 deletions interface/PlaneInfo.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PlaneInfo</class>
<widget class="QFrame" name="PlaneInfo">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>289</width>
<height>66</height>
</rect>
</property>
<property name="windowTitle">
<string>Plane</string>
</property>
<layout class="QFormLayout" name="planeLayout">
<item row="0" column="0">
<widget class="QLabel" name="distanceLabel">
<property name="text">
<string>Distance</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="distance">
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>7</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="decimals">
<number>5</number>
</property>
<property name="minimum">
<double>-340282346638528859811704183484516925440.000000000000000</double>
</property>
<property name="maximum">
<double>340282346638528859811704183484516925440.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="normalLabel">
<property name="text">
<string>Normal</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="normalLayout">
<item>
<widget class="QDoubleSpinBox" name="normalX">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>7</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="decimals">
<number>5</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="normalY">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>7</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="decimals">
<number>5</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="normalZ">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>7</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="decimals">
<number>5</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
54 changes: 54 additions & 0 deletions src/RaZor/Interface/Component/Collider.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,64 @@
#include "RaZor/Interface/AppWindow.hpp"
#include "RaZor/Interface/MainWindow.hpp"
#include "ui_ColliderComp.h"
#include "ui_PlaneInfo.h"

#include <RaZ/Math/Transform.hpp>
#include <RaZ/Physics/Collider.hpp>

#include <QStandardItemModel>

namespace {

QFrame* createPlaneWidget(const Raz::Plane& plane) {
Ui::PlaneInfo planeComp;

auto* planeWidget = new QFrame();
planeComp.setupUi(planeWidget);

planeComp.distance->setValue(static_cast<double>(plane.getDistance()));

planeComp.normalX->setValue(static_cast<double>(plane.getNormal().x()));
planeComp.normalY->setValue(static_cast<double>(plane.getNormal().y()));
planeComp.normalZ->setValue(static_cast<double>(plane.getNormal().z()));

return planeWidget;
}

void showShapeInfo(Raz::Collider& collider, Ui::ColliderComp& colliderComp) {
switch (collider.getShapeType()) {
case Raz::ShapeType::LINE:
// colliderComp.shapeInfoLayout->addWidget(createLineWidget(collider.getShape<Raz::Line>()));
break;

case Raz::ShapeType::PLANE:
colliderComp.shapeInfoLayout->addWidget(createPlaneWidget(collider.getShape<Raz::Plane>()));
break;

case Raz::ShapeType::SPHERE:
// colliderComp.shapeInfoLayout->addWidget(createSphereWidget(collider.getShape<Raz::Sphere>()));
break;

case Raz::ShapeType::TRIANGLE:
// colliderComp.shapeInfoLayout->addWidget(createTriangleWidget(collider.getShape<Raz::Triangle>()));
break;

case Raz::ShapeType::QUAD:
// colliderComp.shapeInfoLayout->addWidget(createQuadWidget(collider.getShape<Raz::Quad>()));
break;

case Raz::ShapeType::AABB:
// colliderComp.shapeInfoLayout->addWidget(createAABBWidget(collider.getShape<Raz::AABB>()));
break;

case Raz::ShapeType::OBB:
// colliderComp.shapeInfoLayout->addWidget(createOBBWidget(collider.getShape<Raz::OBB>()));
break;
}
}

} // namespace

void AppWindow::showColliderComponent(Raz::Collider& collider) {
Ui::ColliderComp colliderComp;

Expand Down Expand Up @@ -70,6 +122,8 @@ void AppWindow::showColliderComponent(Raz::Collider& collider) {
loadComponents();
});

showShapeInfo(collider, colliderComp);

m_parentWindow->m_window.componentsLayout->addWidget(colliderWidget);
}

Expand Down

0 comments on commit 81af599

Please sign in to comment.