Struct QBufferDataGenerator

Source
#[repr(C)]
pub struct QBufferDataGenerator { /* private fields */ }
Expand description

Provides a mechanism to generate buffer data from a job.

C++ class: Qt3DRender::QBufferDataGenerator.

C++ documentation:

Provides a mechanism to generate buffer data from a job.

The Qt3DRender::QBufferDataGenerator should be subclassed to provide a way to fill the data of a Qt3DRender::QBuffer. Such functors are executed at runtime in a Qt 3D job (likely in parallel with many other jobs). When providing a functor you must implement the operator() which will be called to generate the actual data. You must make sure that you have stored copies of anything you might need for it to execute properly. You should also implement the operator==. It will be used to compare with other functors and based on that allow the renderer to decide if a new functor should be executed or not.

Note: functors are useful when you can build data from a few set of attributes (e.g: building a sphere from a radius property). If you already have access to the buffer data, using Qt3DRender::QBuffer::setData() is likely more efficient.

QByteArray createSphereMeshVertexData(float radius, int rings, int slices) { ... }

class SphereVertexDataFunctor : public QBufferDataGenerator { public: SphereVertexDataFunctor(int rings, int slices, float radius) : m_rings(rings) , m_slices(slices) , m_radius(radius) {}

QByteArray operator ()() Q_DECL_OVERRIDE { return createSphereMeshVertexData(m_radius, m_rings, m_slices); }

bool operator ==(const QBufferDataGenerator &other) const Q_DECL_OVERRIDE { const SphereVertexDataFunctor *otherFunctor = functor_cast<SphereVertexDataFunctor>(&other); if (otherFunctor != nullptr) return (otherFunctor->m_rings == m_rings && otherFunctor->m_slices == m_slices && otherFunctor->m_radius == m_radius); return false; }

QT3D_FUNCTOR(SphereVertexDataFunctor)

private: int m_rings; int m_slices; float m_radius; };

The QT3D_FUNCTOR macro should be added when subclassing. This allows you to use functor_cast in your comparison operator to make sure that the other functor is of the same type as the one your are trying to compare against.

Implementations§

Source§

impl QBufferDataGenerator

Source

pub unsafe fn call(&self) -> CppBox<QByteArray>

Should be implemented to return the buffer data as a QByteArray when called.

Calls C++ function: pure virtual QByteArray Qt3DRender::QBufferDataGenerator::operator()().

C++ documentation:

Should be implemented to return the buffer data as a QByteArray when called.

Methods from Deref<Target = QAbstractFunctor>§

Source

pub unsafe fn id(&self) -> isize

Returns a pointer to the id of the functor.

Calls C++ function: pure virtual qintptr Qt3DRender::QAbstractFunctor::id() const.

C++ documentation:

Returns a pointer to the id of the functor.

Trait Implementations§

Source§

impl CppDeletable for QBufferDataGenerator

Source§

unsafe fn delete(&self)

Destroys the instance of QBufferDataGenerator. The destructor is virtual.

Calls C++ function: virtual [destructor] void Qt3DRender::QBufferDataGenerator::~QBufferDataGenerator().

C++ documentation:

Destroys the instance of QBufferDataGenerator. The destructor is virtual.

Source§

impl Deref for QBufferDataGenerator

Source§

fn deref(&self) -> &QAbstractFunctor

Calls C++ function: Qt3DRender::QAbstractFunctor* static_cast<Qt3DRender::QAbstractFunctor*>(Qt3DRender::QBufferDataGenerator* ptr).

Source§

type Target = QAbstractFunctor

The resulting type after dereferencing.
Source§

impl DynamicCast<QBufferDataGenerator> for QAbstractFunctor

Source§

unsafe fn dynamic_cast(ptr: Ptr<QAbstractFunctor>) -> Ptr<QBufferDataGenerator>

Calls C++ function: Qt3DRender::QBufferDataGenerator* dynamic_cast<Qt3DRender::QBufferDataGenerator*>(Qt3DRender::QAbstractFunctor* ptr).

Source§

impl PartialEq<Ref<QBufferDataGenerator>> for QBufferDataGenerator

Source§

fn eq(&self, other: &Ref<QBufferDataGenerator>) -> bool

Should be reimplemented to return true when two generators (the one you are comparing against and the other generator) are identical, false otherwise.

Calls C++ function: pure virtual bool Qt3DRender::QBufferDataGenerator::operator==(const Qt3DRender::QBufferDataGenerator& other) const.

C++ documentation:

Should be reimplemented to return true when two generators (the one you are comparing against and the other generator) are identical, false otherwise.

Note: The renderer uses this comparison to decide whether data for a buffer needs to be reuploaded or not when the functor on a Qt3DRender::QBuffer changes.

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StaticDowncast<QBufferDataGenerator> for QAbstractFunctor

Source§

unsafe fn static_downcast( ptr: Ptr<QAbstractFunctor>, ) -> Ptr<QBufferDataGenerator>

Calls C++ function: Qt3DRender::QBufferDataGenerator* static_cast<Qt3DRender::QBufferDataGenerator*>(Qt3DRender::QAbstractFunctor* ptr).

Source§

impl StaticUpcast<QAbstractFunctor> for QBufferDataGenerator

Source§

unsafe fn static_upcast(ptr: Ptr<QBufferDataGenerator>) -> Ptr<QAbstractFunctor>

Calls C++ function: Qt3DRender::QAbstractFunctor* static_cast<Qt3DRender::QAbstractFunctor*>(Qt3DRender::QBufferDataGenerator* ptr).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

Source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> StaticUpcast<T> for T

Source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.