SplashState::SplashState(Game* game) : GameState(game), _entities(log()), _spriteRenderer(renderer()), _sprites(assets(), loader(), &_spriteRenderer), _texts(loader(), &_spriteRenderer), _inputs(sys(), &log()), _camera(), _initialized(false), _running(false), _loop(sys()), _fpsTime(0), _fpsCount(0), _skipInput(nullptr), _skipTime(1), _nextState(nullptr) { _entities.registerComponentManager(&_sprites); _entities.registerComponentManager(&_texts); }
inline void dumpAssetManager () { list<PcAsset> assets (AssetManager::instance().listContent()); cout << "----all-registered-Assets----\n"; for (auto const& pA : assets) dump (pA); }
std::string extractAssetPath(const std::string fullAssetPath) { std::string path = fullAssetPath; std::string filename; std::string assets("assets/"); size_t pos = path.rfind(assets); if(pos != std::string::npos) filename.assign(path.begin() + pos + assets.length(), path.end()); else filename = path; return filename; }
size_t JsonWriteRichPresenceObj(char* dest, size_t maxLen, int nonce, int pid, const DiscordRichPresence* presence) { JsonWriter writer(dest, maxLen); { WriteObject top(writer); JsonWriteNonce(writer, nonce); WriteKey(writer, "cmd"); writer.String("SET_ACTIVITY"); { WriteObject args(writer, "args"); WriteKey(writer, "pid"); writer.Int(pid); if (presence != nullptr) { WriteObject activity(writer, "activity"); WriteOptionalString(writer, "state", presence->state); WriteOptionalString(writer, "details", presence->details); if (presence->startTimestamp || presence->endTimestamp) { WriteObject timestamps(writer, "timestamps"); if (presence->startTimestamp) { WriteKey(writer, "start"); writer.Int64(presence->startTimestamp); } if (presence->endTimestamp) { WriteKey(writer, "end"); writer.Int64(presence->endTimestamp); } } if ((presence->largeImageKey && presence->largeImageKey[0]) || (presence->largeImageText && presence->largeImageText[0]) || (presence->smallImageKey && presence->smallImageKey[0]) || (presence->smallImageText && presence->smallImageText[0])) { WriteObject assets(writer, "assets"); WriteOptionalString(writer, "large_image", presence->largeImageKey); WriteOptionalString(writer, "large_text", presence->largeImageText); WriteOptionalString(writer, "small_image", presence->smallImageKey); WriteOptionalString(writer, "small_text", presence->smallImageText); } if ((presence->partyId && presence->partyId[0]) || presence->partySize || presence->partyMax) { WriteObject party(writer, "party"); WriteOptionalString(writer, "id", presence->partyId); if (presence->partySize && presence->partyMax) { WriteArray size(writer, "size"); writer.Int(presence->partySize); writer.Int(presence->partyMax); } } if ((presence->matchSecret && presence->matchSecret[0]) || (presence->joinSecret && presence->joinSecret[0]) || (presence->spectateSecret && presence->spectateSecret[0])) { WriteObject secrets(writer, "secrets"); WriteOptionalString(writer, "match", presence->matchSecret); WriteOptionalString(writer, "join", presence->joinSecret); WriteOptionalString(writer, "spectate", presence->spectateSecret); } writer.Key("instance"); writer.Bool(presence->instance != 0); } } } return writer.Size(); }
const boost::filesystem::path assets_dir() const { return boost::filesystem::path(assets()); }
TEST_F(BPTFullpathTest2, Consistency) { StubConfig config; ASSERT_TRUE(config.LoadFromString(TestScenes::Simple03(), "")); std::unique_ptr<Assets> assets(ComponentFactory::Create<Assets>()); ASSERT_TRUE(assets->RegisterInterface<Texture>()); ASSERT_TRUE(assets->RegisterInterface<BSDF>()); ASSERT_TRUE(assets->RegisterInterface<TriangleMesh>()); ASSERT_TRUE(assets->RegisterInterface<Film>()); ASSERT_TRUE(assets->RegisterInterface<Camera>()); ASSERT_TRUE(assets->RegisterInterface<Light>()); ASSERT_TRUE(assets->Load(config.Root().Child("assets"))); std::unique_ptr<Primitives> primitives(ComponentFactory::Create<Primitives>()); ASSERT_TRUE(primitives->Load(config.Root().Child("scene"), *assets)); std::unique_ptr<Scene> scene(ComponentFactory::Create<Scene>(config.Root().Child("scene").AttributeValue("type"))); ASSERT_NE(scene, nullptr); scene->Load(primitives.release()); ASSERT_TRUE(scene->Configure(config.Root().Child("scene"))); ASSERT_TRUE(scene->Build()); BPTPathVertexPool pool; BPTSubpath subpathL(TransportDirection::LE); BPTSubpath subpathE(TransportDirection::EL); std::unique_ptr<ConfigurableSampler> sampler(ComponentFactory::Create<ConfigurableSampler>("random")); ASSERT_TRUE(sampler->Configure(ConfigNode(), *assets)); sampler->SetSeed(1); const int Samples = 1<<10; for (int sample = 0; sample < Samples; sample++) { pool.Release(); subpathL.Clear(); subpathE.Clear(); subpathL.Sample(*scene, *sampler, pool, 3, -1); subpathE.Sample(*scene, *sampler, pool, 3, -1); const int nL = subpathL.NumVertices(); const int nE = subpathE.NumVertices(); for (int s = 0; s <= nL; s++) { for (int t = 0; t <= nE; t++) { // # of vertices must be no less than 2 const int n = s + t; if (n < 2) { continue; } // Between termination vertices geometry term must be positive // Otherwise, EvaluateFullpathPDFRatio is invalid due to offsetting of geometry terms. Math::Float connGeom(-1); if (s > 0 && t > 0) { connGeom = RenderUtils::GeneralizedGeometryTermWithVisibility(*scene, subpathL.Vertex(s-1)->geom, subpathE.Vertex(t-1)->geom); if (Math::Abs(connGeom) < Math::Constants::Eps()) { continue; } } BPTFullPath fullpath(s, t, subpathL, subpathE); auto ps = fullpath.EvaluateFullpathPDF(s); if (Math::Abs(ps) < Math::Constants::Eps()) { // EvaluateFullpathPDFRatio is invalid if p_s is zero continue; } for (int i = 0; i < n; i++) { auto pi = fullpath.EvaluateFullpathPDF(i); auto piNext = fullpath.EvaluateFullpathPDF(i+1); auto ratio = fullpath.EvaluateFullpathPDFRatio(i); bool piIsZero = Math::Abs(pi) < Math::Constants::Eps(); bool piNextIsZero = Math::Abs(piNext) < Math::Constants::Eps(); // We note that we have only to check the case with p_i and p_{i+1} are both non-zero // because in actual weight calculation (cf. bpt.mis.power.cpp) // calculation of the ratio is aborted immediately after p_i or p_{i+1} is found to be non-zero. bool cond = false; if (piIsZero && piNextIsZero) { continue; } else if (piIsZero) { auto result = ExpectNear(Math::Float(0), ratio); EXPECT_TRUE(result); cond = result; } else if (piNextIsZero) { auto result = ExpectNear(Math::Float(0), ratio); EXPECT_TRUE(result); cond = result; } else { auto result = ExpectNearRelative(ratio, piNext / pi, Math::Constants::EpsLarge()); EXPECT_TRUE(result); cond = result; } if (!cond) { LM_LOG_DEBUG("Evaluating i = " + std::to_string(i)); LM_LOG_DEBUG("connGeom = " + std::to_string(connGeom)); LM_LOG_DEBUG("ps = " + std::to_string(ps)); LM_LOG_DEBUG("pi = " + std::to_string(pi)); LM_LOG_DEBUG("piNext = " + std::to_string(piNext)); LM_LOG_DEBUG("ratio = " + std::to_string(ratio)); fullpath.DebugPrint(); } } } } } }