예제 #1
0
        /// <summary>Initializes a new instance of the <see cref="UnmanagedArray{T}" /> struct.</summary>
        /// <param name="length">The length, in items, of the array.</param>
        /// <param name="alignment">The alignment, in bytes, of the items in the array or <c>zero</c> to use the system default.</param>
        /// <param name="zero"><c>true</c> if the items in the array should be zeroed; otherwise, <c>false</c>.</param>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="alignment" /> is not zero or a <c>power of two</c>.</exception>
        public UnmanagedArray(nuint length, nuint alignment = 0, bool zero = true)
        {
            var actualAlignment = (alignment != 0) ? alignment : DefaultAlignment;

            ThrowIfNotPow2(actualAlignment, nameof(alignment));

            Metadata *data;

            if (length != 0)
            {
                // This allocates one more item than necessary, but this can be used to help detect buffer
                // overruns and ensures that get a ref to an empty array isn't "undefined behavior".

                data = (Metadata *)Allocate(
                    SizeOf <Metadata>() + (length * SizeOf <T>()),
                    actualAlignment,
                    offset: SizeOf <nuint>(),
                    zero
                    );

                data->Alignment = alignment;
                data->Length    = length;
            }
            else
            {
                data = Empty._data;
            }

            _data = data;
        }
예제 #2
0
        public Node
        (
            AssimpString?mName = null,
            System.Numerics.Matrix4x4?mTransformation = null,
            Node *mParent       = null,
            uint?mNumChildren   = null,
            Node **mChildren    = null,
            uint?mNumMeshes     = null,
            uint *mMeshes       = null,
            Metadata *mMetaData = null
        ) : this()
        {
            if (mName is not null)
            {
                MName = mName.Value;
            }

            if (mTransformation is not null)
            {
                MTransformation = mTransformation.Value;
            }

            if (mParent is not null)
            {
                MParent = mParent;
            }

            if (mNumChildren is not null)
            {
                MNumChildren = mNumChildren.Value;
            }

            if (mChildren is not null)
            {
                MChildren = mChildren;
            }

            if (mNumMeshes is not null)
            {
                MNumMeshes = mNumMeshes.Value;
            }

            if (mMeshes is not null)
            {
                MMeshes = mMeshes;
            }

            if (mMetaData is not null)
            {
                MMetaData = mMetaData;
            }
        }
예제 #3
0
 private UnmanagedArray(Metadata *data)
 {
     AssertNotNull(data);
     _data = data;
 }
예제 #4
0
        public Scene
        (
            uint?mFlags             = null,
            Node *mRootNode         = null,
            uint?mNumMeshes         = null,
            Mesh **mMeshes          = null,
            uint?mNumMaterials      = null,
            Material **mMaterials   = null,
            uint?mNumAnimations     = null,
            Animation **mAnimations = null,
            uint?mNumTextures       = null,
            Texture **mTextures     = null,
            uint?mNumLights         = null,
            Light **mLights         = null,
            uint?mNumCameras        = null,
            Camera **mCameras       = null,
            Metadata *mMetaData     = null,
            void *mPrivate          = null
        ) : this()
        {
            if (mFlags is not null)
            {
                MFlags = mFlags.Value;
            }

            if (mRootNode is not null)
            {
                MRootNode = mRootNode;
            }

            if (mNumMeshes is not null)
            {
                MNumMeshes = mNumMeshes.Value;
            }

            if (mMeshes is not null)
            {
                MMeshes = mMeshes;
            }

            if (mNumMaterials is not null)
            {
                MNumMaterials = mNumMaterials.Value;
            }

            if (mMaterials is not null)
            {
                MMaterials = mMaterials;
            }

            if (mNumAnimations is not null)
            {
                MNumAnimations = mNumAnimations.Value;
            }

            if (mAnimations is not null)
            {
                MAnimations = mAnimations;
            }

            if (mNumTextures is not null)
            {
                MNumTextures = mNumTextures.Value;
            }

            if (mTextures is not null)
            {
                MTextures = mTextures;
            }

            if (mNumLights is not null)
            {
                MNumLights = mNumLights.Value;
            }

            if (mLights is not null)
            {
                MLights = mLights;
            }

            if (mNumCameras is not null)
            {
                MNumCameras = mNumCameras.Value;
            }

            if (mCameras is not null)
            {
                MCameras = mCameras;
            }

            if (mMetaData is not null)
            {
                MMetaData = mMetaData;
            }

            if (mPrivate is not null)
            {
                MPrivate = mPrivate;
            }
        }