Skip to content
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

Add TraceResult:Material #78

Closed
wants to merge 2 commits into from
Closed

Conversation

yogwoggf
Copy link
Contributor

Fixes #77

PR Type (tick all that are applicable)

  • Bug Fix
  • New Feature (doesn't break Module <-> Lua compatibility)
  • New Feature (breaks Module <-> Lua compatibility)
  • Documentation Update Required

Tested Targets (only applicable for changes to the binary module, delete otherwise)

  • windows-x64-release
  • windows-x86-release

Checklist

  • I have read and understand the contributing guidelines
  • I have tested all aspects of this PR (not required)

Description
TraceResult:Material() returns the material path (local to materials of course) of the trace result.
I don't really see a need for multiple texture getters because you could literally just do
Material(TraceResult:Material()):GetString("$basetexture") and have more options in doing so.

Please explain further

@Derpius
Copy link
Owner

Derpius commented Sep 22, 2022

I don't really see a need for multiple texture getters because you could literally just do Material(TraceResult:Material()):GetString("$basetexture")

Have you forgotten how unbearably slow Material is?
And that doesn’t account for other textures not present on the material like MRAO

@@ -59,7 +59,8 @@ TraceResult::TraceResult(
detailScale(mat.detailScale), detailBlendFactor(mat.detailBlendFactor),
detailBlendMode(mat.detailBlendMode), detailTint(mat.detailTint),
detailAlphaMaskBaseTexture(mat.detailAlphaMaskBaseTexture),
texScale(mat.texScale)
texScale(mat.texScale),
materialPath(&mat.path)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should copy to the TraceResult (The accel struct could be gc’d while the trace result is still in memory)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact I'm going to look into how efficient my VTF copy constructor is, cause copying the textures in might also be doable now

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see why you did this now, std::string isn't trivially destructible

Solution to this is just providing access to all common material properties through the TraceResult

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea didn't work, gonna have to use ptrs to strings cause Lua doesn't call __gc until far too late
I was copying IVTFTexture resources to Lua directly instead of having the user load them from a path

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea didn't work, gonna have to use ptrs to strings cause Lua doesn't call __gc until far too late I was copying IVTFTexture resources to Lua directly instead of having the user load them from a path

Actually I'm going to implement a __gc method for TraceResults

@@ -90,6 +90,8 @@ class TraceResult
CBaseEntity* rawEnt;
uint32_t submatIdx;

const std::string* materialPath = nullptr;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn’t be a pointer, see above

@Derpius Derpius added enhancement New feature or request binary module Issues relating to the binary module labels Sep 22, 2022
@Derpius Derpius added this to the v0.12.0 milestone Sep 22, 2022
@Derpius Derpius closed this Sep 22, 2022
@yogwoggf yogwoggf deleted the texmatget branch September 25, 2022 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binary module Issues relating to the binary module enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature] Add getters to TraceResult for material and texture paths
2 participants