Example #1
0
    void collect_relations_from_entity(ObjectInstance& object_instance)
    {
        set<string> material_names;

        for (const auto& kv : object_instance.get_front_material_mappings())
            material_names.insert(kv.value());

        for (const auto& kv : object_instance.get_back_material_mappings())
            material_names.insert(kv.value());

        for (const auto& material_name : material_names)
        {
            const auto referenced_entity =
                m_input_binder.find_entity(
                    material_name.c_str(),
                    object_instance.get_parent());

            if (referenced_entity.m_entity != nullptr)
                insert_relation(referenced_entity, object_instance);
        }

        {
            const auto referenced_entity =
                m_input_binder.find_entity(
                    object_instance.get_object_name(),
                    object_instance.get_parent());

            if (referenced_entity.m_entity != nullptr)
                insert_relation(referenced_entity, object_instance);
        }
    }
Example #2
0
static DBVH MakeDBVH(const BVH *bvh, int nInstances) {
	srand(0);
	static float anim = 0; anim += 0.02f;

	float scale = Length(bvh->GetBBox().Size()) * 0.015;

	vector<ObjectInstance> instances;
	for(int n = 0; n < nInstances; n++) {
		ObjectInstance inst;
		inst.tree = bvh;
		inst.translation = (Vec3f(rand() % 1000, rand() % 1000, rand() % 1000) - Vec3f(500, 500, 500))
			* scale;
		Matrix<Vec4f> rot = Rotate(
				(rand() % 1000) * 0.002f * constant::pi + anim,
				(rand() % 1000) * 0.002f * constant::pi + anim * 0.2f,
				(rand() % 1000) * 0.002f * constant::pi + anim * 0.1f);
		inst.rotation[0] = Vec3f(rot.x);
		inst.rotation[1] = Vec3f(rot.y);
		inst.rotation[2] = Vec3f(rot.z);
		inst.ComputeBBox();
		instances.push_back(inst);
	}
	ObjectInstance zero;
	zero.tree = bvh;
	zero.translation = Vec3f(0, 0, 0);
	zero.rotation[0] = Vec3f(1, 0, 0);
	zero.rotation[1] = Vec3f(0, 1, 0);
	zero.rotation[2] = Vec3f(0, 0, 1);
	zero.ComputeBBox();
	instances.push_back(zero);

	return DBVH(instances);
}
Example #3
0
	void EchoStatement::execute(Frame * frame) const
	{
		ObjectInstance * rhsResult = rhs->execute(frame);

		const Method * toString = rhsResult->getClass()->getMethod("toString");
		Q_ASSERT(toString != NULL);

		Frame newFrame(frame->getVirtualMachine(), rhsResult->getClass(), toString, rhsResult);
		ObjectInstance * rhsResultString = toString->execute(&newFrame);
		Q_ASSERT(rhsResultString != NULL);
		QString result = Type::String::getQString(rhsResultString);

		std::cout << qPrintable(result) << std::endl;
	}
void QmlContextPropertyAdaptor::doSetObject(const ObjectInstance &oi)
{
    auto context = qobject_cast<QQmlContext *>(oi.qtObject());
    Q_ASSERT(context);

    auto contextData = QQmlContextData::get(context);
    Q_ASSERT(contextData);

    const auto &propNames = contextData->propertyNames();
    m_contextPropertyNames.clear();
    m_contextPropertyNames.reserve(propNames.count());

    QV4::IdentifierHashEntry *e = propNames.d->entries;
    QV4::IdentifierHashEntry *end = e + propNames.d->alloc;
    while (e < end) {
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
        if (e->identifier)
            m_contextPropertyNames.push_back(e->identifier->string);
#else
        if (e->identifier.isValid())
            m_contextPropertyNames.push_back(e->identifier.toQString());
#endif
        ++e;
    }
}
void DynamicPropertyAdaptor::doSetObject(const ObjectInstance &oi)
{
    auto obj = oi.qtObject();
    if (obj) {
        m_propNames = obj->dynamicPropertyNames();
        obj->installEventFilter(this);
        connect(obj, SIGNAL(destroyed(QObject*)), this, SIGNAL(objectInvalidated()));
    }
}
void QmlAttachedPropertyAdaptor::doSetObject(const ObjectInstance &oi)
{
    auto data = QQmlData::get(oi.qtObject());
    Q_ASSERT(data);
    Q_ASSERT(data->hasExtendedData());
    Q_ASSERT(data->attachedProperties());

    m_attachedTypes.reserve(data->attachedProperties()->size());
    for (auto it = data->attachedProperties()->constBegin();
         it != data->attachedProperties()->constEnd(); ++it)
        m_attachedTypes.push_back(it.key());
}
void QMetaPropertyAdaptor::doSetObject(const ObjectInstance& oi)
{
    auto mo = oi.metaObject();
    if (!mo || oi.type() != ObjectInstance::QtObject || !oi.qtObject())
        return;

    connect(oi.qtObject(), SIGNAL(destroyed(QObject*)), this, SIGNAL(objectInvalidated()));

    for (int i = 0; i < mo->propertyCount(); ++i) {
        const QMetaProperty prop = mo->property(i);
        if (prop.hasNotifySignal()) {
            connect(oi.qtObject(), QByteArray("2") +
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
                prop.notifySignal().signature()
#else
                prop.notifySignal().methodSignature()
#endif
                , this, SLOT(propertyUpdated()));
            m_notifyToPropertyMap.insert(prop.notifySignalIndex(), i);
        }
    }
}
void AggregatedPropertyModel::setObject(const ObjectInstance &oi)
{
    clear();

    if (!oi.isValid())
        return;
    auto adaptor = PropertyAdaptorFactory::create(oi, this);
    if (!adaptor)
        return;

    auto count = adaptor->count();
    if (count)
        beginInsertRows(QModelIndex(), 0, count -1);

    m_rootAdaptor = adaptor;
    addPropertyAdaptor(m_rootAdaptor);

    if (count)
        endInsertRows();
}
void AssociativePropertyAdaptor::doSetObject(const ObjectInstance& oi)
{
    if (oi.type() == ObjectInstance::QtVariant)
        m_value = oi.variant();
}
Example #10
0
			/**
			 * Instantiate a String object
			 */
			ObjectInstance * instantiate(const QString& initial)
			{
				ObjectInstance * ret = new ObjectInstance(&clazz);
				ret->setData(&clazz, new QString(initial));
				return ret;
			}
Example #11
0
			/**
			 * constructor method
			 */
			static ObjectInstance * ctorImpl(Frame * frame)
			{
				ObjectInstance * thisPtr = frame->getThis();
				thisPtr->setData(&clazz, new QString());
				return thisPtr;
			}
/*
 * MutableMatchedObjectInstance
 */
MutableMatchedObjectInstance::MutableMatchedObjectInstance(const ObjectInstance& obj)
{
  for (unsigned i = 0, n = obj.AttributeCount(); i < n; i++)
    m_attributes->push_back(new MatchedObjectInstanceAttribute(obj.AttributeAtIndex(i)));
}