float plMaxNodeBase::RegionPriority()
{
    TimeValue currTime = 0;//hsConverterUtils::Instance().GetTime(GetInterface());
    Object *obj = EvalWorldState(currTime).obj;
    if( !obj )
        return 0;

    Matrix3 l2w = GetObjectTM(currTime);

    if( obj->ClassID() == Class_ID(DUMMY_CLASS_ID,0) )
    {
        DummyObject* dummy = (DummyObject*)obj;
        Box3 bnd = dummy->GetBox();

        return BoxVolume(bnd, l2w);
    }

    if( obj->CanConvertToType(triObjectClassID) )
    {
        TriObject   *meshObj = (TriObject *)obj->ConvertToType(currTime, triObjectClassID);
        if( !meshObj )
            return 0;

        Mesh& mesh = meshObj->mesh;
        Box3 bnd = mesh.getBoundingBox();
        
        if( meshObj != obj )
            meshObj->DeleteThis();

        return BoxVolume(bnd, l2w);
    }

    // Don't know how to interpret other, it's not contained.
    return 0;
}
hsBool plMaxNodeBase::Contains(const Point3& worldPt)
{
    TimeValue currTime = 0;//hsConverterUtils::Instance().GetTime(GetInterface());
    Object *obj = EvalWorldState(currTime).obj;
    if( !obj )
        return false;

    Matrix3 l2w = GetObjectTM(currTime);
    Matrix3 w2l = Inverse(l2w);
    Point3 pt = w2l * worldPt;

    if( obj->ClassID() == Class_ID(DUMMY_CLASS_ID,0) )
    {
        DummyObject* dummy = (DummyObject*)obj;
        Box3 bnd = dummy->GetBox();
        return bnd.Contains(pt);
    }
    if( obj->CanConvertToType(triObjectClassID) )
    {
        TriObject   *meshObj = (TriObject *)obj->ConvertToType(currTime, triObjectClassID);
        if( !meshObj )
            return false;

        Mesh& mesh = meshObj->mesh;
        Box3 bnd = mesh.getBoundingBox();
        if( !bnd.Contains(pt) )
        {
            if( meshObj != obj )
                meshObj->DeleteThis();
            return false;
        }

        hsBool retVal = true;
        int i;
        for( i = 0; i < mesh.getNumFaces(); i++ )
        {
            Face& face = mesh.faces[i];

            Point3 p0 = mesh.verts[face.v[0]];
            Point3 p1 = mesh.verts[face.v[1]];
            Point3 p2 = mesh.verts[face.v[2]];

            Point3 n = CrossProd(p1 - p0, p2 - p0);

            if( DotProd(pt, n) > DotProd(p0, n) )
            {
                retVal = false;
                break;
            }
        }

        if( meshObj != obj )
            meshObj->DeleteThis();

        return retVal;
    }

    // If we can't figure out what it is, the point isn't inside it.
    return false;
}
void Ut_MApplicationPage::testContentIsCreatedOnEnteringAppearingState()
{
    MApplicationPage *page = new MApplicationPage;

    bool original_gMWindowIsOnDisplay = gMWindowIsOnDisplay;
    gMWindowIsOnDisplay = true;

    DummyObject dummyObject;
    dummyObject.setApplicationPage(m_subject);

    appWin->show();

    // Simulate an animated appearance.

    QCOMPARE(m_subject->isContentCreated(), false);

    page->appear(appWin); // first page appears "now" at all times
    m_subject->appear(appWin);

    QCOMPARE(m_subject->sceneWindowState(), MSceneWindow::Appearing);
    QCOMPARE(m_subject->isContentCreated(), true);
    QCOMPARE(dummyObject.onApplicationPageAppearingWasCalled, true);
    QCOMPARE(dummyObject.pageContentWasAlreadyCreatedInAppearing, true);

    // put it back to its original value
    gMWindowIsOnDisplay = original_gMWindowIsOnDisplay;
    delete page;
}
void Ut_MApplicationPage::testContentIsCreatedOnEnteringAppearedState()
{
    DummyObject dummyObject;
    dummyObject.setApplicationPage(m_subject);

    QCOMPARE(m_subject->isContentCreated(), false);

    appWin->sceneManager()->appearSceneWindowNow(m_subject);

    QCOMPARE(m_subject->sceneWindowState(), MSceneWindow::Appeared);
    QCOMPARE(m_subject->isContentCreated(), true);
    QCOMPARE(dummyObject.onApplicationPageAppearedWasCalled, true);
    QCOMPARE(dummyObject.pageContentWasAlreadyCreatedInAppeared, true);
}
示例#5
0
static void MakeDummyMesh(plMaxNode* node, plMaxMeshExtractor::NeutralMesh& mesh)
{
    hsPoint3 minV, maxV;

    Object* thisObj = node->GetObjectRef();
    DummyObject* thisDummy = (DummyObject*)thisObj;
    Box3 thisBoundSurface = thisDummy->GetBox();
    minV.fX = thisBoundSurface.Min().x;
    minV.fY = thisBoundSurface.Min().y;
    minV.fZ = thisBoundSurface.Min().z;
    maxV.fX = thisBoundSurface.Max().x;
    maxV.fY = thisBoundSurface.Max().y;
    maxV.fZ = thisBoundSurface.Max().z;

    MakeBoxMesh(node, mesh, minV, maxV);
}
示例#6
0
void testTypes(const TestBackend& testBackend)
{
	DummyObject object;

	testBackend.setUpDb();
	{
		ScopedFactory<TestTypesTableSync> scopedTestTypesTableSync;

		{
			cout << "____Creating table t100_testtypes" << endl;
			DBModule::SetConnectionString(testBackend.getConnectionString());

			ScopedModule<DBModule> scopedDBModule;

			BOOST_CHECK_EQUAL(true, DBTableSyncTemplate<TestTypesTableSync>::TABLE.CreatedTable);
			BOOST_CHECK_EQUAL(false, DBTableSyncTemplate<TestTypesTableSync>::TABLE.MigratedSchema);
			BOOST_CHECK_EQUAL(0, DBTableSyncTemplate<TestTypesTableSync>::TABLE.CreatedIndexes);

			BOOST_REQUIRE(!TestTypesTableSync::AddedRows->next());
			TestTypesTableSync::AddedRows.reset();

			ReplaceQuery<TestTypesTableSync> query(object);
			query.addFieldNull();
			query.addFieldNull();
			query.addFieldNull();
			query.addFieldNull();
			query.addFieldNull();
			query.addFieldNull();
			query.addFieldNull();
			query.addFieldNull();
			query.addFieldNull();
			query.addFieldNull();
			query.addFieldNull();

			query.execute(boost::optional<DBTransaction&>());
			TestTypesTableSync::AddedRows.reset();
		}
		{
			cout << "____Loading table t100_testtypes again" << endl;
			DBModule::SetConnectionString(testBackend.getConnectionString());

			ScopedModule<DBModule> scopedDBModule;

			BOOST_CHECK_EQUAL(false, DBTableSyncTemplate<TestTypesTableSync>::TABLE.CreatedTable);
			BOOST_CHECK_EQUAL(false, DBTableSyncTemplate<TestTypesTableSync>::TABLE.MigratedSchema);
			BOOST_CHECK_EQUAL(0, DBTableSyncTemplate<TestTypesTableSync>::TABLE.CreatedIndexes);

			BOOST_REQUIRE(TestTypesTableSync::AddedRows->next());

			BOOST_CHECK_EQUAL(0, TestTypesTableSync::AddedRows->getInt("integer32"));
			BOOST_CHECK_EQUAL(0, TestTypesTableSync::AddedRows->getLongLong("integer32"));
			BOOST_CHECK_EQUAL(boost::optional<int>(), TestTypesTableSync::AddedRows->getOptionalInt("integer32"));
			BOOST_CHECK_EQUAL(boost::optional<std::size_t>(), TestTypesTableSync::AddedRows->getOptionalUnsignedInt("integer32"));
			// 0 is interpreted as a boolean false.
			BOOST_CHECK_EQUAL(false, TestTypesTableSync::AddedRows->getBool("integer32"));

			BOOST_CHECK_EQUAL(0, TestTypesTableSync::AddedRows->getInt("integer64"));
			BOOST_CHECK_EQUAL(0, TestTypesTableSync::AddedRows->getLongLong("integer64"));
			BOOST_CHECK_EQUAL(boost::optional<int>(), TestTypesTableSync::AddedRows->getOptionalInt("integer64"));
			BOOST_CHECK_EQUAL(boost::optional<std::size_t>(), TestTypesTableSync::AddedRows->getOptionalUnsignedInt("integer64"));
			// 0 is interpreted as a boolean false.
			BOOST_CHECK_EQUAL(false, TestTypesTableSync::AddedRows->getBool("integer64"));

			BOOST_CHECK_EQUAL(0.0, TestTypesTableSync::AddedRows->getDouble("double"));
			BOOST_CHECK_EQUAL("", TestTypesTableSync::AddedRows->getText("text"));

			BOOST_CHECK_EQUAL(false, TestTypesTableSync::AddedRows->getBool("boolean"));
			// Note: the only way to check for an indeterminate value is to use the indeterminate function.
			BOOST_CHECK(boost::logic::indeterminate(TestTypesTableSync::AddedRows->getTribool("triboolean")));

			BOOST_CHECK_EQUAL(time_duration(not_a_date_time), TestTypesTableSync::AddedRows->getHour("time"));
			BOOST_CHECK_EQUAL(date(not_a_date_time), TestTypesTableSync::AddedRows->getDate("date"));
			BOOST_CHECK_EQUAL(ptime(not_a_date_time), TestTypesTableSync::AddedRows->getDateTime("timestamp"));

			BOOST_CHECK(0 == TestTypesTableSync::AddedRows->getGeometryFromWKT("geometry").get());

			BOOST_REQUIRE(!TestTypesTableSync::AddedRows->next());

			TestTypesTableSync::AddedRows.reset();

			// Delete data
			DeleteQuery<TestTypesTableSync> deleteQuery;
			deleteQuery.addWhereField(TABLE_COL_ID, object.getKey());
			deleteQuery.execute(boost::optional<DBTransaction&>());

			// TODO: use a select query to check that the table is empty.
		}
		{
			cout << "____Creating table t100_testtypes" << endl;
			DBModule::SetConnectionString(testBackend.getConnectionString());

			ScopedModule<DBModule> scopedDBModule;
			CoordinatesSystem::SetDefaultCoordinatesSystems(4326); // WGS84

			BOOST_CHECK_EQUAL(false, DBTableSyncTemplate<TestTypesTableSync>::TABLE.CreatedTable);
			BOOST_CHECK_EQUAL(false, DBTableSyncTemplate<TestTypesTableSync>::TABLE.MigratedSchema);
			BOOST_CHECK_EQUAL(0, DBTableSyncTemplate<TestTypesTableSync>::TABLE.CreatedIndexes);

			BOOST_REQUIRE(!TestTypesTableSync::AddedRows->next());
			TestTypesTableSync::AddedRows.reset();

			DummyObject object;

			ReplaceQuery<TestTypesTableSync> query(object);
			query.addField(static_cast<int>(-2147483648LL));
			query.addField(43);
			query.addField(static_cast<unsigned long long int>(9223372036854775807LL));
			query.addField(12345.12345);
			query.addField(std::string("Foo bar blah '\\"));
			query.addField(true);
			query.addField(boost::tribool::false_value);
			// TODO: there is no ValueExpression<time_duration>
			query.addField(std::string("22:00")); // time_duration(22, 0, 0));
			query.addFrameworkField<DateField>(date(2011, 03, 30));
			query.addFrameworkField<PtimeField>(ptime(date(1995, 12, 07), time_duration(13, 25, 10)));

			shared_ptr<Geometry> geom(CoordinatesSystem::GetInstanceCoordinatesSystem().createPoint(6, 10.3));
			query.addField(geom);

			query.execute(boost::optional<DBTransaction&>());
			TestTypesTableSync::AddedRows.reset();

			ModuleClassTemplate<DBModule>::End();

			cout << "____Loading table t100_testtypes again" << endl;
			DBModule::SetConnectionString(testBackend.getConnectionString());

			ModuleClassTemplate<DBModule>::PreInit();
			ModuleClassTemplate<DBModule>::Init();
			CoordinatesSystem::SetDefaultCoordinatesSystems(4326); // WGS84

			BOOST_CHECK_EQUAL(false, DBTableSyncTemplate<TestTypesTableSync>::TABLE.CreatedTable);
			BOOST_CHECK_EQUAL(false, DBTableSyncTemplate<TestTypesTableSync>::TABLE.MigratedSchema);
			BOOST_CHECK_EQUAL(0, DBTableSyncTemplate<TestTypesTableSync>::TABLE.CreatedIndexes);

			BOOST_REQUIRE(TestTypesTableSync::AddedRows->next());

			BOOST_CHECK_EQUAL(-2147483648LL, TestTypesTableSync::AddedRows->getInt("integer32"));
			BOOST_CHECK_EQUAL(-2147483648LL, TestTypesTableSync::AddedRows->getLongLong("integer32"));
			BOOST_CHECK_EQUAL(boost::optional<int>(-2147483648LL), TestTypesTableSync::AddedRows->getOptionalInt("integer32"));
			BOOST_CHECK_EQUAL(boost::optional<std::size_t>(-2147483648LL), TestTypesTableSync::AddedRows->getOptionalUnsignedInt("integer32"));
			// negative values are interpreted as a boolean false.
			BOOST_CHECK_EQUAL(false, TestTypesTableSync::AddedRows->getBool("integer32"));

			BOOST_CHECK_EQUAL(43, TestTypesTableSync::AddedRows->getInt("integer32_2"));
			BOOST_CHECK_EQUAL(43, TestTypesTableSync::AddedRows->getLongLong("integer32_2"));
			BOOST_CHECK_EQUAL(boost::optional<int>(43), TestTypesTableSync::AddedRows->getOptionalInt("integer32_2"));
			BOOST_CHECK_EQUAL(boost::optional<std::size_t>(43), TestTypesTableSync::AddedRows->getOptionalUnsignedInt("integer32_2"));
			// positive values are interpreted as a boolean true.
			BOOST_CHECK_EQUAL(true, TestTypesTableSync::AddedRows->getBool("integer32_2"));

			BOOST_CHECK_EQUAL(9223372036854775807LL, TestTypesTableSync::AddedRows->getLongLong("integer64"));
			// positive values are interpreted as a boolean true.
			BOOST_CHECK_EQUAL(true, TestTypesTableSync::AddedRows->getBool("integer64"));

			BOOST_CHECK_EQUAL(12345.12345, TestTypesTableSync::AddedRows->getDouble("double"));
			BOOST_CHECK_EQUAL(std::string("Foo bar blah '\\"), TestTypesTableSync::AddedRows->getText("text"));

			BOOST_CHECK_EQUAL(true, TestTypesTableSync::AddedRows->getBool("boolean"));
			BOOST_CHECK_EQUAL(boost::tribool::false_value, TestTypesTableSync::AddedRows->getTribool("triboolean"));

			BOOST_CHECK_EQUAL(time_duration(22, 0, 0), TestTypesTableSync::AddedRows->getHour("time"));
			BOOST_CHECK_EQUAL(date(2011, 03, 30), TestTypesTableSync::AddedRows->getDate("date"));
			BOOST_CHECK_EQUAL(ptime(date(1995, 12, 07), time_duration(13, 25, 10)), TestTypesTableSync::AddedRows->getDateTime("timestamp"));

			boost::shared_ptr<Point> point = boost::static_pointer_cast<Point, Geometry>(
				TestTypesTableSync::AddedRows->getGeometryFromWKT("geometry")
			);
			BOOST_CHECK_CLOSE(6.0, point->getX(), 1.0);
			BOOST_CHECK_CLOSE(10.3, point->getY(), 1.0);

			BOOST_REQUIRE(!TestTypesTableSync::AddedRows->next());

			TestTypesTableSync::AddedRows.reset();
		}
	}
}