小编K. *_*ull的帖子

从一组最接近直线的点中找到点的最快算法是什么?

我有:
-一组已知大小的点(在我的情况下,只有6个点)
-一条以x = s + t * r为特征的线,其中x,s和r是3D矢量

I need to find the point closest to the given line. The actual distance does not matter to me.

I had a look at several different questions that seem related (including this one) and know how to solve this on paper from my highschool math classes. But I cannot find a solution without calculating every distance, and I am sure there has to be a better/faster way. Performance is absolutely crucial …

c++ performance linear-algebra computational-geometry

4
推荐指数
1
解决办法
146
查看次数

如何/何时在 DirectX 中释放资源和资源视图

我正在开发 DirectX 11 演示应用程序,并偶然发现了以下问题:
当我从文件创建着色器资源视图(假设是纹理)时,我必须在使用后释放它,就像所有其他 D3D11 对象一样。但是隐式创建的底层资源又如何呢?

我可以想象三种情况:
+ 我应该保留该资源。它是通过调用someShaderResourceView->Release()
+ 来释放的,我应该将它与着色器资源视图对象一起手动释放。
+ 我应该立即发布它。这似乎有效,尽管对我来说似乎不合理。

处理这个问题的正确方法是什么?

编辑:我正在使用 DirectXTex 纹理加载库,但我想保持问题的一般性。

ID3D11Resource *resource;
ID3D11ShaderResourceView *resourceView;
HRESULT result = CreateWICTextureFromFile(device, path.c_str(), &resource, &texture, 0);
//resource->Release(); ???
Run Code Online (Sandbox Code Playgroud)

CreateWICTextureFromFile(...)也可以使用旧的 D3DX11 功能来代替D3DX11CreateShaderResourceViewFromFile(...)

c++ directx resources

2
推荐指数
1
解决办法
2624
查看次数