minib3d small improvements on source
BlitzMax Forums/MiniB3D Module/minib3d small improvements on source
| ||
Hello. I've been taking a look to the minib3d source code using BLIde and the code analizer helps me find some possible improvements. On the file TMesh.bmx 1.- Function CreateCylinder. Line 540. There's a local defined called vpos that is assigned a 1.0 value. This variable is never used, so it could be removed as it can be a little bit confusing. 2.- Method FlipMesh. Line 903 There's a local defined Local v1=surf.tris[i1]. This local is never used. I'm not sure if removing this will make the code any faster, but the fact that there's a variable getting a value for nothing makes the code looks a little bit confusin (IMHO). 3.- Method Update. Line 1709 There a local array created that is also never used. Local no_mat#[]=[0.0,0.0] not sure what it was there for before, but now it does nothing but creating an array instance of 4 elements and release it becouse it's never again used in the code. 4.- Method Update. Line 1528 There's a string created Local name$=Self.EntityName$() that is also never used. This string calls a method. If the method is needed to do something, it would be enought to call Self.Entityname$() without having to assing the value somewhere. In the file TModel 1.- Function LoadAnimB3d. On the line 251 we surprisingly have this code: For Local i=1 To node_level tab$=tab$+"-" Next The variable tab$ is not used really anywhere else, so this loop does nothing but slow down the model loading. Also the declaration of the variable Tab at line 548 could be removed. 2.- In the same function, line 249, we have this code: Local info$="" If tag$="NODE" And parent_ent<>Null Then info$=" (parent= "+parent_ent.name$+")" The variable info is not really used anywhere else. I supose it was there for debug purposes, but now it only adds unnecesary work to the LoadAnimB3D function. I would comment it. 3.- In the same function, line 639 you declare a local ix=0 that is never used. 4.- In the same function, line 498 we have this code: If v_flags & 1 Then v_sz=v_sz+12 If v_flags & 2 Then v_sz=v_sz+16 but the variable v_sz is never checked or referenced again, so it is storing a counter to do nothing. 5.- In the same function, on line 112 you declare a local called tr_sz. This variable is only used on line 562 this way: tr_sz=12 It is not used to do anything but storing a 12. confusing and unnecesary. 6.- In the same function, starting at line 127 to line 140, all this variables: Local tr_x# Local tr_y# Local tr_z# Local tr_nx# Local tr_ny# Local tr_nz# Local tr_r# Local tr_g# Local tr_b# Local tr_u# Local tr_v# Local tr_w# Local tr_a# Local tr_no are declared (so allocated) but never used in the code. the same applies for variable tr_vid at line 123. 7.- In the same function, line 598 you use a variable called a_flags that is never used again. I would replace: a_flags=ReadInt(file)to ReadInt(file) 'Read flagsand remove the a_flags declaration on line 143 8.- In the same function, line 600 you use a variable called a_fps that is never used again. I would replace: a_fps=ReadFloat(file)to ReadFloat(file) 'Read fpsand remove the a_fps declaration on line 145 that's all I can see now. Hope this information is usefull as I'm starting to test miniB3D and I'm finding it great. Thanks for the great work done! |
| ||
Hmmm, I don't think these small bits of useless code will have any impact on MiniB3D's performance, but I guess it's kinda interesting to know all the same. Thanks. |
| ||
@Simonh: The idea of this post was not to bost minib3d performance even more, just a small note to make maintenance of the module easier. I think miniB3D is just incredibly awesome as it is. :D You've done a brilliant GREAT work. |