Skip to content

RenderModel_TextureMap_(packed_)t Incorrect data types in C# #638

Description

@jstefanelli

The current implementation of the 2 strucures in openvr_api.cs is:

[StructLayout(LayoutKind.Sequential)]
public struct RenderModel_TextureMap_t
{
	public char unWidth;
	public char unHeight;
	public IntPtr rubTextureMapData; // const uint8_t *
}

// This structure is for backwards binary compatibility on Linux and OSX only
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct RenderModel_TextureMap_t_Packed
{
	public char unWidth;
	public char unHeight;
	public IntPtr rubTextureMapData; // const uint8_t *

	public RenderModel_TextureMap_t_Packed(RenderModel_TextureMap_t unpacked)
	{
		this.unWidth = unpacked.unWidth;
		this.unHeight = unpacked.unHeight;
		this.rubTextureMapData = unpacked.rubTextureMapData;
	}

	public void Unpack(ref RenderModel_TextureMap_t unpacked)
	{
		unpacked.unWidth = this.unWidth;
		unpacked.unHeight = this.unHeight;
		unpacked.rubTextureMapData = this.rubTextureMapData;
	}
}

Where, according to the docs, the fields unWidth and unHeight are supposed to be ushort.

Manually changing these in the file solves a problem with Render Model Texture Loading.
(Example: with the non midified structures, loading the model vr_controller_vive_1_5 returns a 0x8 px texture.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions