Skip to content

Commit

Permalink
Merge from 'develop' into 'main' for CLOiSim-4.9.2 (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunseok-yang authored Nov 30, 2024
2 parents e993510 + f0b3d02 commit ab8a790
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ MonoBehaviour:
m_ShEvalMode: 0
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 2048
m_AdditionalLightsRenderingMode: 0
m_MainLightShadowmapResolution: 1024
m_AdditionalLightsRenderingMode: 1
m_AdditionalLightsPerObjectLimit: 4
m_AdditionalLightShadowsSupported: 1
m_AdditionalLightsShadowmapResolution: 256
Expand All @@ -59,8 +59,8 @@ MonoBehaviour:
m_ConservativeEnclosingSphere: 0
m_NumIterationsEnclosingSphere: 64
m_SoftShadowQuality: 2
m_AdditionalLightsCookieResolution: 1024
m_AdditionalLightsCookieFormat: 3
m_AdditionalLightsCookieResolution: 512
m_AdditionalLightsCookieFormat: 2
m_UseSRPBatcher: 1
m_SupportsDynamicBatching: 1
m_MixedLightingSupported: 1
Expand Down
3 changes: 3 additions & 0 deletions Assets/Scenes/MainScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1850,17 +1850,20 @@ MonoBehaviour:
- ../world_resources/app.gazebosim.org
- ../world_resources/logistics_center/models
- ../world_resources/smallhouse/models
- ../world_resources/meta-home/models
_worldRootDirectories:
- ../sample_resources/worlds/
- ../world_resources/bluepearl/worlds
- ../world_resources/lawn_ground/worlds
- ../world_resources/seocho_tower/worlds
- ../world_resources/logistics_center/worlds
- ../world_resources/smallhouse/worlds
- ../world_resources/meta-home/worlds
_fileRootDirectories:
- ../sample_resources/media/
- ../world_resources/bluepearl/media
- ../world_resources/lawn_ground
- ../world_resources/smallhouse
--- !u!1 &314493398
GameObject:
m_ObjectHideFlags: 0
Expand Down
19 changes: 10 additions & 9 deletions Assets/Scripts/Devices/Modules/Base/DeviceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,32 @@ public static string GetModelName(in GameObject targetObject, in bool searchOnly
{
try
{
var nextObject = targetObject.GetComponentInParent<SDF.Helper.Model>() as SDF.Helper.Base;
SDF.Helper.Base nextObject = targetObject.GetComponentInParent<SDF.Helper.Model>();

if (nextObject == null)
{
nextObject = targetObject.GetComponentInParent<SDF.Helper.Actor>() as SDF.Helper.Base;
nextObject = targetObject.GetComponentInParent<SDF.Helper.Actor>();
}

if (nextObject == null)
{
return string.Empty;
}

if (searchOnlyOneDepth == false)
if (searchOnlyOneDepth == false && nextObject != null &&
!nextObject.CompareTag("Actor"))
{
while (!SDF2Unity.IsRootModel(nextObject.transform))
{
nextObject = nextObject.transform.parent.GetComponentInParent<SDF.Helper.Base>();

if (nextObject == null)
{
return string.Empty;
break;
}
}
}

if (nextObject == null)
{
return string.Empty;
}

return nextObject.name;
}
catch
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Devices/Sonar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void OnTriggerStay(Collider other)
var sonar = sonarStamped.Sonar;
sonar.Range = detectedRange;
sonar.Contact.Set(contactPoint);
// Debug.Log(deviceName + ": " + other.name + " |Stay| " + detectedRange.ToString("F5") + " | " + contactPoint);
// Debug.Log(DeviceName + ": " + other.name + " |Stay| " + detectedRange.ToString("F5") + " | " + contactPoint);

pingpongindex++;
pingpongindex %= 2;
Expand Down
12 changes: 11 additions & 1 deletion Assets/Scripts/Tools/Mesh/Assimp.Mesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ private static MeshMaterialList LoadMeshes(in List<Assimp.Mesh> sceneMeshes)
return meshMatList;
}

private static Vector3 ToUnityScale(in Vector3 value)
{
return new Vector3(value.z, value.x, value.y);
}

private static GameObject ToUnityMeshObject(
this Assimp.Node node,
in MeshMaterialList meshMatList,
Expand Down Expand Up @@ -400,9 +405,14 @@ private static GameObject ToUnityMeshObject(

// Convert Assimp transfrom into Unity transform
var nodeTransformMatrix = node.Transform.ToUnity();

nodeObject.transform.localPosition = nodeTransformMatrix.GetPosition();
nodeObject.transform.localRotation = nodeTransformMatrix.rotation;
nodeObject.transform.localScale = nodeTransformMatrix.lossyScale;
nodeObject.transform.localScale = ToUnityScale(nodeTransformMatrix.lossyScale);

// Debug.Log("ToUnityMeshObject : " + node.Name + ", " + nodeTransformMatrix.GetPosition() );
// Debug.Log("ToUnityMeshObject : " + node.Name + ", " + nodeTransformMatrix.rotation );
// Debug.Log("ToUnityMeshObject : " + node.Name + ", " + nodeTransformMatrix.lossyScale );

doFlip = (nodeObject.transform.localScale.x < 0 ||
nodeObject.transform.localScale.y < 0 ||
Expand Down
6 changes: 4 additions & 2 deletions Assets/Scripts/Tools/SDF/Helper/Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ public void Reset()
private void UpdateRootModel()
{
var modelHelpers = GetComponentsInParent(typeof(Model));
_rootModelInScopre = (Model)modelHelpers[modelHelpers.Length - 1];
// UE.Debug.Log($"{name}: BaseHelper _rootModel={_rootModel}");
if (modelHelpers.Length > 0)
{
_rootModelInScopre = (Model)modelHelpers[modelHelpers.Length - 1];
}
}

public void ClearPose()
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Tools/SDF/Import/Import.Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ protected void ImportLinks(IReadOnlyList<Link> items, in Object parentObject)

ImportSensors(item.GetSensors(), createdObject);

ImportLights(item.GetLights());

AfterImportLink(item, createdObject);
}
}
Expand Down
17 changes: 11 additions & 6 deletions Assets/Scripts/Tools/SDF/Import/Import.Light.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ namespace Import
{
public partial class Loader : Base
{
private const float DefaultLightIntensity = 50;

protected override void ImportLight(in Light light)
{
if (light == null)
Expand All @@ -41,36 +39,43 @@ protected override void ImportLight(in Light light)

var direction = SDF2Unity.Direction(light.direction);

var defaultLightDirection = UE.Quaternion.identity;
var defaultIntensity = 1f;
const float rangeIntensityRatio = 0.3f;
switch (light.Type)
{
case "directional":
lightComponent.type = UE.LightType.Directional;
lightComponent.transform.localRotation = UE.Quaternion.LookRotation(UE.Vector3.down, direction);

break;

case "spot":
lightComponent.type = UE.LightType.Spot;
lightComponent.spotAngle = (float)light.spot.outer_angle * Mathf.Rad2Deg;
lightComponent.innerSpotAngle = (float)light.spot.inner_angle * Mathf.Rad2Deg;
lightComponent.range = (float)light.attenuation.range;
lightComponent.intensity = (light.intensity.Equals(1)) ? DefaultLightIntensity : (float)light.intensity;
defaultIntensity = lightComponent.range * rangeIntensityRatio;
defaultLightDirection = UE.Quaternion.Euler(90, 0, 0);
break;

case "point":
default:
lightComponent.type = UE.LightType.Point;
lightComponent.range = (float)light.attenuation.range;
lightComponent.transform.localRotation = UE.Quaternion.LookRotation(UE.Vector3.down, direction);
lightComponent.intensity = (light.intensity.Equals(1)) ? DefaultLightIntensity : (float)light.intensity;
defaultIntensity = lightComponent.range * rangeIntensityRatio;
break;
}

// TODO: Since <intensity> element was introdueced from SDF 1.7, the intensity may not exist.
// As a workaround code, set half of range value for intensity.
lightComponent.intensity = (light.intensity.Equals(1)) ? defaultIntensity : (float)light.intensity;

var localPosition = SDF2Unity.Position(light.Pose?.Pos);
var localRotation = SDF2Unity.Rotation(light.Pose?.Rot);

newLightObject.transform.localPosition = localPosition;
newLightObject.transform.localRotation *= localRotation;
newLightObject.transform.localRotation *= (localRotation * defaultLightDirection);
}
}
}
Expand Down
22 changes: 19 additions & 3 deletions Assets/Scripts/Tools/SDF/Import/Import.Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,27 @@ protected override void AfterImportLink(in SDF.Link link, in System.Object targe
return;
}

var linkHelper = linkObject.GetComponent<Helper.Link>();

// skip to create articulation body when inertial element is null
var modelHelpers = linkObject.GetComponentsInParent<Helper.Model>();

var hasStaticModel = false;
for (var i = 0; i < modelHelpers.Length; i++)
{
var modelHelper = modelHelpers[i];
// Debug.LogWarning($"AfterImportLink: {linkObject.name} {modelHelper.name} {link.Name} {modelHelper.isStatic} {modelHelper.gameObject.isStatic}");
if (modelHelper.isStatic)
{
hasStaticModel = true;
}

if (modelHelper.IsFirstChild || hasStaticModel)
{
break;
}
}

var inertial = link.Inertial;
if (!linkHelper.Model.isStatic && inertial != null)
if (!hasStaticModel && inertial != null)
{
Loader.CreateArticulationBody(linkObject, inertial);
}
Expand Down
5 changes: 5 additions & 0 deletions Assets/Scripts/Tools/SDF/Parser/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,10 @@ public void FromString(string value)

A = (double)Convert.ChangeType(tmp[3], TypeCode.Double);
}

public override string ToString()
{
return $"{base.ToString()} R={R:f5} G={G:f5} B={B:f5} A={A:f5}";
}
}
}
2 changes: 1 addition & 1 deletion Assets/Scripts/Tools/SDF/Parser/Light.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected override void ParseElements()

if (IsValidNode("specular"))
{
diffuse.FromString(GetValue<string>("specular"));
specular.FromString(GetValue<string>("specular"));
}

if (IsValidNode("attenuation"))
Expand Down
25 changes: 16 additions & 9 deletions Assets/Scripts/Tools/SDF/Parser/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ public class Link : Entity
private VelocityDecay _velocity_decay = null;

private Inertial _inertial = null;
private Collisions collisions = null;
private Visuals visuals = null;
private Sensors sensors = null;
private Collisions _collisions = null;
private Visuals _visuals = null;
private Sensors _sensors = null;
private Lights _lights = null;

// <projector> : TBD
// <audio_sink> : TBD
Expand Down Expand Up @@ -96,9 +97,10 @@ public Link(XmlNode _node)

protected override void ParseElements()
{
collisions = new Collisions(root);
visuals = new Visuals(root);
sensors = new Sensors(root);
_collisions = new Collisions(root);
_visuals = new Visuals(root);
_sensors = new Sensors(root);
_lights = new Lights(root);

gravity = GetValue<bool>("gravity", true);
enable_wind = GetValue<bool>("enable_wind", false);
Expand Down Expand Up @@ -152,17 +154,22 @@ protected override void ParseElements()

public List<Collision> GetCollisions()
{
return collisions.GetData();
return _collisions.GetData();
}

public List<Visual> GetVisuals()
{
return visuals.GetData();
return _visuals.GetData();
}

public List<Sensor> GetSensors()
{
return sensors.GetData();
return _sensors.GetData();
}

public List<Light> GetLights()
{
return _lights.GetData();
}
}
}
10 changes: 5 additions & 5 deletions ProjectSettings/GraphicsSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ GraphicsSettings:
m_DefaultRenderingPath: 1
m_DefaultMobileRenderingPath: 1
m_TierSettings: []
m_LightmapStripping: 0
m_LightmapStripping: 1
m_FogStripping: 0
m_InstancingStripping: 0
m_BrgStripping: 0
m_LightmapKeepPlain: 1
m_LightmapKeepDirCombined: 1
m_LightmapKeepPlain: 0
m_LightmapKeepDirCombined: 0
m_LightmapKeepDynamicPlain: 1
m_LightmapKeepDynamicDirCombined: 1
m_LightmapKeepShadowMask: 1
m_LightmapKeepSubtractive: 1
m_LightmapKeepShadowMask: 0
m_LightmapKeepSubtractive: 0
m_FogKeepLinear: 1
m_FogKeepExp: 1
m_FogKeepExp2: 1
Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ PlayerSettings:
loadStoreDebugModeEnabled: 0
visionOSBundleVersion: 1.0
tvOSBundleVersion: 1.0
bundleVersion: 4.9.1
bundleVersion: 4.9.2
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down

0 comments on commit ab8a790

Please sign in to comment.