Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 36660aa1 authored by Rahul Chowdhury's avatar Rahul Chowdhury

Make the rotation of objects visible with a white line drawn through the center

REVIEW:121983
parent e97b14b0
......@@ -32,7 +32,7 @@
#include <QKeyEvent>
#include <QPainter>
#include <KLocale>
#include <KDebug>
#include <QDebug>
RigidBodyGraphicsItem::RigidBodyGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: StepGraphicsItem(item, worldModel)
......@@ -77,6 +77,12 @@ void RigidBodyGraphicsItem::paint(QPainter* painter, const QStyleOptionGraphicsI
painter->drawPath(_painterPath);
if (!_markPath.isEmpty()) {
painter->setPen(QPen(Qt::white));
painter->setBrush(QColor(0, 0, 255, 127));
painter->drawPath(_markPath);
}
if(_isSelected) {
double s = currentViewScale();
QRectF rect = _painterPath.boundingRect();
......@@ -235,15 +241,22 @@ void DiskGraphicsItem::viewScaleChanged()
_painterPath = QPainterPath();
_painterPath.setFillRule(Qt::WindingFill);
_markPath = QPainterPath();
_painterPath.setFillRule(Qt::WindingFill);
double s = currentViewScale();
double radius = disk()->radius();
if(radius > 1/s) {
_painterPath.addEllipse(-radius, -radius, 2*radius, 2*radius);
//_painterPath = QMatrix().rotate(disk()->angle() * 180 / StepCore::Constants::Pi).map(_painterPath);
_markPath.moveTo(-radius, radius);
_markPath.lineTo(radius, -radius);
_markPath.moveTo(radius, -radius);
_markPath.lineTo(-radius, radius);
} else {
_painterPath.addEllipse(-1/s, -1/s, 2/s, 2/s);
}
_markPath = QMatrix().rotate(disk()->angle() * 180 / StepCore::Constants::Pi).map(_markPath);
RigidBodyGraphicsItem::viewScaleChanged();
}
......@@ -467,7 +480,7 @@ bool PolygonCreator::sceneEvent(QEvent* event)
showMessage(MessageFrame::Information,
i18n("Click on the scene to add new vertex or press Enter to finish"));
}
//fixCenterOfMass();
//fixInertia();
return true;
......
......@@ -54,6 +54,7 @@ public:
protected:
StepCore::RigidBody* rigidBody() const;
QPainterPath _painterPath;
QPainterPath _markPath;
ArrowHandlerGraphicsItem* _velocityHandler;
CircularArrowHandlerGraphicsItem* _angularVelocityHandler;
......
......@@ -1044,7 +1044,7 @@ int GJKCollisionSolver::solvePolygonDisk(Contact* contact)
double vrel = contact->vrel[0];
STEPCORE_ASSERT_NOABORT( vrel < 0 );
Vector2d r0 = contact->points[0] - body0->position();
double r0n = r0[0]*contact->normal[1] - r0[1]*contact->normal[0];
double term0 = contact->normal.dot(
......@@ -1160,7 +1160,7 @@ int GJKCollisionSolver::solveDiskParticle(Contact* contact)
double b = 1; // coefficient of bounceness
double vrel = contact->vrel[0];
STEPCORE_ASSERT_NOABORT( vrel < 0 );
Vector2d j = contact->normal * ( -(1+b)*vrel / (1/disk0->mass() + 1/particle1->mass()) );
disk0->setVelocity(disk0->velocity() - j / disk0->mass());
particle1->setVelocity(particle1->velocity() + j / particle1->mass());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment