| 1 | // Copyright (C) 2021 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include "qplaneshape_p.h" |
| 5 | |
| 6 | #include <QtQuick3D/QQuick3DGeometry> |
| 7 | #include <extensions/PxExtensionsAPI.h> |
| 8 | |
| 9 | //######################################################################################## |
| 10 | // NOTE: |
| 11 | // Triangle mesh, heightfield or plane geometry shapes configured as eSIMULATION_SHAPE are |
| 12 | // not supported for non-kinematic PxRigidDynamic instances. |
| 13 | //######################################################################################## |
| 14 | |
| 15 | QT_BEGIN_NAMESPACE |
| 16 | |
| 17 | /*! |
| 18 | \qmltype PlaneShape |
| 19 | \inqmlmodule QtQuick3D.Physics |
| 20 | \inherits CollisionShape |
| 21 | \since 6.4 |
| 22 | \brief A collision shape that defines an infinite plane. |
| 23 | |
| 24 | The PlaneShape type defines an infinite plane. The plane divides space into "above" and "below" |
| 25 | it. Everything "below" the plane will collide with it and be pushed above it. The orientation of |
| 26 | the plane is vertical: The Plane lies on the XY plane with "above" pointing sideways towards positive Z. |
| 27 | |
| 28 | PlaneShape can only be used with \l StaticRigidBody and \l {DynamicRigidBody::isKinematic}{kinematic bodies}. |
| 29 | */ |
| 30 | |
| 31 | QPlaneShape::QPlaneShape() = default; |
| 32 | |
| 33 | QPlaneShape::~QPlaneShape() |
| 34 | { |
| 35 | delete m_planeGeometry; |
| 36 | } |
| 37 | |
| 38 | physx::PxGeometry *QPlaneShape::getPhysXGeometry() |
| 39 | { |
| 40 | if (!m_planeGeometry) { |
| 41 | updatePhysXGeometry(); |
| 42 | } |
| 43 | return m_planeGeometry; |
| 44 | } |
| 45 | |
| 46 | void QPlaneShape::updatePhysXGeometry() |
| 47 | { |
| 48 | delete m_planeGeometry; |
| 49 | // TODO: we need only one plane geometry, and it should live in the backend |
| 50 | m_planeGeometry = new physx::PxPlaneGeometry(); |
| 51 | } |
| 52 | |
| 53 | QT_END_NAMESPACE |
| 54 | |