Skip to content

Commit b4916d3

Browse files
committed
Enable View and World.
1 parent 8e0fbc7 commit b4916d3

8 files changed

Lines changed: 37 additions & 21 deletions

File tree

KeeKee.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"PreMoveFudge": 0.4
4343
},
4444
"Renderer": {
45-
"RenderProvider": "OGL"
45+
"RenderProvider": "Null"
4646
},
4747
"RendererOGL": {
4848
"CamaraFar": 2048.0, // camera far clip

src/KeeKee.Comm.LLLP/CommLLLP.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ public void Objects_ObjectUpdate(object? sender, OMV.PrimEventArgs args) {
575575
try {
576576
if (rcontext.TryGetCreateEntityLocalID(args.Prim.LocalID, out updatedEntity, delegate () {
577577
// code called to create the entry if it's not found
578+
m_log.Log(KLogLevel.DUPDATEDETAIL, "ObjectUpdate: creating new entity for local ID {0}", args.Prim.LocalID);
578579
updateFlags |= UpdateCodes.New;
579580
updateFlags |= UpdateCodes.Acceleration | UpdateCodes.AngularVelocity | UpdateCodes.Velocity;
580581
return m_InstanceFactory.CreateLLPhysical(GridClient, args.Prim, rcontext, LLLPAssetContext);
@@ -687,6 +688,7 @@ public void Objects_AttachmentUpdate(object? sender, OMV.PrimEventArgs args) {
687688
UpdateCodes updateFlags = UpdateCodes.FullUpdate;
688689
IEntity ent;
689690
if (rcontext.TryGetCreateEntityLocalID(args.Prim.LocalID, out ent, () => {
691+
m_log.Log(KLogLevel.DUPDATEDETAIL, "OnNewAttachment: creating new entity for local ID {0}", args.Prim.LocalID);
690692
LLEntity newEnt = m_InstanceFactory.CreateLLPhysical(GridClient, args.Prim, rcontext, LLLPAssetContext);
691693
updateFlags |= UpdateCodes.New;
692694
string? attachmentID = "1"; // default attachment ID
@@ -724,9 +726,15 @@ private void Objects_TerseObjectUpdate(object? sender, OMV.TerseObjectUpdateEven
724726
return;
725727
}
726728
LLRegionContext rcontext = FindRegion(args.Simulator);
729+
if (rcontext == null) {
730+
m_log.Log(KLogLevel.DBADERROR, "TerseObjectUpdate: no region context for simulator {0}", args.Simulator.Name);
731+
return;
732+
}
733+
727734
OMV.ObjectMovementUpdate update = args.Update;
728735
m_stats.ObjTerseUpdate.Event();
729-
IEntity? updatedEntity = null;
736+
737+
// IEntity? updatedEntity = null;
730738
UpdateCodes updateFlags = 0;
731739
lock (m_opLock) {
732740
if (args.Prim.Acceleration != args.Update.Acceleration) updateFlags |= UpdateCodes.Acceleration;
@@ -744,8 +752,9 @@ private void Objects_TerseObjectUpdate(object? sender, OMV.TerseObjectUpdateEven
744752
m_log.Log(KLogLevel.DBADERROR, "TerseObjectUpdate: received prim with UUID zero");
745753
return;
746754
}
747-
if (rcontext.TryGetCreateEntityLocalID(args.Prim.LocalID, out updatedEntity, delegate () {
755+
if (rcontext.TryGetCreateEntityLocalID(args.Prim.LocalID, out var updatedEntity, delegate () {
748756
// code called to create the entry if it's not found
757+
m_log.Log(KLogLevel.DUPDATEDETAIL, "TerseObjectUpdate: creating new entity for local ID {0}", args.Prim.LocalID);
749758
updateFlags |= UpdateCodes.New;
750759
updateFlags |= UpdateCodes.Acceleration | UpdateCodes.AngularVelocity | UpdateCodes.Velocity;
751760
return m_InstanceFactory.CreateLLPhysical(GridClient, args.Prim, rcontext, LLLPAssetContext);

src/KeeKee.Entity/EntityCollection.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void AddEntity(IEntity entity) {
4848
// disconnect this work from the caller -- use another thread
4949
m_workQueueEvent.DoLater(DoEventLater, entity);
5050
} else {
51-
if (OnEntityNew != null) OnEntityNew(entity);
51+
OnEntityNew?.Invoke(entity);
5252
}
5353
}
5454
}
@@ -67,7 +67,7 @@ public void UpdateEntity(IEntity entity, UpdateCodes detail) {
6767
object[] parms = { entity, detail };
6868
m_workQueueEvent.DoLater(DoUpdateLater, parms);
6969
} else {
70-
if (OnEntityUpdate != null) OnEntityUpdate(entity, detail);
70+
OnEntityUpdate?.Invoke(entity, detail);
7171
}
7272
}
7373

@@ -76,17 +76,15 @@ private bool DoUpdateLater(DoLaterJob qInstance, object parm) {
7676
IEntity ent = (IEntity)parms[0];
7777
UpdateCodes detail = (UpdateCodes)parms[1];
7878
EntityUpdateCallback? euc = OnEntityUpdate;
79-
if (euc != null) {
80-
euc.Invoke(ent, detail);
81-
}
79+
euc?.Invoke(ent, detail);
8280
return true;
8381
}
8482

8583
public void RemoveEntity(IEntity entity) {
8684
m_log.Log(KLogLevel.DWORLDDETAIL, "RemoveEntity: " + entity.Name);
8785

8886
EntityRemovedCallback? erc = OnEntityRemoved;
89-
if (erc != null) erc.Invoke(entity);
87+
erc?.Invoke(entity);
9088

9189
lock (this) {
9290
m_entityDictionary.Remove(entity.Name.Name);

src/KeeKee.View/Viewer.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// See the License for the specific language governing permissions and
1010
// limitations under the License.
1111

12+
using Microsoft.Extensions.Hosting;
1213
using Microsoft.Extensions.Options;
1314

1415
using KeeKee.Config;
@@ -34,7 +35,7 @@ namespace KeeKee.View {
3435
/// User input
3536
///
3637
/// </summary>
37-
public class Viewer : IViewProvider {
38+
public class Viewer : BackgroundService, IViewProvider {
3839

3940
private KLogger<Viewer> m_log;
4041
private IOptions<ViewConfig> m_ViewConfig;
@@ -77,6 +78,9 @@ IWorld pWorld
7778
m_workQueue = pQueueManager.CreateBasicWorkQueue("ViewerWorkQueue");
7879
Renderer = pRenderer;
7980
TheWorld = pWorld;
81+
}
82+
83+
protected override async Task ExecuteAsync(CancellationToken cancellationToken) {
8084

8185
m_log.Log(KLogLevel.DINIT, "entered AfterAllModulesLoaded()");
8286

@@ -120,13 +124,14 @@ IWorld pWorld
120124
// start the renderer
121125
// ((IModule)Renderer).Start();
122126

123-
m_log.Log(KLogLevel.DINIT, "exiting Start()");
127+
await Task.CompletedTask;
128+
124129
return;
125130
}
126131

127132

128133
private void World_OnEntityNew(IEntity ent) {
129-
// m_log.Log(LogLevel.DVIEWDETAIL, "OnEntityNew: Telling renderer about a new entity");
134+
m_log.Log(KLogLevel.DVIEWDETAIL, "OnEntityNew: Telling renderer about a new entity");
130135
Renderer.Render(ent);
131136
}
132137

src/KeeKee.World.LL/LLEntity.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ public class LLEntity : IEntity {
2626
public const ulong NOREGION = 0xffffffff;
2727
public OMV.Simulator? Sim { get; set; }
2828

29-
30-
// an LL localID is a per sim unique handle for the item
31-
public const uint NOLOCALID = 0xffffffff;
32-
public uint LocalID { get; set; }
33-
3429
// Created with dependency injection to get the logger and contexts
3530
public LLEntity(KLogger<LLEntity> pLog,
3631
IWorld pWorld,
@@ -42,7 +37,13 @@ EntityClassifications pClassification
4237
: base(pLog, pWorld, pRContext, pAContext, pClassification) {
4338
this.Prim = pPrim;
4439
this.Sim = pRContext is LLRegionContext rcontext ? rcontext.Simulator : null;
45-
this.LocalID = pPrim != NullPrim ? pPrim.LocalID : LLEntity.NOLOCALID;
40+
41+
if (pPrim != NullPrim) {
42+
this.Name = new EntityName(pAContext, "Prim" + pPrim.LocalID.ToString());
43+
m_LGID = pPrim.LocalID;
44+
} else {
45+
this.Name = new EntityName("NullPrim");
46+
}
4647
}
4748

4849
/// <summary>

src/KeeKee.World.Services/RestHandlerAvatarTracker.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void World_OnAgentRemoved(IEntity pEnt) {
140140
}
141141

142142
void World_OnWorldEntityNew(IEntity pEnt) {
143-
if (pEnt.HasComponent<ICmptAvatar>()) {
143+
if (pEnt.Classification == EntityClassifications.AvatarEntity) {
144144
// this new entity is an avatar. If we don't know it already, remember same
145145
lock (m_avatars) {
146146
if (!m_avatars.ContainsKey(pEnt.Name.Name)) {
@@ -153,7 +153,7 @@ void World_OnWorldEntityNew(IEntity pEnt) {
153153
}
154154

155155
void World_OnWorldEntityUpdate(IEntity pEnt, UpdateCodes what) {
156-
if (pEnt.HasComponent<ICmptAvatar>()) {
156+
if (pEnt.Classification == EntityClassifications.AvatarEntity) {
157157
// this updated entity is an avatar. If we don't know it already, remember same
158158
lock (m_avatars) {
159159
if (!m_avatars.ContainsKey(pEnt.Name.Name)) {
@@ -166,7 +166,7 @@ void World_OnWorldEntityUpdate(IEntity pEnt, UpdateCodes what) {
166166
}
167167

168168
void World_OnWorldEntityRemoved(IEntity pEnt) {
169-
if (pEnt.HasComponent<ICmptAvatar>()) {
169+
if (pEnt.Classification == EntityClassifications.AvatarEntity) {
170170
// this entity is an avatar. If we're tracking it, stop that
171171
lock (m_avatars) {
172172
if (m_avatars.ContainsKey(pEnt.Name.Name)) {

src/KeeKee/KeeKee.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<ProjectReference Include="..\KeeKee.Renderer.Map\KeeKee.Renderer.Map.csproj" />
3535
<ProjectReference Include="..\KeeKee.Renderer.Null\KeeKee.Renderer.Null.csproj" />
3636
<ProjectReference Include="..\KeeKee.Rest\KeeKee.Rest.csproj" />
37+
<ProjectReference Include="..\KeeKee.View\KeeKee.View.csproj" />
3738
</ItemGroup>
3839

3940
<ItemGroup>

src/KeeKee/Main.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using KeeKee.Rest;
2525
using KeeKee.Renderer;
2626
using KeeKee.Framework;
27+
using KeeKee.View;
2728
using KeeKee.World;
2829
using KeeKee.World.LL;
2930
using KeeKee.Framework.WorkQueue;
@@ -169,6 +170,7 @@ public static async Task Main(string[] args) {
169170
// services.AddHostedService<ViewOGL>();
170171

171172
// The user interface
173+
services.AddHostedService<Viewer>();
172174
services.AddSingleton<IUserInterfaceProvider, UserInterfaceCommon>();
173175

174176
// KeeKee.Rest, IModule

0 commit comments

Comments
 (0)