-
Notifications
You must be signed in to change notification settings - Fork 1
fix(scan): stabilize scan --fix + better output + FSAA default #325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,25 @@ | ||
| #include "MaterialProcessor.h" | ||
| #include "RTShaderHelper.h" | ||
|
|
||
| namespace { | ||
| static Ogre::Pass* ensureFirstPass(const Ogre::MaterialPtr& mat) | ||
|
Check warning on line 5 in src/Assimp/MaterialProcessor.cpp
|
||
| { | ||
| if (!mat) | ||
| return nullptr; | ||
| Ogre::Technique* tech = nullptr; | ||
| if (mat->getNumTechniques() == 0) | ||
| tech = mat->createTechnique(); | ||
| else | ||
| tech = mat->getTechnique(0); | ||
|
|
||
| if (!tech) | ||
| return nullptr; | ||
| if (tech->getNumPasses() == 0) | ||
| return tech->createPass(); | ||
| return tech->getPass(0); | ||
| } | ||
| } // namespace | ||
|
|
||
| void MaterialProcessor::loadScene(const aiScene* scene) | ||
| { | ||
| for(auto i = 0u; i < scene->mNumMaterials; i++) { | ||
|
|
@@ -42,37 +61,43 @@ | |
| } | ||
| if(normalTexPtr) { | ||
| Ogre::LogManager::getSingleton().logMessage("MaterialProcessor: Applying RTSS normal map '" + normalFilename + "' to existing material '" + materialName + "'"); | ||
| // Some materials can exist without any techniques/passes (e.g. partially loaded | ||
| // script materials). Ensure a valid pass exists before RTSS touches it. | ||
| (void)ensureFirstPass(existingMaterial); | ||
| applyRTSSNormalMap(existingMaterial, normalTexPtr->getName()); | ||
|
Comment on lines
+64
to
67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard RTSS application when pass creation fails. At Line 66 the return from Suggested fix- (void)ensureFirstPass(existingMaterial);
- applyRTSSNormalMap(existingMaterial, normalTexPtr->getName());
+ Ogre::Pass* existingPass = ensureFirstPass(existingMaterial);
+ if (!existingPass) {
+ Ogre::LogManager::getSingleton().logMessage(
+ "MaterialProcessor: Skipping RTSS normal map for existing material '" + materialName +
+ "' because no valid pass could be ensured");
+ } else {
+ applyRTSSNormalMap(existingMaterial, normalTexPtr->getName());
+ }🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| return existingMaterial; | ||
| } | ||
|
|
||
| Ogre::MaterialPtr ogreMaterial = Ogre::MaterialManager::getSingleton().create(materialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); | ||
| Ogre::Pass* pass = ensureFirstPass(ogreMaterial); | ||
| if (!pass) | ||
| return ogreMaterial; | ||
|
|
||
| aiColor3D color(0.f, 0.f, 0.f); | ||
| if(AI_SUCCESS == material->Get(AI_MATKEY_COLOR_DIFFUSE, color)) { | ||
| ogreMaterial->getTechnique(0)->getPass(0)->setDiffuse(color.r, color.g, color.b, 1.0f); | ||
| pass->setDiffuse(color.r, color.g, color.b, 1.0f); | ||
| } | ||
|
|
||
| if(AI_SUCCESS == material->Get(AI_MATKEY_COLOR_AMBIENT, color)) { | ||
| // PBR-workflow exporters often set ambient to (0,0,0) which kills ambient | ||
| // lighting in Ogre's Phong model. Keep Ogre's default (white) in that case. | ||
| if(color.r > 0.001f || color.g > 0.001f || color.b > 0.001f) | ||
| ogreMaterial->getTechnique(0)->getPass(0)->setAmbient(color.r, color.g, color.b); | ||
| pass->setAmbient(color.r, color.g, color.b); | ||
| } | ||
|
|
||
| if(AI_SUCCESS == material->Get(AI_MATKEY_COLOR_SPECULAR, color)) { | ||
| ogreMaterial->getTechnique(0)->getPass(0)->setSpecular(color.r, color.g, color.b, 1.0f); | ||
| pass->setSpecular(color.r, color.g, color.b, 1.0f); | ||
| } | ||
|
|
||
| if(AI_SUCCESS == material->Get(AI_MATKEY_COLOR_EMISSIVE, color)) { | ||
| ogreMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(color.r, color.g, color.b); | ||
| pass->setSelfIllumination(color.r, color.g, color.b); | ||
| } | ||
|
|
||
| float shininess = 0.0f; | ||
| if(AI_SUCCESS == material->Get(AI_MATKEY_SHININESS, shininess)) { | ||
| ogreMaterial->getTechnique(0)->getPass(0)->setShininess(shininess); | ||
| pass->setShininess(shininess); | ||
| } | ||
|
|
||
| // Handle textures | ||
|
|
@@ -85,7 +110,7 @@ | |
| if(!texturePtr){ | ||
| texturePtr = loadTexture(textureFilename, path, scene); | ||
| } | ||
| auto* tus = ogreMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(texturePtr->getName()); | ||
| auto* tus = pass->createTextureUnitState(texturePtr->getName()); | ||
| tus->setName("diffuse_map"); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the retry path genuinely “light.”
lightFlags |= additionalFlagscan immediately re-enable the same post-process bits that caused the first import to fail, so the fallback stops being a real fallback as soon as a caller supplies extra Assimp flags. This should carry through only a known-safe subset, not the whole caller mask.🤖 Prompt for AI Agents