2
0
Эх сурвалжийг харах

Move some assets to new mesh ver and fix some bugs

Panagiotis Christopoulos Charitos 7 жил өмнө
parent
commit
d134c84b8f

BIN
engine_data/Plight.ankimesh


BIN
engine_data/Slight.ankimesh


+ 9 - 3
src/anki/resource/MeshLoader.cpp

@@ -137,8 +137,14 @@ Error MeshLoader::checkFormat(VertexAttributeLocation type, ConstWeakArray<Forma
 		return Error::USER_DATA;
 	}
 
+	if(!attrib.m_format)
+	{
+		// Attrib is not in use, no more checks
+		return Error::NONE;
+	}
+
 	// Scale should be 1.0 for now
-	if(attrib.m_scale != 0.0)
+	if(attrib.m_scale != 1.0f)
 	{
 		ANKI_RESOURCE_LOGE("Vertex attribute %u should have 1.0 scale", U(type));
 		return Error::USER_DATA;
@@ -159,7 +165,7 @@ Error MeshLoader::checkHeader() const
 	}
 
 	// Flags
-	if((h.m_flags & MeshBinaryFile::Flag::ALL) != MeshBinaryFile::Flag::ALL)
+	if((h.m_flags & ~MeshBinaryFile::Flag::ALL) != MeshBinaryFile::Flag::NONE)
 	{
 		ANKI_RESOURCE_LOGE("Wrong header flags");
 		return Error::USER_DATA;
@@ -178,7 +184,7 @@ Error MeshLoader::checkHeader() const
 		checkFormat(VertexAttributeLocation::BONE_WEIGHTS, Array<Format, 2>{{Format::NONE, Format::R8G8B8A8_UNORM}}));
 
 	// Indices format
-	if(h.m_indicesFormat != Format::R16_UINT || h.m_indicesFormat != Format::R32_UINT)
+	if(h.m_indicesFormat != Format::R16_UINT && h.m_indicesFormat != Format::R32_UINT)
 	{
 		ANKI_RESOURCE_LOGE("Wrong format for indices");
 		return Error::USER_DATA;

+ 11 - 6
src/anki/resource/MeshResource.cpp

@@ -112,10 +112,12 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 	PtrSize totalVertexBuffSize = 0;
 	for(U i = 0; i < header.m_vertexBufferCount; ++i)
 	{
-		m_vertBufferInfos[i].m_offset = getAlignedRoundUp(VERTEX_BUFFER_ALIGNMENT, totalVertexBuffSize);
+		alignRoundUp(VERTEX_BUFFER_ALIGNMENT, totalVertexBuffSize);
+
+		m_vertBufferInfos[i].m_offset = totalVertexBuffSize;
 		m_vertBufferInfos[i].m_stride = header.m_vertexBuffers[i].m_vertexStride;
 
-		totalVertexBuffSize = m_vertBufferInfos[i].m_offset + m_vertCount;
+		totalVertexBuffSize += m_vertCount * m_vertBufferInfos[i].m_stride;
 	}
 
 	m_vertBuff = getManager().getGrManager().newBuffer(BufferInitInfo(totalVertexBuffSize,
@@ -131,10 +133,13 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 		AttribInfo& out = m_attribs[attrib];
 		const MeshBinaryFile::VertexAttribute& in = header.m_vertexAttributes[attrib];
 
-		out.m_fmt = in.m_format;
-		out.m_relativeOffset = in.m_relativeOffset;
-		out.m_buffIdx = in.m_bufferBinding;
-		ANKI_ASSERT(in.m_scale == 1.0f && "Not supported ATM");
+		if(!!in.m_format)
+		{
+			out.m_fmt = in.m_format;
+			out.m_relativeOffset = in.m_relativeOffset;
+			out.m_buffIdx = in.m_bufferBinding;
+			ANKI_ASSERT(in.m_scale == 1.0f && "Not supported ATM");
+		}
 	}
 
 	// Other