/** * Sets new system settings (optionally writes out to the ini). */ void FSystemSettings::ApplyNewSettings( const FSystemSettingsData& NewSettings, bool bWriteToIni ) { // we can set any setting before the engine is initialized so don't bother restoring values. bool bEngineIsInitialized = GEngine != NULL; // if the engine is running, there are certain values we can't set immediately if (bEngineIsInitialized) { // apply settings to the runtime system. ApplySettingsAtRuntime(NewSettings, bWriteToIni); ApplyOverrides(); } else { // if the engine is not initialized we don't need to worry about all the deferred settings etc. // as we do above. // Set new settings. Would look prettier if we didn't derive from the Data class... (FSystemSettingsData&)(*this) = NewSettings; // If requested, save the settings to ini. if ( bWriteToIni ) { SaveToIni(); } ApplyOverrides(); } }
void FSystemSettings::CVarSink() { ApplyOverrides(); auto CVarAllowHighQualityLightMaps = IConsoleManager::Get().FindConsoleVariable(TEXT("r.HighQualityLightMaps")); if (bInitialUseHighQualityLightmaps != (CVarAllowHighQualityLightMaps->GetInt() != 0)) { // This setting can't be changed at runtime, so put it back to what it was originally CVarAllowHighQualityLightMaps->Set(bInitialUseHighQualityLightmaps); UE_LOG(LogSystemSettings, Warning, TEXT("r.HighQualityLightMaps cannot be changed at runtime. Ignoring setting change")); } }
/** * Initializes system settings and included texture LOD settings. * * @param bSetupForEditor Whether to initialize settings for Editor */ void FSystemSettings::Initialize( bool bSetupForEditor ) { TestBitFieldFunctions(); RegisterShowFlagConsoleVariables(); // Load the settings that will be the default for every other compat level, and the editor, and the other split screen levels. FSystemSettingsData DefaultSettings; DefaultSettings.LoadFromIni(GetSectionName(false), GEngineIni, false); bIsEditor = bSetupForEditor; (FSystemSettingsData&)(*this) = DefaultSettings; LoadFromIni(); ApplyOverrides(); IConsoleManager::Get().RegisterConsoleVariableSink_Handle(FConsoleCommandDelegate::CreateRaw(this, &FSystemSettings::CVarSink)); // initialize a critical texture streaming value used by texture loading, etc int32 MinTextureResidentMipCount = 7; GConfig->GetInt(TEXT("TextureStreaming"), TEXT("MinTextureResidentMipCount"), MinTextureResidentMipCount, GEngineIni); UTexture2D::SetMinTextureResidentMipCount(MinTextureResidentMipCount); }
AtNode * ProcessPointsBase( IPoints & prim, ProcArgs & args, SampleTimeSet & sampleTimes, std::vector<AtPoint> & vidxs, std::vector<float> & radius, MatrixSampleMap * xformSamples ) { if ( !prim.valid() ) { return NULL; } Alembic::AbcGeom::IPointsSchema &ps = prim.getSchema(); TimeSamplingPtr ts = ps.getTimeSampling(); sampleTimes.insert( ts->getFloorIndex(args.frame / args.fps, ps.getNumSamples()).second ); std::string name = args.nameprefix + prim.getFullName(); AtNode * instanceNode = NULL; std::string cacheId; SampleTimeSet singleSampleTimes; singleSampleTimes.insert( ts->getFloorIndex(args.frame / args.fps, ps.getNumSamples()).second ); ICompoundProperty arbGeomParams = ps.getArbGeomParams(); ISampleSelector frameSelector( *singleSampleTimes.begin() ); std::vector<std::string> tags; //get tags if ( arbGeomParams != NULL && arbGeomParams.valid() ) { if (arbGeomParams.getPropertyHeader("mtoa_constant_tags") != NULL) { const PropertyHeader * tagsHeader = arbGeomParams.getPropertyHeader("mtoa_constant_tags"); if (IStringGeomParam::matches( *tagsHeader )) { IStringGeomParam param( arbGeomParams, "mtoa_constant_tags" ); if ( param.valid() ) { IStringGeomParam::prop_type::sample_ptr_type valueSample = param.getExpandedValue( frameSelector ).getVals(); if ( param.getScope() == kConstantScope || param.getScope() == kUnknownScope) { Json::Value jtags; Json::Reader reader; if(reader.parse(valueSample->get()[0], jtags)) for( Json::ValueIterator itr = jtags.begin() ; itr != jtags.end() ; itr++ ) { tags.push_back(jtags[itr.key().asUInt()].asString()); } } } } } } if ( args.makeInstance ) { std::ostringstream buffer; AbcA::ArraySampleKey sampleKey; for ( SampleTimeSet::iterator I = sampleTimes.begin(); I != sampleTimes.end(); ++I ) { ISampleSelector sampleSelector( *I ); ps.getPositionsProperty().getKey(sampleKey, sampleSelector); buffer << GetRelativeSampleTime( args, (*I) ) << ":"; sampleKey.digest.print(buffer); buffer << ":"; } cacheId = buffer.str(); instanceNode = AiNode( "ginstance" ); AiNodeSetStr( instanceNode, "name", name.c_str() ); args.createdNodes.push_back(instanceNode); if ( args.proceduralNode ) { AiNodeSetByte( instanceNode, "visibility", AiNodeGetByte( args.proceduralNode, "visibility" ) ); } else { AiNodeSetByte( instanceNode, "visibility", AI_RAY_ALL ); } ApplyTransformation( instanceNode, xformSamples, args ); NodeCache::iterator I = g_meshCache.find(cacheId); // parameters overrides if(args.linkOverride) ApplyOverrides(name, instanceNode, tags, args); // shader assignation if (nodeHasParameter( instanceNode, "shader" ) ) { if(args.linkShader) { ApplyShaders(name, instanceNode, tags, args); } else { AtArray* shaders = AiNodeGetArray(args.proceduralNode, "shader"); if (shaders->nelements != 0) AiNodeSetArray(instanceNode, "shader", AiArrayCopy(shaders)); } } if ( I != g_meshCache.end() ) { AiNodeSetPtr(instanceNode, "node", (*I).second ); return NULL; } } bool isFirstSample = true; float radiusPoint = 0.1f; if (AiNodeLookUpUserParameter(args.proceduralNode, "radiusPoint") !=NULL ) radiusPoint = AiNodeGetFlt(args.proceduralNode, "radiusPoint"); bool useVelocities = false; if ((sampleTimes.size() == 1) && (args.shutterOpen != args.shutterClose)) { // no sample, and motion blur needed, let's try to get velocities. if(ps.getVelocitiesProperty().valid()) useVelocities = true; } for ( SampleTimeSet::iterator I = sampleTimes.begin(); I != sampleTimes.end(); ++I, isFirstSample = false) { ISampleSelector sampleSelector( *I ); Alembic::AbcGeom::IPointsSchema::Sample sample = ps.getValue( sampleSelector ); Alembic::Abc::P3fArraySamplePtr v3ptr = sample.getPositions(); size_t pSize = sample.getPositions()->size(); if(useVelocities && isFirstSample) { float scaleVelocity = 1.0f; if (AiNodeLookUpUserParameter(args.proceduralNode, "scaleVelocity") !=NULL ) scaleVelocity = AiNodeGetFlt(args.proceduralNode, "scaleVelocity"); vidxs.resize(pSize*2); Alembic::Abc::V3fArraySamplePtr velptr = sample.getVelocities(); float timeoffset = ((args.frame / args.fps) - ts->getFloorIndex((*I), ps.getNumSamples()).second) * args.fps; for ( size_t pId = 0; pId < pSize; ++pId ) { Alembic::Abc::V3f posAtOpen = ((*v3ptr)[pId] + (*velptr)[pId] * scaleVelocity *-timeoffset); AtPoint pos1; pos1.x = posAtOpen.x; pos1.y = posAtOpen.y; pos1.z = posAtOpen.z; vidxs[pId]= pos1; Alembic::Abc::V3f posAtEnd = ((*v3ptr)[pId] + (*velptr)[pId]* scaleVelocity *(1.0f-timeoffset)); AtPoint pos2; pos2.x = posAtEnd.x; pos2.y = posAtEnd.y; pos2.z = posAtEnd.z; vidxs[pId+pSize]= pos2; radius.push_back(radiusPoint); } } else // not motion blur or correctly sampled particles { for ( size_t pId = 0; pId < pSize; ++pId ) { AtPoint pos; pos.x = (*v3ptr)[pId].x; pos.y = (*v3ptr)[pId].y; pos.z = (*v3ptr)[pId].z; vidxs.push_back(pos); radius.push_back(radiusPoint); } } } AtNode* pointsNode = AiNode( "points" ); if (!pointsNode) { AiMsgError("Failed to make points node for %s", prim.getFullName().c_str()); return NULL; } args.createdNodes.push_back(pointsNode); if ( instanceNode != NULL) { AiNodeSetStr( pointsNode, "name", (name + ":src").c_str() ); } else { AiNodeSetStr( pointsNode, "name", name.c_str() ); } if(!useVelocities) { AiNodeSetArray(pointsNode, "points", AiArrayConvert( vidxs.size() / sampleTimes.size(), sampleTimes.size(), AI_TYPE_POINT, (void*)(&(vidxs[0])) )); AiNodeSetArray(pointsNode, "radius", AiArrayConvert( vidxs.size() / sampleTimes.size(), sampleTimes.size(), AI_TYPE_FLOAT, (void*)(&(radius[0])) )); if ( sampleTimes.size() > 1 ) { std::vector<float> relativeSampleTimes; relativeSampleTimes.reserve( sampleTimes.size() ); for (SampleTimeSet::const_iterator I = sampleTimes.begin(); I != sampleTimes.end(); ++I ) { chrono_t sampleTime = GetRelativeSampleTime( args, (*I) ); relativeSampleTimes.push_back(sampleTime); } AiNodeSetArray( pointsNode, "deform_time_samples", AiArrayConvert(relativeSampleTimes.size(), 1, AI_TYPE_FLOAT, &relativeSampleTimes[0])); } } else { AiNodeSetArray(pointsNode, "points", AiArrayConvert( vidxs.size() / 2, 2, AI_TYPE_POINT, (void*)(&(vidxs[0])) )); AiNodeSetArray(pointsNode, "radius", AiArrayConvert( vidxs.size() /2 / sampleTimes.size(), sampleTimes.size(), AI_TYPE_FLOAT, (void*)(&(radius[0])) )); AiNodeSetArray( pointsNode, "deform_time_samples", AiArray(2, 1, AI_TYPE_FLOAT, 0.f, 1.f)); } AddArbitraryGeomParams( arbGeomParams, frameSelector, pointsNode ); if ( instanceNode == NULL ) { if ( xformSamples ) { ApplyTransformation( pointsNode, xformSamples, args ); } return pointsNode; } else { AiNodeSetByte( pointsNode, "visibility", 0 ); AiNodeSetInt( pointsNode, "mode", 1 ); AiNodeSetPtr(instanceNode, "node", pointsNode ); g_meshCache[cacheId] = pointsNode; return pointsNode; } }
void FSystemSettings::CVarSink() { ApplyOverrides(); }
void ActorAnimationOverrider::Override( TESNPC* NPC ) const { SME_ASSERT(NPC); #ifndef NDEBUG _MESSAGE("Attempting to override Animations for NPC %08X...", NPC->refID); gLog.Indent(); #endif // !NDEBUG ClearOverrides(NPC); if (GetBlacklisted(NPC)) { #ifndef NDEBUG _MESSAGE("Blacklisted, skipping..."); #endif // !NDEBUG } else { TESRace* Race = InstanceAbstraction::GetNPCRace(NPC); if (Race == NULL) { #ifndef NDEBUG _MESSAGE("No race?! The gall! We are not amused, not the slightest!"); #endif // !NDEBUG } else { const char* RaceName = InstanceAbstraction::GetFormName(Race); const char* GenderPath = NULL; if (InstanceAbstraction::GetNPCFemale(NPC)) GenderPath = "F"; else GenderPath = "M"; UInt32 FormID = NPC->refID & 0x00FFFFFF; TESFile* Plugin = InstanceAbstraction::GetOverrideFile(NPC, 0); if (Settings::kAnimOverridePerRace.GetData().i) { if (RaceName && strlen(RaceName) > 2) { char Buffer[0x200] = {0}; FORMAT_STR(Buffer, "PERRACE_%s_%s", RaceName, GenderPath); AnimationFileListT Overrides; if (GetSpecialAnims(NPC, Buffer, Overrides)) { #ifndef NDEBUG _MESSAGE("Per-Race:"); gLog.Indent(); #endif // !NDEBUG ApplyOverrides(NPC, Overrides); #ifndef NDEBUG gLog.Outdent(); #endif // !NDEBUG } } } if (Settings::kAnimOverridePerNPC.GetData().i && Plugin) { char Buffer[0x200] = {0}; FORMAT_STR(Buffer, "PERNPC_%s_%08X", Plugin->name, FormID); AnimationFileListT Overrides; if (GetSpecialAnims(NPC, Buffer, Overrides)) { #ifndef NDEBUG _MESSAGE("Per-NPC:"); gLog.Indent(); #endif // !NDEBUG ApplyOverrides(NPC, Overrides); #ifndef NDEBUG gLog.Outdent(); #endif // !NDEBUG } } } } #ifndef NDEBUG gLog.Outdent(); #endif // !NDEBUG }