Git Product home page Git Product logo

Comments (8)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 16, 2024
The trunk has been updated to 3.1.1 for a while now.

I noticed some irregularities with marshaling some strings and made tweaks to 
AssimpLibrary.cs where I was using MarshalStructure<T> rather than Read<T> 
which seemed to clear that up. Perhaps that was what you were seeing? Or is 
this an issue with Export (marshaling back to native?)? 

Please provide an example where AiString marshaling fails with some explanation 
of what should be expected and I'll look into it.

Original comment by nicholas.woodfield on 27 Jun 2014 at 2:40

from assimp-net.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 16, 2024
I did a quick check in trunk and the AiString problem is still here.. the same 
problem i had..

I attached a sample model to show this.. the names of the meshes and bones have 
only the first byte correct and the rest is zero.. 

you can use a previous version of assimpNet (not based on v3.1.1 assimp) and it 
will read them ok

Also you should add this
https://github.com/VirusFree/AssimpNet/commit/c04f0cd69fe5b1f46cf6cb61a2c7ff5532
7187a5

Original comment by [email protected] on 27 Jun 2014 at 11:14

Attachments:

from assimp-net.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 16, 2024
Alrighty, after conferring with one Alex on the native Assimp side we got to 
the bottom of this. I'm not exactly sure how this would change with upgrading 
to v3.1.1, but perhaps its because the library has moved to a different .NET 
runtime? Anyways, yes I did observe the same oddity with AiMesh which utilizes 
Marshal::PtrToStructure because it is not a blittable type.

Anyways, that function is rarely used so I have come up with a more elegant 
solution to use custom marshaling for non-blittable types. The changes are in 
the trunk now and I have tested against your model and the mesh names are 
coming in.

BTW, I did not see any issue with bone names.

Original comment by nicholas.woodfield on 1 Jul 2014 at 7:40

  • Changed state: Fixed

from assimp-net.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 16, 2024
Re-opening, works in 32 bit but not 64 bit due to an alignment issue. Jumped 
the gun on that one

Original comment by nicholas.woodfield on 1 Jul 2014 at 11:52

  • Changed state: Accepted

from assimp-net.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 16, 2024
Yes, i tested the trunk in 32 bit and works ok, in 64 it crahes with acces 
violation..

a quick look i found that there is indeed an alignment problem.
eg in lines (MarshalNativeToManaged.cs line 147)
            mesh.NumFaces = MemoryHelper.Read<uint>(currPos);
            currPos = MemoryHelper.AddIntPtr(currPos, sizeof(uint));

            mesh.Vertices = MemoryHelper.Read<IntPtr>(currPos);
            currPos = MemoryHelper.AddIntPtr(currPos, IntPtr.Size);


i check the pointers and the memory at that locations and i see that the 
correct data for the vertices pointer start with some padding. This is because 
was is before it is not 64-bit aligned.

the struct aimesh from assimp is 
struct aiMesh
{
    unsigned int mPrimitiveTypes;
    unsigned int mNumVertices;
    unsigned int mNumFaces;
    C_STRUCT aiVector3D* mVertices;
...
}
which means mVertices is not 64-bit, since the 3 previous entries add up to 12 
bytes, so with some compiler padding/alignment mVertices should start at 16.

So the problem is that doing it by hand the MemoryHelper.AddIntPtr(currPos, 
xxx); means we are skipping the compiler-added padding for alignemnt.


Original comment by [email protected] on 2 Jul 2014 at 1:09

from assimp-net.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 16, 2024
Ok i fixed it.

here is the commit
https://github.com/VirusFree/AssimpNet/commit/b97f8aebdc6d560b73cdd04fdf92c52d30
6db874

Original comment by [email protected] on 2 Jul 2014 at 1:12

from assimp-net.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 16, 2024
and here it is as a patch :)

Original comment by [email protected] on 2 Jul 2014 at 1:16

Attachments:

from assimp-net.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 16, 2024
Thanks, I'll add the methods to MemoryHelper.

However I went a different direction, ultimately a compromise with creating 
AiMesh/AiAnimMesh blittable and avoiding any use of .NET marshaling. Still 
keeping the option for custom marshaling in the future though. Probably should 
have gone that route in the first place to avoid boxing.

BTW for future reference, the original problem is explained in the comments 
section of the article below:

http://msdn.microsoft.com/en-us/library/zycewsya%28v=vs.100%29.aspx

Original comment by nicholas.woodfield on 3 Jul 2014 at 1:29

  • Changed state: Fixed

from assimp-net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.