Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005799opensim[REGION] Script Functionspublic2011-11-24 13:372011-12-03 08:03
Reportermarc 
Assigned Tojustincc 
PriorityhighSeveritymajorReproducibilityalways
Statuspatch feedbackResolutionopen 
PlatformOSOS Version
Product Versionmaster (dev code) 
Target VersionFixed in Version 
Summary0005799: Face count incorrect for Mesh Prims & generic problem determine count of faces on a Mesh
DescriptionAny change of face color don't work right on mesh Prims with more the 2 faces from LSL. For a single mesh prim there could be up to 8 faces defined. The underlying

public void SetFaceColor(Vector3 color, int face) for all LSL functions changing face color using GetNumberOfSides() returns for Mesh Prim 1 as Sculpty. The Type is right but there must be difference to adress the right amount of faces! Even if the source is patched to accept sculpts with more prims and the SetFaceColor function is changed there seems to be some problems down to libopenmetaverse

  
Steps To ReproduceUpload a single mesh that consist of several subobjects using one Texture and try to change the color of a face with (Just ALL_SIDES works):

 llSetLinkPrimitiveParamsFast
 osSetPrimitiveParams
 llGetNumberOfSides
 llSetColor

Additional InformationIf you do this by hand with the viewer "Select Face" and change color everything works fine on a mesh
TagsNo tags attached.
Git Revision or version numbernot sure
Run Mode Standalone (Multiple Regions)
Physics EngineBasicPhysics
Script Engine
EnvironmentMono / Linux32
Mono VersionNone
ViewerSecondlife Beta 3
Attached Filespatch file icon 0001-Workaround-for-mesh-to-correct-the-number-of-faces-i.patch [^] (1,599 bytes) 2011-11-25 06:47 [Show Content]

- Relationships

-  Notes
(0020383)
justincc (administrator)
2011-11-24 13:41

Do you have the patch for the attempted opensim changes?
(0020384)
marc (reporter)
2011-11-24 14:00

Just a dirty hack to enable sculpts to have more then 1 side. Have no idea if side effects used on not existing face just to see if the problem goes deeper!

        public void SetFaceColor(Vector3 color, int face)
        {
            Primitive.TextureEntry tex = Shape.Textures;
            Color4 texcolor;
            
            
        // Special for MESHES
       int numberOfSides;
       PrimType primType = GetPrimType();
            
       if ((face >= 0) && (primType == PrimType.SCULPT))
       {
        numberOfSides = 7;
       }
           else
       {
        numberOfSides = GetNumberOfSides();
      }
                
            if (face >= 0 && face < numberOfSides)
            {
                texcolor = tex.CreateFace((uint)face).RGBA;
                texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
                texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
                texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
                tex.FaceTextures[face].RGBA = texcolor;
                UpdateTexture(tex);
                TriggerScriptChangedEvent(Changed.COLOR);
                return;
            }
            else if (face == ALL_SIDES)
            {
                for (uint i = 0; i < GetNumberOfSides(); i++)
                {
                    m_log.Error("[COLOR ALL]: side="+face);
                    if (tex.FaceTextures[i] != null)
                    {
                        texcolor = tex.FaceTextures[i].RGBA;
                        texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
                        texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
                        texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
                        tex.FaceTextures[i].RGBA = texcolor;
                    }
                    texcolor = tex.DefaultTexture.RGBA;
                    texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
                    texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
                    texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
                    tex.DefaultTexture.RGBA = texcolor;
                }
                UpdateTexture(tex);
                TriggerScriptChangedEvent(Changed.COLOR);
                return;
            }
        }
(0020385)
justincc (administrator)
2011-11-24 14:01

Thanks. I suspect there's no quick fix for this but it's useful to have that information.
(0020386)
marc (reporter)
2011-11-25 06:53

Hi,
I picked it up again and with the now included patch it worked perfect for me on meshes. I just tried to to recognize a mesh type a bit deeper with Shape.SculptType that seems to be for meshes = 5. With that makes the LSL function depending on the the face/side count working for meshes & sculpts.
(0020400)
marc (reporter)
2011-11-27 16:39

Adressing faces for meshes now works with that patch
(0020434)
justincc (administrator)
2011-12-02 14:27

In your patch, I see that the comment says that mesh has 8 faces, yet the return value is 7. Is this correct?

Also, do meshes always have 8 faces or does this depend on the mesh? Would there be a problem if a higher number of sides was returned than the mesh actually has?
(0020435)
marc (reporter)
2011-12-02 19:10

Yes thats correct adressing the faces starts in LSL ALL_SIDES = -1, 0..7 so 0..7 are the max sides on normal prims. A mesh can have up to 8 faces/sides that can be adressed to change the color/texture. Technical a collada file could have much more, its a Linden decission to keep them at max of 8, I guess they made it like that to stay compatible with the rest so they had no big changes for LSL. As far I have tested it it doesn't matter if you adress a face that doesn't exist on a mesh, the patch just gives back the max value and not the value that might be set during the import of the mesh. I will try to dig there a bit deeper maybe it is set in some member var so it can be used to return the real face count on a mesh.
(0020437)
justincc (administrator)
2011-12-03 08:03

I have applied this patch in git master e75bcd4. I think the returned number of sides for a sculpt should be 8 - this is the actual sides number, not the maximum index number from LSL's perspective. Let me know if this is wrong.

I'd be very interested to see another patch which returns the actual number if you can find the data value - I must admit, I don't know where it would be offhand.

- Issue History
Date Modified Username Field Change
2011-11-24 13:37 marc New Issue
2011-11-24 13:41 justincc Note Added: 0020383
2011-11-24 14:00 marc Note Added: 0020384
2011-11-24 14:01 justincc Note Added: 0020385
2011-11-25 06:47 marc File Added: 0001-Workaround-for-mesh-to-correct-the-number-of-faces-i.patch
2011-11-25 06:53 marc Note Added: 0020386
2011-11-27 16:39 marc Note Added: 0020400
2011-11-27 16:39 marc Status new => patch included
2011-12-02 14:27 justincc Note Added: 0020434
2011-12-02 14:27 justincc Assigned To => justincc
2011-12-02 14:27 justincc Status patch included => patch feedback
2011-12-02 19:10 marc Note Added: 0020435
2011-12-03 08:03 justincc Note Added: 0020437


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker