Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Fix: DX11 renderer is unable to load LOD models from mods directories. #531

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theHarven
Copy link

The change forces LOD model files to be loaded from the same path as
main model file. The bug was reported here:
http://forums.keenswh.com/threads/1-105-directx-11-renderer-is-unable-to-load-level-of-detail-models.7371600/

@harag-on-steam
Copy link
Contributor

harag-on-steam commented May 26, 2016

Currently the LOD path is supposed to be relative to a content root (<SE>/Content, <Mod>/). Why change this? This will create a needless mismatch between Dx11 and the legacy Dx9 renderer.

@theHarven
Copy link
Author

Hey,
It will not create any mismatch, because it's already done this way in Dx9 renderer, look at the code at VRage.Renderer\RendererObjects\MyRendererEntity.cs:

        // This is more hack than correct solution, we have to find lods in same dir as models, because of MODs
        private string GetLodPath(string modelPath, string lodPath)
        {
            return Path.Combine(Path.GetDirectoryName(modelPath), Path.GetFileName(lodPath));
        }

        MyRenderModel AddLODs(string model)
        {
            MyLodModel lodModel = AddLOD(0, model);

            if (lodModel == null)
                return null;

            foreach (var lodDesc in lodModel.Model.LODs)
            {
                string lodModelPath = lodDesc.Model;

                if (String.IsNullOrEmpty(Path.GetExtension(lodModelPath)))
                {
                    //Debug.Fail("Missing LOD file extension: " + lodModelPath);
                    lodModelPath += ".mwm";
                }

                lodModelPath = GetLodPath(model, lodModelPath);

                if (lodDesc.RenderQualityList == null || lodDesc.RenderQualityList.Contains((int)MyRenderConstants.RenderQualityProfile.RenderQuality))
                    AddLOD(lodDesc.Distance, lodModelPath);
            }

            return lodModel.Model;
        }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants