User:Ankitm/GSoC 2020/Weekly Reports

Week 12 August 17 - 21

  • Fix overlapping nodes in the nodetree. rB0c7801fa
  • Vertex normals:
    • Parse vertex normals: vn lines. rBc583afd6
    • Decouple getting smooth groups from export parameters rB0479dc41
    • Export vertex normals if smooth shading is enabled. rB4923087d
  • Refactor:
    • Move file opening errors to constructors. rB491bd8b8
    • Add a public member function in MaterialWrap. rBc815ba0a
    • Move object creation code from constructor. rB4777a6a5
    • Remove unused uv vertex index offset. rBedd5307e
  • For polygons with holes:
    • Initial commit for ngon_tessellate: it is untested and will very likely crash. rBefab0bc7
    • Fix tessellate crash due to wrong Vector size. rB5b0cb5bb
    • Add newly creates faces to imported faces and dissolve edges. As of this commit, ngons are tessellated but the holes are also filled up since it keeps falling back to triangle-fan method. Need to debug and fix it to use scan-fill. rBe76ab124
    • Edit FaceElem list outside polygon creation code. rB10e3f23b
  • Parsing
    • Use blender::StringRef instead of std::string_view. rB73454388
    • Use remove_prefix for easy transition to StringRef. rBae122533
    • Read multiple lines with "\\n" line breaks. rBa662ddd7
  • Silence normal being zero warnings in mesh validate's verbose mode. rB3f8a8d17
  • Silence mesh_validate verbose warnings. rB32fe2869

Week 11 August 10 - 15

  • Catch out of range exceptions for stoi/stof. rBbb2eca07.
  • Add vertex offset due to Curves' vertices also. rBb378f84f.
  • Use const& instead of pointers in Mesh class. rB82eff7a0.
  • Accept 3D UV vertex coordinates rB6ee696e5.
  • Fix loose edge export & import, and offsets. rBc010cf58.
  • Fix vertex offsets for MEdges and MLoops. rBe0c0b8ff.
  • Fix several material import bugs, remove wrong assert. rB606b0d7d.
  • Fix usemtl line not being written. rB69f70829
  • Use function pointer; remove redundant variables. rBba0d376e
  • Export packed image file names as if they're in current directory. rBd9cdfba2
  • Use const; move constructors to implementation file. rBa725b6f7
  • Fix several material import bugs, remove wrong assert. rB606b0d7d
  • Apply axes transform to exportable Nurbs. rBd882a63e
  • Move MTL writer code near OBJ writer code. rBae1c5f16
  • Skip parsing extra texture map options, move MTLWriter from Objects code. rB99ededd9
  • Clean up: use const, header cleanup. rBa732abd9
  • Move file open errors to constructors. rB491bd8b8
  • Add a public member function in MaterialWrap. rBc815ba0a
  • Cleanup : clang format; cout > cerr rBc5e0e82f

Week 10 August 4 - 7

Committed material creation prototype & fixed several issues later on.

  • Accept 3D UV vertex coordinates rB6ee696e5
  • Fix wrong material exporter assert added recently. rB85989931

Week 9 July 27 - 31

I could not work for the whole week productively.

  • Off-topic (Master) Enable header auto-complete suggestions in Xcode. rB27d50d6f This turned into a standardised way of dealing with Xcode's include file paths.
  • Off-topic: Respond to a new developer on a bug fix and the devtalk thread
  • Off-topic: Tested ClangBuildAnalyzer on Blender (lite build).

Week 8: July 20 - 25

  • Move vertex (and UV vertex) list outside OBJRawObject so that objects that are defined (o curvename) after the list of vertices is written can access them using relative indices. 71eadb4b62
  • Support NURBS curve import 6e21f8c20d. Got help from Howard Trickey for fixing a visibility bug. af278ce58b
  • Fix build errors: avoid uint with Vector's size() function. 7bd38c2776. Style guide was updated to discourage uint usage and {} initialisation doesn't allow narrowing conversions. There's still a lot of code in OBJ exporter that uses uint, that's for a Friday. This commit was only for removing uint with Vector.size().
  • Worked on Refactor: Conform to style guide, add documentation. 97aa9d44fa.
  • Move Object creation code in Mesh creation class. 2bb56c83fa. This helps adding deform groups and materials to the Object in one place and away from the code that adds that Object to a Collection.
  • Rename exportable_meshes to exportable_as_mesh 4716660591. (This was long due.)
  • Support importing vertex deform groups. 25526821a4.
  • Use VectorSet instead of vector for def_group. b33a4592a3. The commit 37467ec5e9 used std::vector<std::string> which is slow due to linear searching. Jacques Lucke suggested using VectorSet for faster lookups. Also StringRef is used to avoid copying.
  • Cleanup: silence clang-tidy warnings; comments. ffaa1df439.
  • Wrote an intial draft of importer's design document. T68936#982751. Still need to incorporate mentors' feedback on the document. Google doc for Importer design

Next Week plans

  • Fix design doc
  • MTL and material grouping.
  • Port a portion of mesh editing tools written in python to C++: bpy_utils.mesh.ngon_tessellate (in release/scripts/modules/bpy_extras/mesh_utils.py
  • Add error handling for bad meshes or fix them.

Week 7: July 13 - 17

  • Break code into mesh, objects, and reader files. rB7582bbd5
  • Directly create Mesh without using intermediate BMesh ec04edfe5c. It lowered the peak memory usage by half. Also made mesh creation faster.
  • Use stoi and stof instead of >> for faster parsing. aacb1f4756. Time taken in string to float conversion is less now as compared to >> operator. But the cost is in splitting the string and allocations made for several substrings. Overall this is faster.
    OBJ import the same file as last week using stoi. cube subd 8; 23.3MB file.
  • Fix UV crashes and redundant loops in v1//vn1 case. rB92be92be
  • Support meshes with edges with or without polygons. 5a9b983263
  • Importer: Support smooth shading for polygons. rB031c4732
  • Importer: Fix misaligned UV vertices of a mesh rBfe4c5350
  • Exporter: fix vertex normals not being exported when smooth shading is enabled. Calculating smooth groups before exporting normals was the solution. rB501ead4b

Week 8 planned tasks

  • Due to curves, the parser needs some changes in how it stores the vertices. There can be vertices that belong to no object. And then later on an object refers to them with relative indices. So there needs to be another copy of all vertices which can be referred to by curves.
  • Grouping
  • MTL

Week6: July 6 - 10

  • Setup clang tidy with Ninja. On macOS, had to build llvm + clang 11 + tidy to get the executable. Also setup a build with clang 11 + leak sanitiser since Xcode's asan doesn't provide the functionality.
  • Import a mesh successfully in the viewport. It took a long time, trying to avoid Mesh, BMesh asserts, seg-faults and memory leaks due to un-freed meshes.
    • The mesh has vertex data only, so far. Texture coordinates are to be added.
    • The parser takes a long time. ~70% of the import process. Making a Blender object from the parsed data is the rest ~30%. So need to optimise it.
    • The importer is still 3-4 times faster than the python one.

Side note: an interesting diff is under review: Use mmap() IO for reading uncompressed .blends D8246

Week 7 planned tasks

  • Texture coordinates, normals and curves.
  • Vertex Grouping, object grouping.
  • Material library and grouping.

Week 5: June 29 - July 4

Ticked exporter checkbox in the status tracker task. T68936

Week 4: June 22-27

  • Review update and cleanup in the OOP refactor(rBf2a1a66b): rB0f383a3d.
  • Support NURBS being exported in parameter form, optionally. So far, they were exported as meshes. rB31d48017.
    • Support NURBS surfaces to be exported as a regular mesh. (same as above rB31d48017)
  • Broke down files to create new ones for OBJMesh and OBJNurbs. rB6c98925d Later on, MTLWriter will also have its own implementation file.
  • Support material library export. We decided against using the existing python writer, since there were no benefits of using it except saving some time now. To extend support, one would have to edit Node Shader Utils file first. Also debugging it would be a trouble. Since nodes are already in C/C++, we have more control there, instead of in the API.
    • Export of single material per object: rB827869a4. Support for multiple materials in one object: rBfaa11ec0
  • Changes in the UI:
  • Bug fixes:
    • Duplicate texture coordinates: rBef0eff0b
    • Show red colored warning if overriding an existing file while exporting (it was a wrong flag) rBc39128ca
    • Fix socket vector being read as socket RGBA rB7685d9e4

Remaining tasks

  • Smooth groups (and bitflags) & Vertex groups
  • Start with importer. I'm already lagging here User:Ankitm/GSoC_2020_Proposal_IO_Perf#Project_Schedule. But since the refactor I had planned for week 7 (along with profiling) won't take long, I feel that I have a good buffer to work in.

Week 3: June 15-19

  • Animation: Allow all frames to be exported, instead of 0-1000. Also filenames are also edited with frame number only if there are multiple frames. rB45461012
  • Worked on exposing more settings in the UI:
  • Add support for curves to be exported after converting them to meshes.
  • Refactor the code upto now to object-oriented style. (commit [todo], in review D8089)
    This allowed us to have minimal memory overhead with no timing cost. UV vertices, however, have to be allocated on heap and thus show a peak while exporting.

Unfortunately, I couldn't finish some goals at time: Material library, NURBS and grouping settings. So the goal for next week is to finish them as soon as possible and start with importer.

Week 2: June 8-13

  • The OBJ exporter now exports Texture Coordinates. rBf01a7d50. Not the MTL file yet. It's a goal of Week 3.
    Here's a table of comparison of a single object to one file which includes UV coordinates too.
Object File Size (There's a little difference due to the extra info like MTL in python )
(C++/ Python + MTL)
Export Time (fstream/fprintf)
(s)
Export time Python
(s)
Default cube + 8 subdivision surface levels 61.6 MB / 63 MB 3.1 / 1.9 s 20 s
Default cube + 9 subdivision surface levels 257.3 MB / 262 MB + 229 bytes MTL 10.7 / 6.7 s 82 s
Ico-sphere + 8 subdivision surface levels 663.1 MB / 674 MB + 124 bytes MTL 27.7 / 19 s 210 s
  • Since fstream is not adding any benefits and is slower too, it was removed.
  • It also exports multiple objects in the same file. But so far only OB_MESH object types are supported. rB40736795.
  • Multiple frames can also be exported now, in individual files. rB6d088bdd.
  • Progress is now shown on per-file basis in Terminal and timing in the end. It should be improved to act on per-object basis when there is a single frame.
  • The windows build to test is up: https://blender.community/c/graphicall/Pmbbbc/

Planned for Week 3

  • Curves, Axes transform, Scale transform.
  • Object Grouping, Indices (absolute is already there, will discuss about relative.)
  • Materials, Triangulation.

Week 1: June 1-6

  • Received a lot of input from the mentors regarding coding style, comments, documentation, and file structures. Spent quite some time on cleaning the hastily committed rB485cc433. See current version at Diffusion
  • Currently the exporter exports vertices, face normals, and face indices. In world coordinates.
  • It's lacking in (1) multiple objects, (2) texture coordinates (3) Axes transformation. If you compare obj txt files written with python & C++ , you'll see differences in vertex order, and some coordinates with opposite sign. But the shape is correct.
  • Did a comparison between the old & new exporters. Release configuration, lite build + opensubdiv, default cube with 9 subsurf modifiers. See images: F8586987 & F8586984. We're checking the time taken by wm_handler_fileselect_do function.
Object File Size (note that vt are not there in C++ yet so C++ file size is smaller.)
(C++/ Python + MTL)
Export Time (fstream/fprintf)
(s)
Export time Python
(s)
Default cube + 8 subdivision surface levels 48 MB / 63 MB 2.4 / 1.47 s 20 s
Default cube + 9 subdivision surface levels 186 MB / 262 MB + 229 bytes MTL 7.6 / 4.6 s 82 s
Ico-sphere + 8 subdivision surface levels 478 MB / 674 MB + 124 bytes MTL 22 / 13 s 210 s


Planned for Week 2

  • Textures, multiple objects in the same file.
  • Modifiers, Curves, Multiple frames , Axes transform, Progress logging

Week 0: before June 1

  • Updated the goals to move OBJ in the beginning & PLY in the end. See timeline:
  • Set up the branch soc-2020-io-performance : See on diffusion
  • Project status tracker and design discussion task on Phab: T68936
  • Get familiar with gperftools, see gperftools installation and use
  • Set up UI and file-handler API for both exporter & importer (OBJ).

Planned for Week 1

  • Export vertex coordinates, vertex normals, faces & texture coordinates.